-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new shim to wrap the legacy and current iac flows.
- Loading branch information
Showing
10 changed files
with
103 additions
and
65 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { assertIaCOptionsFlags } from './iac-local-execution/assert-iac-options-flag'; | ||
import { IaCTestOptions } from './iac-local-execution/types'; | ||
import { test as localTest } from './iac-local-execution'; | ||
import { test as legacyTest } from '../../../lib'; | ||
import { TestResult } from '../../../lib/snyk-test/legacy'; | ||
import { IacFileInDirectory } from '../../../lib/types'; | ||
|
||
/** | ||
* Shim around the new local execution test path and the existing remote | ||
* test flow. We also locally deal with the way the legacy test flow exposes | ||
* the scanned files via the `options.iacDirFiles` object here so that | ||
* in the new flow we do not mutate the options object. | ||
*/ | ||
export async function test( | ||
pathToScan: string, | ||
options: IaCTestOptions, | ||
): Promise<{ | ||
results: TestResult | TestResult[]; | ||
files: IacFileInDirectory[] | null; | ||
}> { | ||
// Ensure that all flags are correct. We do this to ensure that the | ||
// caller doesn't accidentally mistype --experimental and send their | ||
// configuration files to our backend by accident. | ||
assertIaCOptionsFlags(process.argv); | ||
|
||
if (options.experimental) { | ||
// this path is an experimental feature feature for IaC which does issue scanning locally without sending files to our Backend servers. | ||
// once ready for GA, it is aimed to deprecate our remote-processing model, so IaC file scanning in the CLI is done locally. | ||
return localTest(pathToScan, options); | ||
} | ||
|
||
const results = await legacyTest(pathToScan, options); | ||
return { files: options.iacDirFiles ?? null, results }; | ||
} |
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
3 changes: 1 addition & 2 deletions
3
...nit-tests/assert-iac-options-flag.spec.ts → ...nit-tests/assert-iac-options-flag.spec.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