@@ -141,25 +141,29 @@ async function run(): Promise<void> {
141
141
summary . addSnapshotWarnings ( config , snapshot_warnings )
142
142
}
143
143
144
- let failureCount = 0 ;
144
+ let issueFound = false
145
145
146
146
if ( config . vulnerability_check ) {
147
147
core . setOutput ( 'vulnerable-changes' , JSON . stringify ( vulnerableChanges ) )
148
148
summary . addChangeVulnerabilitiesToSummary ( vulnerableChanges , minSeverity )
149
- failureCount += printVulnerabilitiesBlock ( vulnerableChanges , minSeverity , warnOnly )
149
+ issueFound ||= printVulnerabilitiesBlock (
150
+ vulnerableChanges ,
151
+ minSeverity ,
152
+ warnOnly
153
+ )
150
154
}
151
155
if ( config . license_check ) {
152
156
core . setOutput (
153
157
'invalid-license-changes' ,
154
158
JSON . stringify ( invalidLicenseChanges )
155
159
)
156
160
summary . addLicensesToSummary ( invalidLicenseChanges , config )
157
- failureCount + = printLicensesBlock ( invalidLicenseChanges , warnOnly )
161
+ issueFound || = printLicensesBlock ( invalidLicenseChanges , warnOnly )
158
162
}
159
163
if ( config . deny_packages || config . deny_groups ) {
160
164
core . setOutput ( 'denied-changes' , JSON . stringify ( deniedChanges ) )
161
165
summary . addDeniedToSummary ( deniedChanges )
162
- failureCount + = printDeniedDependencies ( deniedChanges , config )
166
+ issueFound || = printDeniedDependencies ( deniedChanges , config )
163
167
}
164
168
if ( config . show_openssf_scorecard ) {
165
169
summary . addScorecardToSummary ( scorecard , config )
@@ -184,7 +188,7 @@ async function run(): Promise<void> {
184
188
}
185
189
186
190
// update the PR comment if needed with the right-sized summary
187
- await commentPr ( rendered , config , failureCount )
191
+ await commentPr ( rendered , config , issueFound )
188
192
} catch ( error ) {
189
193
if ( error instanceof RequestError && error . status === 404 ) {
190
194
core . setFailed (
@@ -210,17 +214,14 @@ function printVulnerabilitiesBlock(
210
214
addedChanges : Changes ,
211
215
minSeverity : Severity ,
212
216
warnOnly : boolean
213
- ) : number {
214
- let vulCount = 0
217
+ ) : boolean {
218
+ let vulFound = false
215
219
core . group ( 'Vulnerabilities' , async ( ) => {
216
- if ( addedChanges . length > 0 ) {
217
- for ( const change of addedChanges ) {
218
- printChangeVulnerabilities ( change )
219
- vulCount += change . vulnerabilities . length ;
220
- }
220
+ for ( const change of addedChanges ) {
221
+ vulFound ||= printChangeVulnerabilities ( change )
221
222
}
222
223
223
- if ( vulCount > 0 ) {
224
+ if ( vulFound ) {
224
225
const msg = 'Dependency review detected vulnerable packages.'
225
226
if ( warnOnly ) {
226
227
core . warning ( msg )
@@ -233,10 +234,10 @@ function printVulnerabilitiesBlock(
233
234
)
234
235
}
235
236
} )
236
- return vulCount
237
+ return vulFound
237
238
}
238
239
239
- function printChangeVulnerabilities ( change : Change ) : void {
240
+ function printChangeVulnerabilities ( change : Change ) : boolean {
240
241
for ( const vuln of change . vulnerabilities ) {
241
242
core . info (
242
243
`${ styles . bold . open } ${ change . manifest } » ${ change . name } @${
@@ -247,16 +248,17 @@ function printChangeVulnerabilities(change: Change): void {
247
248
)
248
249
core . info ( ` ↪ ${ vuln . advisory_url } ` )
249
250
}
251
+ return change . vulnerabilities . length > 0
250
252
}
251
253
252
254
function printLicensesBlock (
253
255
invalidLicenseChanges : Record < string , Changes > ,
254
256
warnOnly : boolean
255
- ) : number {
256
- let failureCount = 0 ;
257
+ ) : boolean {
258
+ let issueFound = false
257
259
core . group ( 'Licenses' , async ( ) => {
258
260
if ( invalidLicenseChanges . forbidden . length > 0 ) {
259
- failureCount += invalidLicenseChanges . forbidden . length ;
261
+ issueFound = true
260
262
core . info ( '\nThe following dependencies have incompatible licenses:' )
261
263
printLicensesError ( invalidLicenseChanges . forbidden )
262
264
const msg = 'Dependency review detected incompatible licenses.'
@@ -267,7 +269,7 @@ function printLicensesBlock(
267
269
}
268
270
}
269
271
if ( invalidLicenseChanges . unresolved . length > 0 ) {
270
- failureCount += invalidLicenseChanges . unresolved . length ;
272
+ issueFound = true
271
273
core . warning (
272
274
'\nThe validity of the licenses of the dependencies below could not be determined. Ensure that they are valid SPDX licenses:'
273
275
)
@@ -278,7 +280,7 @@ function printLicensesBlock(
278
280
}
279
281
printNullLicenses ( invalidLicenseChanges . unlicensed )
280
282
} )
281
- return failureCount ;
283
+ return issueFound
282
284
}
283
285
284
286
function printLicensesError ( changes : Changes ) : void {
@@ -380,7 +382,8 @@ function printScannedDependencies(changes: Changes): void {
380
382
function printDeniedDependencies (
381
383
changes : Changes ,
382
384
config : ConfigurationOptions
383
- ) : number {
385
+ ) : boolean {
386
+ let issueFound = false
384
387
core . group ( 'Denied' , async ( ) => {
385
388
for ( const denied of config . deny_packages ) {
386
389
core . info ( `Config: ${ denied } ` )
@@ -392,12 +395,13 @@ function printDeniedDependencies(
392
395
}
393
396
394
397
if ( changes . length > 0 ) {
398
+ issueFound = true
395
399
core . setFailed ( 'Dependency review detected denied packages.' )
396
400
} else {
397
401
core . info ( 'Dependency review did not detect any denied packages' )
398
402
}
399
403
} )
400
- return changes . length
404
+ return issueFound
401
405
}
402
406
403
407
function getScorecardChanges ( changes : Changes ) : Changes {
0 commit comments