create a filter for vulns that are on the allowlist

This commit is contained in:
Sarah Aladetan
2022-09-22 21:36:26 +00:00
parent bd61ea0d9e
commit 602f968ea2
2 changed files with 73 additions and 1 deletions
+29
View File
@@ -46,3 +46,32 @@ export function filterChangesByScopes(
return filteredChanges
}
export function filterOutAllowedAdvisories(
ghsas: string[],
changes: Changes
): Changes {
let filteredChanges = []
for (const change of changes) {
if (
change.vulnerabilities === undefined ||
change.vulnerabilities.length === 0
) {
filteredChanges.push(change)
continue
}
let allVulnsAllowed = true
for (const vulnerability of change.vulnerabilities) {
if (!ghsas.includes(vulnerability.advisory_ghsa_id)) {
allVulnsAllowed = false
}
}
if (allVulnsAllowed === false) {
filteredChanges.push(change)
}
}
return filteredChanges
}