revise ghsa filter
This commit is contained in:
+11
-12
@@ -51,27 +51,26 @@ export function filterOutAllowedAdvisories(
|
|||||||
ghsas: string[],
|
ghsas: string[],
|
||||||
changes: Changes
|
changes: Changes
|
||||||
): Changes {
|
): Changes {
|
||||||
let filteredChanges = []
|
const filteredChanges = changes.filter(change => {
|
||||||
for (const change of changes) {
|
const noAdvisories =
|
||||||
if (
|
|
||||||
change.vulnerabilities === undefined ||
|
change.vulnerabilities === undefined ||
|
||||||
change.vulnerabilities.length === 0
|
change.vulnerabilities.length === 0
|
||||||
) {
|
|
||||||
filteredChanges.push(change)
|
if (noAdvisories) {
|
||||||
continue
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
let allVulnsAllowed = true
|
let allAllowedAdvisories = true
|
||||||
|
// if there's at least one advisory that is not allowlisted, we will keep the change
|
||||||
for (const vulnerability of change.vulnerabilities) {
|
for (const vulnerability of change.vulnerabilities) {
|
||||||
if (!ghsas.includes(vulnerability.advisory_ghsa_id)) {
|
if (!ghsas.includes(vulnerability.advisory_ghsa_id)) {
|
||||||
allVulnsAllowed = false
|
allAllowedAdvisories = false
|
||||||
}
|
}
|
||||||
}
|
if (!allAllowedAdvisories) {
|
||||||
|
return true
|
||||||
if (allVulnsAllowed === false) {
|
|
||||||
filteredChanges.push(change)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return filteredChanges
|
return filteredChanges
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user