Skip to content

Commit

Permalink
Fix prevent scan on cached failed builds]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Oct 23, 2024
1 parent 09c8662 commit 4473fe8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ class ContainerScanServiceImpl implements ContainerScanService, JobHandler<ScanE
log.debug "Container scan required by scanOnRequest=$request"
scan(fromContainer(request))
}
else if( request.scanId && !request.isContainer() && request.buildNew==false && !request.dryRun && !existsScan(request.scanId) ) {
else if( request.scanId && !request.isContainer() && request.buildNew==false && request.succeeded && !request.dryRun && !existsScan(request.scanId) ) {
log.debug "Container scan required by cached request=$request"
scan(fromContainer(request))
}
else {
log.debug "Container scan NOT required by scanOnRequest=$request"
log.debug "Container scan NOT required by request=$request"
}
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class ContainerScanServiceImplTest extends Specification {
request.buildId >> BUILD_ID
request.buildNew >> BUILD_NEW
request.dryRun >> DRY_RUN
request.succeeded >> SUCCEEDED
and:
def scan = Mock(ScanRequest)

Expand All @@ -412,15 +413,16 @@ class ContainerScanServiceImplTest extends Specification {
RUN_TIMES * scanService.scan(scan) >> null

where:
SCAN_ID | BUILD_ID | BUILD_NEW | DRY_RUN | EXISTS_SCAN | RUN_TIMES
null | null | null | null | false | 0
'sc-123'| null | null | null | false | 0
SCAN_ID | BUILD_ID | BUILD_NEW | SUCCEEDED | DRY_RUN | EXISTS_SCAN | RUN_TIMES
null | null | null | null | null | false | 0
'sc-123'| null | null | null | null | false | 0
and:
'sc-123'| 'bd-123' | null | null | false | 0
'sc-123'| 'bd-123' | true | null | false | 0
'sc-123'| 'bd-123' | false | null | false | 1
'sc-123'| 'bd-123' | false | null | true | 0
'sc-123'| 'bd-123' | false | true | false | 0
'sc-123'| 'bd-123' | null | null | null | false | 0
'sc-123'| 'bd-123' | true | null | null | false | 0
'sc-123'| 'bd-123' | false | true | null | false | 1
'sc-123'| 'bd-123' | false | false | null | false | 0
'sc-123'| 'bd-123' | false | null | null | true | 0
'sc-123'| 'bd-123' | false | null | true | false | 0
}

def 'should store scan entry' () {
Expand Down

0 comments on commit 4473fe8

Please sign in to comment.