Skip to content

Commit

Permalink
Merge pull request #719 from snyk/feat/fixed-in-info
Browse files Browse the repository at this point in the history
feat: fixed in info on vulns
  • Loading branch information
lili2311 committed Aug 8, 2019
2 parents 9a95a78 + b28d01a commit 64e248e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/cli/commands/test/formatters/legacy-format-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ function createTruncatedVulnsPathsText(vulnList) {
}

function createFixedInText(vuln: any): string {
return vuln.nearestFixedInVersion ?
chalk.bold('\n Fixed in: ' + vuln.nearestFixedInVersion )
: '';
if (vuln.nearestFixedInVersion) {
return chalk.bold('\n Fixed in: ' + vuln.nearestFixedInVersion);
} else if (vuln.fixedIn && vuln.fixedIn.length > 0) {
return chalk.bold('\n Fixed in: ' + vuln.fixedIn.join(', '));
}

return '';
}

function createRemediationText(vuln, packageManager) {
Expand Down Expand Up @@ -168,5 +172,9 @@ function createRemediationText(vuln, packageManager) {
return chalk.bold(`\n Remediation: \n ${upgradePathsArray.join('\n ')}`);
}

if (vuln.fixedIn && vuln.fixedIn.length > 0) {
return createFixedInText(vuln);
}

return '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ function constructUnfixableText(unresolved: IssueData[]) {
if (!(unresolved.length > 0)) {
return [];
}
const unfixableIssuesTextArray = [chalk.bold.white('\nIssues that cannot be fixed:')];
const unfixableIssuesTextArray = [chalk.bold.white('\nIssues with no direct upgrade or patch:')];
for (const issue of unresolved) {
const packageNameAtVersion = chalk.bold.whiteBright(`\n ${issue.packageName}@${issue.version} \n`);
const extraInfo = issue.fixedIn
? `\n This issue was fixed in versions: ${issue.fixedIn.join(', ')}`
: '\n No upgrade or patch available';
const packageNameAtVersion = chalk.bold.whiteBright(`\n ${issue.packageName}@${issue.version}\n`);
unfixableIssuesTextArray
.push(packageNameAtVersion + formatIssue(issue.id, issue.title, issue.severity, issue.isNew));
.push(packageNameAtVersion + formatIssue(issue.id, issue.title, issue.severity, issue.isNew) + `${extraInfo}`);
}

return unfixableIssuesTextArray;
Expand All @@ -140,9 +143,10 @@ function formatIssue(id: string, title: string, severity: SEVERITY, isNew: boole
},
};
const newBadge = isNew ? ' (new)' : '';

return severitiesColourMapping[severity].colorFunc(
` ✗ ${chalk.bold(title)}${newBadge} [${titleCaseText(severity)} Severity]`,
) + `[${id}] `;
) + `[${id}]`;
}

function titleCaseText(text) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/snyk-test/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface IssueData {
description: string;
title: string;
severity: SEVERITY;
fixedIn: string[];
}

interface AnnotatedIssue extends IssueData {
Expand Down

0 comments on commit 64e248e

Please sign in to comment.