-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3604 from snyk/feat/add-scan-flag-support
feat: add scan flag support
- Loading branch information
Showing
7 changed files
with
67 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
assertTerraformPlanModes, | ||
FlagError, | ||
} from '../local-execution/assert-iac-options-flag'; | ||
import { IaCTestFlags } from '../local-execution/types'; | ||
|
||
const keys: (keyof IaCTestFlags)[] = [ | ||
'debug', | ||
'v', | ||
'version', | ||
'h', | ||
'help', | ||
'q', | ||
'quiet', | ||
'org', | ||
'insecure', | ||
'severityThreshold', | ||
'json', | ||
'sarif', | ||
'json-file-output', | ||
'sarif-file-output', | ||
'scan', | ||
'experimental', | ||
'var-file', | ||
// PolicyOptions | ||
'ignore-policy', | ||
'policy-path', | ||
]; | ||
const allowed = new Set<string>(keys); | ||
|
||
export function assertIacV2Options(options: IaCTestFlags): void { | ||
// We process the process.argv so we don't get default values. | ||
for (const key of Object.keys(options)) { | ||
// The _ property is a special case that contains non | ||
// flag strings passed to the command line (usually files) | ||
// and `iac` is the command provided. | ||
if (key !== '_' && key !== 'iac' && !allowed.has(key)) { | ||
throw new FlagError(key); | ||
} | ||
} | ||
|
||
if (options.scan) { | ||
assertTerraformPlanModes(options.scan as string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
src/lib/iac/test/v2/local-cache/policy-engine/constants/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ export interface TestConfig { | |
targetName?: string; | ||
remoteRepoUrl?: string; | ||
policy?: string; | ||
scan: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters