Description
At the moment, when we inspect the image config, the OS information can be incorrect and/or incomplete.
Since we obtain OS information only from the scanned layers, the following cases are possible:
Information is missed because the layer is already cached
If information is updated in different layers, the result is non-deterministic
Current Implementation
The current logic in pkg/fanal/artifact/image/image.go:
p := parallel.NewPipeline(a.artifactOption.Parallel, false, layerKeys, func(ctx context.Context,
layerKey string) (any, error) {
// ... inspection logic
return layerInfo.OS, nil
}, func(res any) error {
// Merge OS info in onResult (main goroutine)
osInfo := res.(types.OS)
osFound.Merge(osInfo)
return nil
})
This approach works well for layers being inspected, but doesn't account for layers loaded from cache.
Expected Behavior
OS information should be merged deterministically in layer order, regardless of whether layers come from cache or fresh inspection.