From ae5d4a43b70869040e2204bb3f4247def83654d8 Mon Sep 17 00:00:00 2001 From: Charles Hu <106095667+charleshu-8@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:20:46 -0400 Subject: [PATCH] Mapper tweaks (#6054) Signed-off-by: Charles Hu --- libs/hdf-converters/src/twistlock-mapper.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/hdf-converters/src/twistlock-mapper.ts b/libs/hdf-converters/src/twistlock-mapper.ts index 7bf1671eb0..7dd38f6e39 100644 --- a/libs/hdf-converters/src/twistlock-mapper.ts +++ b/libs/hdf-converters/src/twistlock-mapper.ts @@ -27,12 +27,14 @@ export class TwistlockResults { constructor(twistlockJson: string, withRaw = false) { this.data = JSON.parse(twistlockJson); this.withRaw = withRaw; - } - toHdf(): ExecJSON.Execution { + // Add a wrapper to the data for the repository scan case which doesn't include the `results` key if (!_.has(this.data, 'results')) { this.data = {results: [this.data]}; } + } + + toHdf(): ExecJSON.Execution { return new TwistlockMapper(this.data, this.withRaw).toHdf(); } } @@ -107,9 +109,8 @@ export class TwistlockMapper extends BaseConverter { transformer: impactMapping(IMPACT_MAPPING) }, code: { - transformer: (vulnerability: Record): string => { - return JSON.stringify(vulnerability, null, 2); - } + transformer: (vulnerability: Record): string => + JSON.stringify(vulnerability, null, 2) }, results: [ {