Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return correct exit code when using --exclude-base-image-vulns
We now filter the vulnerabilities when using the --exclude-base-image-vulns flag before we decide if the test response was successful.
- Loading branch information
1 parent
4d8273d
commit 2c5b41d
Showing
3 changed files
with
32 additions
and
23 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
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 |
---|---|---|
|
@@ -10,6 +10,11 @@ const createOutputDirectory = (): string => { | |
return outputPath; | ||
}; | ||
|
||
const isWindows = | ||
require('os-name')() | ||
.toLowerCase() | ||
.indexOf('windows') === 0; | ||
|
||
jest.setTimeout(1000 * 60 * 5); | ||
|
||
test('snyk test command should fail when --file is not specified correctly', async () => { | ||
|
@@ -333,17 +338,20 @@ test('container test --sarif-file-output can be used at the same time as --json' | |
expect(code).toEqual(0); | ||
}); | ||
|
||
test('bug: container test --file=Dockerfile --exclude-base-image-vulns returns exit code 2', async () => { | ||
const dockerfilePath = path.normalize( | ||
'test/acceptance/fixtures/docker/Dockerfile.alpine-3.12.0', | ||
); | ||
if (!isWindows) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ivanstanev
Author
Contributor
|
||
// Previously we used to have a bug where --exclude-base-image-vulns returned exit code 2. | ||
// This test asserts that the bug no longer exists. | ||
test('container test --file=Dockerfile --exclude-base-image-vulns returns exit code 0', async () => { | ||
const dockerfilePath = path.normalize( | ||
'test/acceptance/fixtures/docker/Dockerfile.alpine-3.12.0', | ||
); | ||
|
||
const { code, stdout } = await runSnykCLI( | ||
`container test alpine:3.12.0 --json --file=${dockerfilePath} --exclude-base-image-vulns`, | ||
); | ||
const jsonOutput = JSON.parse(stdout); | ||
const { code, stdout } = await runSnykCLI( | ||
`container test alpine:3.12.0 --json --file=${dockerfilePath} --exclude-base-image-vulns`, | ||
); | ||
const jsonOutput = JSON.parse(stdout); | ||
|
||
// BUG: it should return ok: true and exit code 0 when all vulns are excluded | ||
expect(jsonOutput.ok).toEqual(false); | ||
expect(code).toEqual(2); | ||
}); | ||
expect(jsonOutput.ok).toEqual(true); | ||
expect(code).toEqual(0); | ||
}); | ||
} |
@ivanstanev , do you remember why this text is excluded from windows? cannot see anything obvious from the code.