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