File tree 2 files changed +18
-7
lines changed
2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { Changes , Severity , SEVERITIES , Scope } from './schemas'
2
2
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
+ */
3
11
export function filterChangesBySeverity (
4
12
severity : Severity ,
5
13
changes : Changes
@@ -31,7 +39,14 @@ export function filterChangesBySeverity(
31
39
filteredChanges = filteredChanges . filter (
32
40
change => change . vulnerabilities . length > 0
33
41
)
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
+ )
35
50
}
36
51
37
52
export function filterChangesByScopes (
Original file line number Diff line number Diff line change @@ -80,21 +80,17 @@ async function run(): Promise<void> {
80
80
return
81
81
}
82
82
83
- const minSeverity = config . fail_on_severity
84
83
const scopedChanges = filterChangesByScopes ( config . fail_on_scopes , changes )
84
+
85
85
const filteredChanges = filterAllowedAdvisories (
86
86
config . allow_ghsas ,
87
87
scopedChanges
88
88
)
89
89
90
+ const minSeverity = config . fail_on_severity
90
91
const vulnerableChanges = filterChangesBySeverity (
91
92
minSeverity ,
92
93
filteredChanges
93
- ) . filter (
94
- change =>
95
- change . change_type === 'added' &&
96
- change . vulnerabilities !== undefined &&
97
- change . vulnerabilities . length > 0
98
94
)
99
95
100
96
const invalidLicenseChanges = await getInvalidLicenseChanges (
You can’t perform that action at this time.
0 commit comments