Skip to content

Commit

Permalink
Update 'isExcepted' to check for CVE id
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-clark1824 committed Mar 9, 2022
1 parent dfe04e0 commit 3cdbfa6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/types/general.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface v6Advisories {

export interface v6Advisory {
readonly id: string;
readonly cves: string[];
// eslint-disable-next-line camelcase
readonly module_name: string;
readonly title: string;
Expand Down
11 changes: 10 additions & 1 deletion src/utils/vulnerability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ export function processAuditJson(
return Object.values(advisories).reduce(
(acc: ProcessedResult, cur: v6Advisory) => {
const shouldAudit = mapLevelToNumber(cur.severity) >= mapLevelToNumber(auditLevel);
const isExcepted = exceptionIds.includes(Number(cur.id));
let isExcepted: boolean = false;

if (cur.id && exceptionIds.includes(Number(cur.id)) || // NPM v6 contains 'id's to use
(cur.cves && exceptionIds.filter(id => cur.cves.includes(id)).length > 0) || // NPM v6 can also have an array of cve id's
(cur.via && cur.via[0].source && exceptionIds.includes(Number(cur.via[0].source))) || //auditReportVersion: 2. Check via.source for id
(cur.via && cur.via[0].url && exceptionIds.filter(id => cur.via[0].url.contains(id)).length > 0 )) //auditReportVersion: 2. Check via.url for github id
{
isExcepted = true;
}

const isIgnoredModule = modulesToIgnore.includes(cur.module_name);

// Record this vulnerability into the report, and highlight it using yellow color if it's new
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"target": "es5",
"module": "commonjs",
"lib": [
"ES6",
"ES2015"
"ES2018"
],
"outDir": "lib",
"strict": true,
Expand All @@ -19,4 +18,4 @@
"exclude": [
"test",
],
}
}

0 comments on commit 3cdbfa6

Please sign in to comment.