Skip to content

Commit

Permalink
Merge pull request #327 from snyk/fix/undefined-base-image
Browse files Browse the repository at this point in the history
fix: Undefined base image
  • Loading branch information
robcresswell committed Jan 9, 2019
2 parents bc82842 + 962810a commit a8c561d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cli/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ function formatIssues(vuln, options) {
? createRemediationText(vuln, packageManager)
: '',
fixedIn: options.docker ? createFixedInText(vulnerableRange, version) : '',
dockerfilePackage: options.docker && vuln.dockerfileInstruction
? `\n Introduced in your Dockerfile by '${ vuln.dockerfileInstruction }'`
: `\n Introduced by your base image (${ vuln.dockerBaseImage })`,
dockerfilePackage: options.docker ? dockerfileInstructionText(vuln) : '',
};

return (
Expand All @@ -377,6 +375,18 @@ function formatIssues(vuln, options) {
);
}

function dockerfileInstructionText(vuln) {
if (vuln.dockerfileInstruction) {
return `\n Introduced in your Dockerfile by '${ vuln.dockerfileInstruction }'`;
}

if (vuln.dockerBaseImage) {
return `\n Introduced by your base image (${ vuln.dockerBaseImage })`;
}

return '';
}

function createFixedInText(versionRangeList, pkgVersion) {
let fixedVersion = '';
let fixedVersionCandidate = '';
Expand Down

0 comments on commit a8c561d

Please sign in to comment.