feat: fall back to OCI labels for base image detection when Dockerfile is unavailable#789
Draft
parker-snyk wants to merge 3 commits intomainfrom
Draft
feat: fall back to OCI labels for base image detection when Dockerfile is unavailable#789parker-snyk wants to merge 3 commits intomainfrom
parker-snyk wants to merge 3 commits intomainfrom
Conversation
PR Reviewer Guide 🔍
|
fix: fix snapshots fix: restore snapshots and fix static.spec.ts corruption from containerd-on run The previous LLM session regenerated snapshots with containerd enabled, which produced incorrect/truncated dep graphs. This restores the rpm-transitive-dependencies snapshot to match main (full transitive dep graph), and removes the duplicate OCI label test block that was accidentally injected inside the opensuse test in static.spec.ts, causing a TypeScript parse error.
8fc29ec to
c17f243
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When Snyk scans an image without a Dockerfile (or with a Dockerfile that has no
FROM), the base image has historically been undetectable — causing Snyk to skip base image remediation advice entirely.This PR adds a fallback: after Dockerfile analysis, if
baseImageis still unset,analyzeStaticallychecks the image's OCI standard labels:org.opencontainers.image.base.name(preferred — human-readable tag, e.g.alpine:latest)org.opencontainers.image.base.digest(fallback — content-addressed digest)If either label is present, its value is used as the base image. Dockerfile-derived values always take precedence — this only activates when no base image could be determined from the Dockerfile.
Where should the reviewer start?
lib/static.ts— the fallback logic is a small addition after the existing Dockerfile analysis block.Then
test/lib/static.spec.tsfor the unit tests, andtest/system/static.spec.tsfor the end-to-end system test.How should this be manually tested?
docker load < test/fixtures/docker-archives/docker-save/oci-labels.tardockerfileAnalysis.baseImageis"alpine:latest"in the output.Without this change,
baseImagewould beundefined.Any background context you want to provide?
Many modern third-party images (Chainguard, Bitnami, Red Hat UBI, distroless, official Docker Hub images) include OCI base image labels as part of their build process. The OCI Image Spec defines
org.opencontainers.image.base.nameandorg.opencontainers.image.base.digestspecifically for this purpose.Without this fallback, users auditing pre-built images without access to the original Dockerfile receive no base image remediation advice — even when the image itself carries the necessary metadata.
What are the relevant tickets?
CN-1041
Screenshots
N/A
Additional questions
The snapshot updates in this PR are due to image layer hashes changing as the underlying test images were refreshed from their registries. The logic changes themselves are isolated to
lib/static.ts.