Skip to content

Commit 4d8273d

Browse files
committedJul 30, 2021
test: show that excluding base image vulns returns wrong exit code
The Snyk CLI first produces a not-ok test result when it gets the list of vulnerabilities from Snyk and only then excludes the base image vulns when using the --exclude-base-image-vulns CLI flag. This leads it to incorrectly reporting an error. The CLI sees an unsuccessful test response with 0 vulnerabilities and cannot handle it.
1 parent 294148c commit 4d8273d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM alpine:3.12.0

‎test/jest/acceptance/cli-args.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,18 @@ test('container test --sarif-file-output can be used at the same time as --json'
332332
expect(sarifOutput.version).toMatch('2.1.0');
333333
expect(code).toEqual(0);
334334
});
335+
336+
test('bug: container test --file=Dockerfile --exclude-base-image-vulns returns exit code 2', async () => {
337+
const dockerfilePath = path.normalize(
338+
'test/acceptance/fixtures/docker/Dockerfile.alpine-3.12.0',
339+
);
340+
341+
const { code, stdout } = await runSnykCLI(
342+
`container test alpine:3.12.0 --json --file=${dockerfilePath} --exclude-base-image-vulns`,
343+
);
344+
const jsonOutput = JSON.parse(stdout);
345+
346+
// BUG: it should return ok: true and exit code 0 when all vulns are excluded
347+
expect(jsonOutput.ok).toEqual(false);
348+
expect(code).toEqual(2);
349+
});

0 commit comments

Comments
 (0)
Please sign in to comment.