Skip to content

Commit

Permalink
feat: Improve output for dockerfile instructions
Browse files Browse the repository at this point in the history
This commit allows for use of the installCommand extracted
from a RUN instruction in newer versions of the SDP.

[CAP-280]
  • Loading branch information
pecodez committed Nov 24, 2021
1 parent 9ab4e54 commit 94c08ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/snyk-test/run-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ async function parseRes(
const dockerfilePackage = dockerfilePackages[vuln.name.split('/')[0]];
if (dockerfilePackage) {
(vuln as DockerIssue).dockerfileInstruction =
dockerfilePackage.instruction;
dockerfilePackage.installCommand;
}
(vuln as DockerIssue).dockerBaseImage = res.docker!.baseImage;
return vuln;
Expand Down
10 changes: 6 additions & 4 deletions test/acceptance/cli-test/cli-test.docker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const DockerTests: AcceptanceTests = {
dockerfilePackages: {
'openssl@1.5.0': {
instruction: 'RUN apk add openssl@1.5.0',
installCommand: 'apk add openssl@1.5.0',
},
},
dockerfileLayers: {
Expand Down Expand Up @@ -264,6 +265,7 @@ export const DockerTests: AcceptanceTests = {
dockerfilePackages: {
'openssl@1.5.0': {
instruction: 'RUN apk add openssl@1.5.0',
installCommand: 'apk add openssl@1.5.0',
},
},
dockerfileLayers: {
Expand Down Expand Up @@ -649,7 +651,7 @@ export const DockerTests: AcceptanceTests = {
data: {
dockerfilePackages: {
bzip2: {
instruction: 'RUN test instruction',
installCommand: 'test installCommand',
},
},
},
Expand Down Expand Up @@ -678,7 +680,7 @@ export const DockerTests: AcceptanceTests = {
t.fail('should have found vuln');
} catch (err) {
const msg = err.message;
t.match(msg, "Image layer: 'RUN test instruction'");
t.match(msg, "Image layer: 'test installCommand'");
}
},

Expand All @@ -697,7 +699,7 @@ export const DockerTests: AcceptanceTests = {
data: {
dockerfilePackages: {
bzip2: {
instruction: 'RUN test instruction',
installCommand: 'test installCommand',
},
},
},
Expand Down Expand Up @@ -726,7 +728,7 @@ export const DockerTests: AcceptanceTests = {
t.fail('should have found vuln');
} catch (err) {
const msg = err.message;
t.match(msg, "Image layer: 'RUN test instruction'");
t.match(msg, "Image layer: 'test installCommand'");
}
},

Expand Down

0 comments on commit 94c08ad

Please sign in to comment.