Skip to content

Name each patched package as a VEX product so Trivy and Grype match it - #2243

Draft
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
mainfrom
fix/vex-package-products
Draft

Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
mainfrom
fix/vex-package-products

Conversation

@mikolalysenko

Copy link
Copy Markdown
Collaborator

Problem

socket-patch vex names 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

  • Product order. The project product stays first, unchanged. Readers of products[0].subcomponents see the same packages as before.
  • Package products. Each package then follows as a product of its own, with no subcomponents, under these forms:
    • its PURL;
    • its PURL without qualifiers or subpath;
    • for a gem whose platform is not ruby, pkg:gem/<name>@<version>-<platform>, which is how Grype and Syft report it. Trivy reports it with no platform.
  • Mixed statuses. A form is left out when it would stand for packages of one vulnerability with different statuses, such as a patched build and an affected build of one gem. The scanner then keeps reporting that finding.
  • Override. A form equal to the --product override is not repeated.
  • Docs. CLI_CONTRACT.md (Statement products), docs/usage.md (with trivy / grype commands) and the Bazel example in docs/ecosystems.md are updated.

Testing

  • Unit tests cover native gems, platform=ruby, a shared form with mixed statuses, a shared form with all builds patched, and the product override.

  • Updated the conformance tests, e2e_vex, e2e_embedded_vex and the Bazel harness, which compared the whole products array.

  • Ran every vex:: core test plus the vex, e2e_vex* and cli_parse_vex test binaries. All pass.

  • cargo clippy --locked --workspace --all-features -- -D warnings is clean.

  • The release binary was run 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):

    Mode Before After
    Hosted 0 hidden in either scanner 13 hidden in both
    Vendored 0 hidden in either scanner 12 hidden in both

    A native-gem statement with all three forms hides the finding in both scanners.

Before ready

🤖 Generated with Claude Code

`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant