Skip to content

Commit f0ff01f

Browse files
committed
null check
1 parent 0dc5711 commit f0ff01f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,24 @@ await this.dockerService.ImageExistsLocallyAsync(refWithDigest, cancellationToke
662662
refWithDigest,
663663
cancellationToken
664664
);
665+
666+
if (baseImageDetails == null)
667+
{
668+
record.BaseImageLayerMessage = "Failed to inspect base image after pull";
669+
this.logger.LogInformation(
670+
"Failed to inspect base image {BaseImage} after pull. Results will not be mapped to base image layers",
671+
refWithDigest
672+
);
673+
return 0;
674+
}
675+
665676
this.logger.LogDebug(
666677
"Base image {BaseImage} resolved for {ContainerImage} with {LayerCount} layers",
667678
refWithDigest,
668679
image,
669680
baseImageDetails.Layers.Count()
670681
);
682+
671683
if (!ValidateBaseImageLayers(scannedImageDetails, baseImageDetails))
672684
{
673685
record.BaseImageLayerMessage =

0 commit comments

Comments
 (0)