File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
supervisor/watchers/handlers Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -136,9 +136,9 @@ async function scanImagesAndSendResults(
136136 const workloadState = await getWorkloadAlreadyScanned ( workload ) ;
137137 const imageState = await getWorkloadImageAlreadyScanned (
138138 workload ,
139- workload . imageId ,
139+ workload . imageName ,
140140 ) ;
141- if ( workloadState === undefined && imageState === undefined ) {
141+ if ( workloadState === undefined || imageState === undefined ) {
142142 logger . info (
143143 { workloadName } ,
144144 'the workload has been deleted while scanning was in progress, skipping sending scan results' ,
Original file line number Diff line number Diff line change @@ -95,12 +95,19 @@ async function handleReadyPod(workloadMetadata: IWorkload[]): Promise<void> {
9595 for ( const workload of workloadMetadata ) {
9696 const scanned = await getWorkloadImageAlreadyScanned (
9797 workload ,
98- workload . imageId ,
98+ workload . imageName ,
9999 ) ;
100- if ( scanned !== undefined ) {
100+ // ImageID contains the resolved image digest.
101+ // ImageName may contain a tag. The image behind this tag can be mutated and can change over time.
102+ // We need to compare on ImageID which will reliably tell us if the image has changed.
103+ if ( scanned === workload . imageId ) {
101104 continue ;
102105 }
103- await setWorkloadImageAlreadyScanned ( workload , workload . imageId , '' ) ; // empty string takes zero bytes and is !== undefined
106+ await setWorkloadImageAlreadyScanned (
107+ workload ,
108+ workload . imageName ,
109+ workload . imageId ,
110+ ) ;
104111 workloadToScan . push ( workload ) ;
105112 }
106113
You can’t perform that action at this time.
0 commit comments