Skip to content

Commit

Permalink
feat: remove misleading docker layers count breakdown
Browse files Browse the repository at this point in the history
  • Loading branch information
karniwl committed Feb 13, 2019
1 parent 4698eaa commit a25d205
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ function displayResult(res, options) {
);
}

if (options.docker && options.file && options['exclude-base-image-vulns'] && res.vulnerabilities) {
res.uniqueCount = countExcludeBaseImageVulns(options, res);
}

// NOT OK => We found some vulns, let's format the vulns info
const vulnCount = res.vulnerabilities && res.vulnerabilities.length;
const singleVulnText = res.licensesPolicy ? 'issue' : 'vulnerability';
Expand All @@ -249,8 +253,6 @@ function displayResult(res, options) {
}
let summary = testedInfoText + ', ' + chalk.red.bold(vulnCountText);

summary += getDockerLayersVulnCount(options, res);

if (WIZARD_SUPPORTED_PMS.indexOf(packageManager) > -1) {
summary += chalk.bold.green('\n\nRun `snyk wizard` to address these issues.');
}
Expand Down Expand Up @@ -637,10 +639,7 @@ function metadataForVuln(vuln) {
};
}

function getDockerLayersVulnCount(options, res): string {
if (!options.docker || !options.file || !res.vulnerabilities) {
return '';
}
function countExcludeBaseImageVulns(options, res): number {
const nonBaseImageVulns = res.vulnerabilities.filter((vuln) => (vuln.dockerfileInstruction));
if (options['exclude-base-image-vulns']) {
res.vulnerabilities = nonBaseImageVulns;
Expand All @@ -654,8 +653,5 @@ function getDockerLayersVulnCount(options, res): string {
}
return acc;
}, 0);
const layersVulnsCount = '\nVulnerabilities introduced by your base image: ' +
chalk.bold.red(`${res.uniqueCount - userUniqueCount}.`) +
'\nVulnerabilities introduced by other layers: ' + chalk.bold.red(`${userUniqueCount}.`);
return layersVulnsCount;
return userUniqueCount;
}

0 comments on commit a25d205

Please sign in to comment.