From 8cf181582031466702aecd4cc0e39f64408dcef3 Mon Sep 17 00:00:00 2001 From: Ofek Atar Date: Wed, 31 Aug 2022 15:35:06 +0300 Subject: [PATCH] feat: Added support for depth-detection --- src/cli/commands/test/iac/v2/assert-iac-options.ts | 1 + src/cli/commands/test/iac/v2/index.ts | 3 +++ src/lib/iac/test/v2/scan/index.ts | 4 ++++ src/lib/iac/test/v2/types.ts | 1 + 4 files changed, 9 insertions(+) diff --git a/src/cli/commands/test/iac/v2/assert-iac-options.ts b/src/cli/commands/test/iac/v2/assert-iac-options.ts index c2601411ee..048a5f4310 100644 --- a/src/cli/commands/test/iac/v2/assert-iac-options.ts +++ b/src/cli/commands/test/iac/v2/assert-iac-options.ts @@ -22,6 +22,7 @@ const keys: (keyof IaCTestFlags)[] = [ 'scan', 'experimental', 'var-file', + 'detectionDepth', // PolicyOptions 'ignore-policy', 'policy-path', diff --git a/src/cli/commands/test/iac/v2/index.ts b/src/cli/commands/test/iac/v2/index.ts index d452ba90d6..9577387a1f 100644 --- a/src/cli/commands/test/iac/v2/index.ts +++ b/src/cli/commands/test/iac/v2/index.ts @@ -54,6 +54,8 @@ async function prepareTestConfig( const projectTags = parseTags(options); const targetName = getFlag(options, 'target-name'); const remoteRepoUrl = getFlag(options, 'remote-repo-url'); + const depthDetection = + parseInt(getFlag(options, 'depth-detection') as string) || undefined; const attributes = parseAttributes(options); const policy = await findAndLoadPolicy(process.cwd(), 'iac', options); const scan = options.scan ?? 'resource-changes'; @@ -73,6 +75,7 @@ async function prepareTestConfig( remoteRepoUrl, policy: policy?.toString(), scan, + depthDetection, }; } diff --git a/src/lib/iac/test/v2/scan/index.ts b/src/lib/iac/test/v2/scan/index.ts index e471b137b1..72a4eeec1b 100644 --- a/src/lib/iac/test/v2/scan/index.ts +++ b/src/lib/iac/test/v2/scan/index.ts @@ -113,6 +113,10 @@ function processFlags( flags.push('-project-lifecycle', options.attributes.lifecycle.join(',')); } + if (options.depthDetection) { + flags.push('-depth-detection', `${options.depthDetection}`); + } + if (options.projectTags) { const stringifiedTags = options.projectTags .map((tag) => { diff --git a/src/lib/iac/test/v2/types.ts b/src/lib/iac/test/v2/types.ts index deb8224939..08ae6cf0f0 100644 --- a/src/lib/iac/test/v2/types.ts +++ b/src/lib/iac/test/v2/types.ts @@ -17,4 +17,5 @@ export interface TestConfig { remoteRepoUrl?: string; policy?: string; scan: string; + depthDetection?: number; }