Repository navigation
Name each patched package as a VEX product so Trivy and Grype match it - #2243
Conversation
`socket-patch vex` named only the project as each statement's product, with the patched packages as subcomponents. Trivy and Grype look a finding up by the package's own PURL, so the document suppressed nothing in either scanner. Each statement now keeps the project product first, unchanged, and names every package again as a product of its own: by its PURL, without qualifiers, and for a gem built for a platform other than `ruby` as `name@version-platform`, which is how Grype and Syft report it. A form that would stand for packages of one vulnerability with different statuses (a patched and an `affected` build of one gem) is left out, so the scanner keeps reporting the finding. Checked with Trivy 0.76.2 and Grype 0.122.1 on an npm project with 10 patched packages: the document now hides 13 patched findings in hosted mode and 12 in vendored mode in both scanners, where it hid none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…irect shapes test Package products carry no subcomponents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fe206e6 to
becb631
Compare
From review: - Stripping qualifiers from a Maven classifier, a PyPI file or an npm vcs_url PURL could cover an artifact that was never patched, so only a gem's platform gets extra forms. - A patch record the document leaves out (its check failed) now counts as an unpatched copy when deciding whether a shared form is safe. - The check covers the vulnerability's aliases too, since scanners match statements by any of them. - The platform is percent-decoded before it goes into name@version-platform. The contract and usage docs say a package's own PURL can be left out for the same reason, and that the document is only for the project it was made for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR SummaryMedium Risk Overview For platform gems, the builder also emits scanner-specific PURL forms (Trivy Docs add Statement products in Reviewed by Cursor Bugbot for commit 58b95ea. Configure here. |
The tests from #2224 compare whole statements, which now name each package as a product of its own after the project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main gained "Name each patched package as a VEX product so Trivy and Grype match it" (#2243). No file has a conflict. That change is to the VEX document and to the test harness that reads one, which the NuGet flows of this branch go through where they hold `vex` to a vendored package. They pass on the merged tree: `nuget::vendored_mode_keeps_the_block_or_declines` finds the vendored package as a product of its own in the document, beside the project. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Problem
socket-patch vexnames only the project as each statement's product, with the patched packages as subcomponents. Trivy and Grype look a finding up by the package's own PURL, so the document suppresses nothing in either scanner.Change
products[0].subcomponentssee every package as before.platformqualifier is also named the way each scanner reports it:pkg:gem/<name>@<version>(Trivy);pkg:gem/<name>@<version>-<platform>(Grype, Syft), unless the platform isruby. The platform is percent-decoded first.not_affectedand another isaffected, or has a patch record the document leaves out, such as a failed check. This applies to a package's own PURL too. A form equal to the--productoverride is not repeated.CLI_CONTRACT.md(Statement products),docs/usage.md(addstrivy/grypecommands) and the Bazel example indocs/ecosystems.md.Review findings not fixed as suggested
pkg:gem/x@1.0and anaffectedpkg:gem/x@1.0?platform=x86_64-linuxshare a form, Trivy reports both aspkg:gem/x@1.0. Naming that formnot_affectedwould hide the unpatched build's CVE. Leaving it out keeps the finding visible, which is the safe direction. The contract text says so.Testing
Unit tests for:
platform=rubyand a percent-encoded platform;--productoverride.Updated tests: the conformance tests,
e2e_vex,e2e_embedded_vex, the Bazel harness, which compared the wholeproductsarray, and the Cargo redirect shapes test, which read subcomponents from every product.Suites run:
socket-patch-corelib (8556 passed) and every CLI test binary that reads VEX products (apply,vex,e2e_vex*,e2e_embedded_vex,e2e_hosted_production,e2e_gem_native_ext_build,e2e_redirect_cargo_shapes, the vlt suites,mode_migration_*). All pass.Lint:
cargo clippy --locked --workspace --all-features -- -D warningsis clean.Real scanners: ran the release binary on an npm project with 10 hosted patches and on the same project vendored, then scanned with Trivy 0.76.2 (
fs --vex) and Grype 0.122.1 (dir: --vex):A native-gem statement with both gem forms hides its finding in both scanners.
/code-review high: run on the first version of this PR. Its findings are fixed or answered above.🤖 Generated with Claude Code