@@ -141,23 +141,29 @@ async function run(): Promise<void> {
141
141
summary . addSnapshotWarnings ( config , snapshot_warnings )
142
142
}
143
143
144
+ let issueFound = false
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
+ issueFound ||= await printVulnerabilitiesBlock (
150
+ vulnerableChanges ,
151
+ minSeverity ,
152
+ warnOnly
153
+ )
148
154
}
149
155
if ( config . license_check ) {
150
156
core . setOutput (
151
157
'invalid-license-changes' ,
152
158
JSON . stringify ( invalidLicenseChanges )
153
159
)
154
160
summary . addLicensesToSummary ( invalidLicenseChanges , config )
155
- printLicensesBlock ( invalidLicenseChanges , warnOnly )
161
+ issueFound ||= await printLicensesBlock ( invalidLicenseChanges , warnOnly )
156
162
}
157
163
if ( config . deny_packages || config . deny_groups ) {
158
164
core . setOutput ( 'denied-changes' , JSON . stringify ( deniedChanges ) )
159
165
summary . addDeniedToSummary ( deniedChanges )
160
- printDeniedDependencies ( deniedChanges , config )
166
+ issueFound ||= await printDeniedDependencies ( deniedChanges , config )
161
167
}
162
168
if ( config . show_openssf_scorecard ) {
163
169
summary . addScorecardToSummary ( scorecard , config )
@@ -182,7 +188,7 @@ async function run(): Promise<void> {
182
188
}
183
189
184
190
// update the PR comment if needed with the right-sized summary
185
- await commentPr ( rendered , config )
191
+ await commentPr ( rendered , config , issueFound )
186
192
} catch ( error ) {
187
193
if ( error instanceof RequestError && error . status === 404 ) {
188
194
core . setFailed (
@@ -208,14 +214,12 @@ function printVulnerabilitiesBlock(
208
214
addedChanges : Changes ,
209
215
minSeverity : Severity ,
210
216
warnOnly : boolean
211
- ) : void {
212
- let vulFound = false
213
- core . group ( 'Vulnerabilities' , async ( ) => {
214
- if ( addedChanges . length > 0 ) {
215
- for ( const change of addedChanges ) {
216
- printChangeVulnerabilities ( change )
217
- }
218
- vulFound = true
217
+ ) : Promise < boolean > {
218
+ return core . group ( 'Vulnerabilities' , async ( ) => {
219
+ let vulFound = false
220
+
221
+ for ( const change of addedChanges ) {
222
+ vulFound ||= printChangeVulnerabilities ( change )
219
223
}
220
224
221
225
if ( vulFound ) {
@@ -230,10 +234,12 @@ function printVulnerabilitiesBlock(
230
234
`Dependency review did not detect any vulnerable packages with severity level "${ minSeverity } " or higher.`
231
235
)
232
236
}
237
+
238
+ return vulFound
233
239
} )
234
240
}
235
241
236
- function printChangeVulnerabilities ( change : Change ) : void {
242
+ function printChangeVulnerabilities ( change : Change ) : boolean {
237
243
for ( const vuln of change . vulnerabilities ) {
238
244
core . info (
239
245
`${ styles . bold . open } ${ change . manifest } » ${ change . name } @${
@@ -244,14 +250,18 @@ function printChangeVulnerabilities(change: Change): void {
244
250
)
245
251
core . info ( ` ↪ ${ vuln . advisory_url } ` )
246
252
}
253
+ return change . vulnerabilities . length > 0
247
254
}
248
255
249
256
function printLicensesBlock (
250
257
invalidLicenseChanges : Record < string , Changes > ,
251
258
warnOnly : boolean
252
- ) : void {
253
- core . group ( 'Licenses' , async ( ) => {
259
+ ) : Promise < boolean > {
260
+ return core . group ( 'Licenses' , async ( ) => {
261
+ let issueFound = false
262
+
254
263
if ( invalidLicenseChanges . forbidden . length > 0 ) {
264
+ issueFound = true
255
265
core . info ( '\nThe following dependencies have incompatible licenses:' )
256
266
printLicensesError ( invalidLicenseChanges . forbidden )
257
267
const msg = 'Dependency review detected incompatible licenses.'
@@ -262,6 +272,7 @@ function printLicensesBlock(
262
272
}
263
273
}
264
274
if ( invalidLicenseChanges . unresolved . length > 0 ) {
275
+ issueFound = true
265
276
core . warning (
266
277
'\nThe validity of the licenses of the dependencies below could not be determined. Ensure that they are valid SPDX licenses:'
267
278
)
@@ -271,6 +282,8 @@ function printLicensesBlock(
271
282
)
272
283
}
273
284
printNullLicenses ( invalidLicenseChanges . unlicensed )
285
+
286
+ return issueFound
274
287
} )
275
288
}
276
289
@@ -373,8 +386,10 @@ function printScannedDependencies(changes: Changes): void {
373
386
function printDeniedDependencies (
374
387
changes : Changes ,
375
388
config : ConfigurationOptions
376
- ) : void {
377
- core . group ( 'Denied' , async ( ) => {
389
+ ) : Promise < boolean > {
390
+ return core . group ( 'Denied' , async ( ) => {
391
+ let issueFound = false
392
+
378
393
for ( const denied of config . deny_packages ) {
379
394
core . info ( `Config: ${ denied } ` )
380
395
}
@@ -383,6 +398,15 @@ function printDeniedDependencies(
383
398
core . info ( `Change: ${ change . name } @${ change . version } is denied` )
384
399
core . info ( `Change: ${ change . package_url } is denied` )
385
400
}
401
+
402
+ if ( changes . length > 0 ) {
403
+ issueFound = true
404
+ core . setFailed ( 'Dependency review detected denied packages.' )
405
+ } else {
406
+ core . info ( 'Dependency review did not detect any denied packages' )
407
+ }
408
+
409
+ return issueFound
386
410
} )
387
411
}
388
412
0 commit comments