You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(security): mark image rebuilds that fix OS advisories - #76
When a pinned image's digest is replaced, the Count now compares the OS packages in the old and new digests' SBOMs through OSV.dev. If OSV reports an advisory for the old image and not for the new one, the update is marked as a security fix. When the Count can't tell, the PR and the dashboard say so. Revision 3 of the design was approved; this PR builds it and turns the design into an internals page.
Reading SBOMs (crates/datasource/src/images.rs). The Count reads by digest, anonymously:
the BuildKit attestation in the image index;
otherwise a cosign sha256-<digest>.att, whose in-toto subject must match the digest, or .sbom, trying the platform digest before the index digest.
Every manifest and blob is checked against its SHA-256. Docker official images are read from mirror.gcr.io first, with Docker Hub as the fallback. The SBOM blob is reduced once to the generator, the distro and the source packages (sbom-os-v1); file entries are never stored.
Source packages. A binary package that is GENERATED_FROM a Docker Scout source entry is covered by that entry. syft's upstream qualifier names the source. When neither is present, the package is queried under its own name. The kernel source linux is left out. Debian, Ubuntu, Alpine, Wolfi and Chainguard are covered. RPM distributions are reported as os-not-covered in this PR, because their source-RPM versions haven't been measured against OSV yet.
Outcomes. The states are checked, partial-sources, no-os-packages, no-sbom, sbom-without-os, previous-unavailable, os-not-covered and unreadable; the worst platform decides. A fix:
sets fixes;
applies security.apply and security.label;
adds [security] to the commit;
leads the PR with an advisory table (old version, new version or "removed", platforms) for the five most severe fixes, then the rest as linked IDs with a count; what the rebuild "also brings in" is listed the same way.
Only an OSV match can set the security mark. A test pins this with image annotations that claim a security fix.
Which records are read. Which advisories a rebuild leaves behind comes from the IDs in OSV's batch answer. Only a record the Count has read in full, and that isn't withdrawn, marks the rebuild as a security fix. He reads the records for the five most severe advisories each image update fixes and the five most severe it brings in. If every fix he reads turns out to be withdrawn, he reads the next five in rank order, and keeps going until one holds or none are left; if none hold, the rebuild is not a security fix. A withdrawn record takes its ID out of the comparison. The remaining IDs stay in the list and the count, as links "listed by OSV". The PR says that only the rows in its table were read. OSV's batch answer carries no severity, so "most severe" is judged from the ID: a distro's own notice (DSA, DLA, USN and the like) ranks above a per-CVE tracker entry such as DEBIAN-CVE-…, and a newer number ranks above an older one. The full records of these OS advisories rarely carry a severity anyway: none of the records read in the earlier measurement had one. Engine tests cover three cases: one withdrawn record among the five read, the first five all withdrawn with the next one holding, and every fix withdrawn, which gives no label and no fix.
Report, PR and dashboard.
The report gains Update.image and metadata.image, both optional, so the schema version is unchanged.
PR bodies get one callout per kind, with one line per image.
A new dashboard section, "Images the Count can't vouch for", follows Known vulnerabilities.
security.images, security.imagePlatforms and security.quietImages (pattern to required reason) are new config fields. Silenced images still appear on the dashboard, under "Silenced".
HTTP cache and fixtures.
Registry manifests and blobs addressed by digest are kept as immutable, even when a registry sends no-store, as quay.io does.
A registry 404 for a digest or a cosign tag is kept for a day.
The recorder keeps a body byte for byte when its SHA-256 is a digest it was asked for, and the redactor no longer rewrites URLs it has nothing to redact in. Both keep recorded SBOMs digest-valid.
Platforms.security.imagePlatforms defaults to linux/amd64 alone; users add linux/arm64 or others in config. An image with none of the listed platforms (an arm64-only build, say) is compared on the first platform its index lists, skipping attestation entries, on both digests. The engine test for the OSV-only mark now runs on the default config with one amd64 and one arm64-only image, and checks which platform each was compared on.
Cost. Measured on five pinned images (debian:bookworm, ubuntu:24.04 and alpine:3.20 at older digests, node:22.11.0-bookworm-slim, and a quay.io image whose old digest is gone), with a cold cache. The first three rows compared linux/amd64 and linux/arm64, the old default:
First run, check on
Requests
Wall time
Reading every record (before)
522, 521
8.0 s, 9.9 s
Five most severe per side
207, 207
6.2 s, 6.7 s
Re-run on this head, both platforms set in config
207, 207, 208
7.0 s, 7.0 s, 6.4 s
This PR, default linux/amd64 only
165, 165, 165
5.8 s, 5.9 s, 5.4 s
Check off, for reference
76
2.6 s
Warm run, either platform setting
16
1.2 s
Dropping arm64 saves 42 cold requests (its manifest, attestation, SBOM and cosign reads) and about a second. On these five images every count is the same on amd64 alone as on both platforms: debian 71, ubuntu 166/173/205, alpine 29, node 78. OSV has added one Ubuntu advisory since the earlier rows, which read 172/204. The measurement predates the read-on step, which costs more only when all five records read for a rebuild are withdrawn. On the earlier two-platform run, of the 131 cold requests the check added, about 20 are OSV records, at most ten per image update. The rest are 85 digest and cosign reads, 24 redirected blob downloads and one OSV batch, and all but the batch are cached after the first run. Most of the remaining cold time goes on downloading SBOM blobs (an Ubuntu SBOM is 2.4 MB, a Debian one 4.8 MB).
Warm, the extra requests are one OSV batch (about 0.8 s) and three quay.io cosign HEADs. I removed two warm costs before opening this PR: quay's digest manifests were re-read on every run, and missing cosign tags were re-checked on every run. The tests corpus has no pinned images the Count extracts, so its cost is unchanged.
Not in this PR:
An image fix inside a tag update that is held back by its release-age wait doesn't skip that wait.
There is no fallback to the signed package index.
Tooling warnings come in the follow-up PR.
Rebased onto the hard fork (#77): the conformance changes are gone, and the one departure entry, image rebuild advisories, uses the new short format. The compatibility table, the guide pages (security, dashboard, pull-requests), the configuration and report references, and the new internals page are updated.
We reviewed changes in 2b5240b...468f9cd on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
`fn registry_with` has a cyclomatic complexity of 46 with "very-high" risk
A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.
The reason will be displayed to describe this comment to others. Learn more.
`fn read_sbom` has a cyclomatic complexity of 40 with "very-high" risk
A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.
The reason will be displayed to describe this comment to others. Learn more.
Calling `.clone()` for assignment to variable
Consider using .clone_from() instead of assigning the result of .clone().
clone_from() may perform better in some cases because some structs may have custom implementations of clone_from(), which improve performance by avoiding needless allocations.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
Triaged DeepSource's 21 inline findings. All are minor style or antipattern notes: T::default over Default::default(), an empty new(), a .clone() in an assignment, and the cyclomatic complexity of read_sbom and of the existing registry auth path, which this PR only renamed to registry_with. None of them changes behaviour, and per the repo's review rules they don't block, so I'm leaving them as they are.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Calling `.clone()` for assignment to variable
Consider using .clone_from() instead of assigning the result of .clone().
clone_from() may perform better in some cases because some structs may have custom implementations of clone_from(), which improve performance by avoiding needless allocations.
The reason will be displayed to describe this comment to others. Learn more.
`fn image_section` has a cyclomatic complexity of 32 with "very-high" risk
A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Calling `.clone()` for assignment to variable
Consider using .clone_from() instead of assigning the result of .clone().
clone_from() may perform better in some cases because some structs may have custom implementations of clone_from(), which improve performance by avoiding needless allocations.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
When a pinned image's digest is replaced, read the SBOMs of the old and new
digests (BuildKit attestation, or cosign .att/.sbom), ask OSV.dev about the
OS source packages each lists, and mark the update as a security fix only for
an advisory OSV reports for the old image and not the new one. PRs and the
dashboard say when the Count can't tell. Docker official images are read from
mirror.gcr.io first, with Docker Hub as the fallback.
Which advisories a rebuild leaves behind comes from the IDs in OSV's batch
answer, but only a record the Count has read and that isn't withdrawn marks it
a security fix. Records are read for the five most severe advisories each
rebuild fixes and the five most severe it brings in, ranked from the ID since
the batch carries no severity; when every fix read is withdrawn, the next ones
are read in rank order until one holds. The PR lists the rest as links "listed
by OSV", with a count.
Images are compared on linux/amd64 by default; security.imagePlatforms adds
more. An image with none of the listed platforms is compared on the first
platform its index lists.
Digest-addressed registry reads are cached as immutable, and 404s for digests
and cosign tags are kept for a day.
The reason will be displayed to describe this comment to others. Learn more.
`fn read_sbom` has a cyclomatic complexity of 43 with "very-high" risk
A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Calling `.clone()` for assignment to variable
Consider using .clone_from() instead of assigning the result of .clone().
clone_from() may perform better in some cases because some structs may have custom implementations of clone_from(), which improve performance by avoiding needless allocations.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
- Report schema is now 3: v2 shipped, and the new `image` fields would break
strict v2 readers.
- A single-image manifest is matched to the platform its config names, an
image's attestations are all tried, and a cosign tag manifest is read only
by a verified digest.
- Digest-addressed 404s keep their one-day expiry instead of the ten-year
floor, and a read made with a Docker Hub account token follows the
registry's no-store.
- Image rebuilds honour the `active`, `digest` and `permitted` gates of
`security.apply` like a package fix, and an advisory OSV lists for several
source packages is a fix for each.
- Replacements are ranked on their own repository's platforms, batched image
updates keep their SBOM comparison, and introduced advisories show without
fixes.
- `security.imagePlatforms` may not be empty while `images` is on.
- The recorder's redactor leaves unchanged URLs alone however they serialize.
- Dashboard rows name the pinned digest; generator names can't break out of
their code span.
The reason will be displayed to describe this comment to others. Learn more.
`fn read_sbom` has a cyclomatic complexity of 48 with "very-high" risk
A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
The reason will be displayed to describe this comment to others. Learn more.
Prefer using `T::default`, over trait function `Default::default()`
Calls to Default::default() are less readable than T::default().
Using the name of the type makes it easier for the reader to discern which type is being used.
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
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.
When a pinned image's digest is replaced, the Count now compares the OS packages in the old and new digests' SBOMs through OSV.dev. If OSV reports an advisory for the old image and not for the new one, the update is marked as a security fix. When the Count can't tell, the PR and the dashboard say so. Revision 3 of the design was approved; this PR builds it and turns the design into an internals page.
Reading SBOMs (
crates/datasource/src/images.rs). The Count reads by digest, anonymously:sha256-<digest>.att, whose in-toto subject must match the digest, or.sbom, trying the platform digest before the index digest.Every manifest and blob is checked against its SHA-256. Docker official images are read from mirror.gcr.io first, with Docker Hub as the fallback. The SBOM blob is reduced once to the generator, the distro and the source packages (
sbom-os-v1); file entries are never stored.Source packages. A binary package that is GENERATED_FROM a Docker Scout source entry is covered by that entry. syft's
upstreamqualifier names the source. When neither is present, the package is queried under its own name. The kernel sourcelinuxis left out. Debian, Ubuntu, Alpine, Wolfi and Chainguard are covered. RPM distributions are reported asos-not-coveredin this PR, because their source-RPM versions haven't been measured against OSV yet.Outcomes. The states are checked, partial-sources, no-os-packages, no-sbom, sbom-without-os, previous-unavailable, os-not-covered and unreadable; the worst platform decides. A fix:
fixes;security.applyandsecurity.label;[security]to the commit;Only an OSV match can set the security mark. A test pins this with image annotations that claim a security fix.
Which records are read. Which advisories a rebuild leaves behind comes from the IDs in OSV's batch answer. Only a record the Count has read in full, and that isn't withdrawn, marks the rebuild as a security fix. He reads the records for the five most severe advisories each image update fixes and the five most severe it brings in. If every fix he reads turns out to be withdrawn, he reads the next five in rank order, and keeps going until one holds or none are left; if none hold, the rebuild is not a security fix. A withdrawn record takes its ID out of the comparison. The remaining IDs stay in the list and the count, as links "listed by OSV". The PR says that only the rows in its table were read. OSV's batch answer carries no severity, so "most severe" is judged from the ID: a distro's own notice (DSA, DLA, USN and the like) ranks above a per-CVE tracker entry such as
DEBIAN-CVE-…, and a newer number ranks above an older one. The full records of these OS advisories rarely carry a severity anyway: none of the records read in the earlier measurement had one. Engine tests cover three cases: one withdrawn record among the five read, the first five all withdrawn with the next one holding, and every fix withdrawn, which gives no label and no fix.Report, PR and dashboard.
Update.imageandmetadata.image, both optional, so the schema version is unchanged.security.images,security.imagePlatformsandsecurity.quietImages(pattern to required reason) are new config fields. Silenced images still appear on the dashboard, under "Silenced".HTTP cache and fixtures.
no-store, as quay.io does.Platforms.
security.imagePlatformsdefaults tolinux/amd64alone; users addlinux/arm64or others in config. An image with none of the listed platforms (an arm64-only build, say) is compared on the first platform its index lists, skipping attestation entries, on both digests. The engine test for the OSV-only mark now runs on the default config with one amd64 and one arm64-only image, and checks which platform each was compared on.Cost. Measured on five pinned images (
debian:bookworm,ubuntu:24.04andalpine:3.20at older digests,node:22.11.0-bookworm-slim, and a quay.io image whose old digest is gone), with a cold cache. The first three rows comparedlinux/amd64andlinux/arm64, the old default:linux/amd64onlyDropping arm64 saves 42 cold requests (its manifest, attestation, SBOM and cosign reads) and about a second. On these five images every count is the same on amd64 alone as on both platforms: debian 71, ubuntu 166/173/205, alpine 29, node 78. OSV has added one Ubuntu advisory since the earlier rows, which read 172/204. The measurement predates the read-on step, which costs more only when all five records read for a rebuild are withdrawn. On the earlier two-platform run, of the 131 cold requests the check added, about 20 are OSV records, at most ten per image update. The rest are 85 digest and cosign reads, 24 redirected blob downloads and one OSV batch, and all but the batch are cached after the first run. Most of the remaining cold time goes on downloading SBOM blobs (an Ubuntu SBOM is 2.4 MB, a Debian one 4.8 MB).
Warm, the extra requests are one OSV batch (about 0.8 s) and three quay.io cosign HEADs. I removed two warm costs before opening this PR: quay's digest manifests were re-read on every run, and missing cosign tags were re-checked on every run. The tests corpus has no pinned images the Count extracts, so its cost is unchanged.
Not in this PR:
Rebased onto the hard fork (#77): the conformance changes are gone, and the one departure entry, image rebuild advisories, uses the new short format. The compatibility table, the guide pages (security, dashboard, pull-requests), the configuration and report references, and the new internals page are updated.