Skip to content

Commit

Permalink
fix: show vuln note if present
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 22, 2019
1 parent 35e0fbd commit 6891566
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface BasicVulnInfo {
fixedIn: string[];
legalInstructions?: LegalInstruction[];
paths: string[][];
note: string | false;
}

interface TopLevelPackageUpgrade {
Expand Down Expand Up @@ -60,6 +61,7 @@ export function formatIssuesWithRemediation(
type: vuln.metadata.type,
version: vuln.version,
fixedIn: vuln.fixedIn,
note: vuln.note,
legalInstructions: vuln.legalInstructionsArray,
paths: vuln.list.map((v) => v.from),
};
Expand Down Expand Up @@ -166,10 +168,11 @@ function constructLicenseText(
basicLicenseInfo[id].title,
basicLicenseInfo[id].severity,
basicLicenseInfo[id].isNew,
basicLicenseInfo[id].legalInstructions,
`${basicLicenseInfo[id].name}@${basicLicenseInfo[id].version}`,
basicLicenseInfo[id].paths,
testOptions,
basicLicenseInfo[id].note,
basicLicenseInfo[id].legalInstructions,
);
licenseTextArray.push('\n' + licenseText);
}
Expand Down Expand Up @@ -207,10 +210,10 @@ function constructPatchesText(
basicVulnInfo[id].title,
basicVulnInfo[id].severity,
basicVulnInfo[id].isNew,
undefined,
`${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`,
basicVulnInfo[id].paths,
testOptions,
basicVulnInfo[id].note,
);
patchedTextArray.push(patchedText + thisPatchFixes);
}
Expand All @@ -237,10 +240,10 @@ function thisUpgradeFixes(
basicVulnInfo[id].title,
basicVulnInfo[id].severity,
basicVulnInfo[id].isNew,
undefined,
`${basicVulnInfo[id].name}@${basicVulnInfo[id].version}`,
basicVulnInfo[id].paths,
testOptions,
basicVulnInfo[id].note,
),
)
.join('\n');
Expand Down Expand Up @@ -387,10 +390,10 @@ function constructUnfixableText(
issue.title,
issue.severity,
issue.isNew,
undefined,
`${issue.packageName}@${issue.version}`,
issueInfo.paths,
testOptions,
issueInfo.note,
) + `${extraInfo}`,
);
}
Expand All @@ -413,10 +416,11 @@ function formatIssue(
title: string,
severity: SEVERITY,
isNew: boolean,
legalInstructions: LegalInstruction[] | undefined,
vulnerableModule: string,
paths: string[][],
testOptions: TestOptions,
note: string | false,
legalInstructions?: LegalInstruction[],
): string {
const severitiesColourMapping = {
low: {
Expand Down Expand Up @@ -483,7 +487,8 @@ function formatIssue(
? `${chalk.bold(
'\n Legal instructions',
)}:\n ${legalLicenseInstructionsText}`
: '')
: '') +
(note ? `${chalk.bold('\n Note')}:\n ${note}` : '')
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/snyk-test/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface GroupedVuln {
metadata: VulnMetaData;
isIgnored: boolean;
title: string;
note: string;
note: string | false;
severity: SEVERITY;
isNew: boolean;
name: string;
Expand Down Expand Up @@ -95,7 +95,7 @@ interface AnnotatedIssue extends IssueData {
type?: 'license';
title: string;
patch?: any;
note?: any;
note?: string | false;
publicationTime?: string;
}

Expand Down

0 comments on commit 6891566

Please sign in to comment.