File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 11import { Changes , Severity , SEVERITIES , Scope } from './schemas'
22
3+ /**
4+ * Filters changes by a severity level. Only vulnerable
5+ * dependencies will be returned.
6+ *
7+ * @param severity - The severity level to filter by.
8+ * @param changes - The array of changes to filter.
9+ * @returns The filtered array of changes that match the specified severity level and have vulnerabilities.
10+ */
311export function filterChangesBySeverity (
412 severity : Severity ,
513 changes : Changes
@@ -31,7 +39,14 @@ export function filterChangesBySeverity(
3139 filteredChanges = filteredChanges . filter (
3240 change => change . vulnerabilities . length > 0
3341 )
34- return filteredChanges
42+
43+ // only report vulnerability additions
44+ return filteredChanges . filter (
45+ change =>
46+ change . change_type === 'added' &&
47+ change . vulnerabilities !== undefined &&
48+ change . vulnerabilities . length > 0
49+ )
3550}
3651
3752export function filterChangesByScopes (
Original file line number Diff line number Diff line change @@ -80,21 +80,17 @@ async function run(): Promise<void> {
8080 return
8181 }
8282
83- const minSeverity = config . fail_on_severity
8483 const scopedChanges = filterChangesByScopes ( config . fail_on_scopes , changes )
84+
8585 const filteredChanges = filterAllowedAdvisories (
8686 config . allow_ghsas ,
8787 scopedChanges
8888 )
8989
90+ const minSeverity = config . fail_on_severity
9091 const vulnerableChanges = filterChangesBySeverity (
9192 minSeverity ,
9293 filteredChanges
93- ) . filter (
94- change =>
95- change . change_type === 'added' &&
96- change . vulnerabilities !== undefined &&
97- change . vulnerabilities . length > 0
9894 )
9995
10096 const invalidLicenseChanges = await getInvalidLicenseChanges (
You can’t perform that action at this time.
0 commit comments