Repository navigation
Add vex --grype-config to list the VEX document in Grype's config - #2252
Conversation
`socket-patch vex --output socket.vex.json --grype-config [path]` keeps
the Grype config's `vex-documents` list naming the document, so a plain
`grype dir:.` reads it without `--vex`. `.grype.yaml` is the default.
- A missing config is created; an existing one gains one list item and
keeps every other byte (CRLF and a missing final newline included).
- Grype fails a whole scan when a listed document is missing, so a run
that leaves no document at `--output` takes the entry out again.
- Grype refuses a key named twice, and a config the editor cannot read
with certainty (a flow list, another spelling of the key, nested
content, several documents) is left as it is, with a
`grype_config_not_updated` warning naming the line to add. The VEX
document and the exit status stay the run's own.
- The entry is relative to the config's directory, which is where
Grype resolves it when run there.
- `--json` reports `grypeConfig: { path, entry, change }`; `--dry-run`
writes nothing and says what it would do.
Checked with Grype 0.122.1 on an npm project with hosted patches: the
config line alone hides the same 13 patched findings as `--vex`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Read a file mixing CRLF and LF line by line, so a key on an LF line is found instead of appended a second time (Grype refuses a key named twice). Each line keeps its own ending, and a missing final newline stays missing. - Treat `./socket.vex.json`, `out/../socket.vex.json` and `\` separators as the same entry when adding and when removing. - Refuse a config or document path with `..`, which a symlinked directory could send elsewhere. - Check the document shape (one block mapping) before every edit, not only when the key is missing. - Honour a quote only where it opens an item, as YAML does. - After a failed run, warn when the config cannot be read or checked, without claiming it lists the entry, and report the change in the error envelope's `grypeConfig`. - Read `SOCKET_VEX_GRYPE_CONFIG=1/true/yes` as `.grype.yaml` and `0/false/no` as off, like the other SOCKET_VEX_* switches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR SummaryLow Risk Overview On a successful write, the CLI creates or surgically edits the config to add a relative path entry while preserving existing YAML shape and line endings; if the file is already listed (any spelling), it leaves it alone. On runs that end with no document at The YAML logic lives in Reviewed by Cursor Bugbot for commit de22dae. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit de22dae. Configure here.
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the YAML line editor, the refused shapes and the removal on a failed run. One nit inline. The open Bugbot thread on same_path is real and worth fixing before or soon after merge; the compact-key thread is not a bug, since vex-documents:[] with no space is a plain scalar, not a key.
… a dry run - `same_path` popped on every `..`, so `../socket.vex.json` folded to `socket.vex.json`: add reported the parent's entry as `listed` and remove could drop it. A `..` with nothing to climb out of now stays. - A dry run leaves a stale OpenVEX document in place, so the config step saw it and never previewed `would_remove`, although the real run removes both. It now asks whether the real run would remove the document (`is_openvex_doc`, split out of `remove_stale_vex_doc`). Assisted-by: Claude Code:claude-opus-5-5
6281359 made vex_grype call vex::is_openvex_doc, a cycle that command_module_layering refuses. vex.rs now asks is_openvex_doc itself and passes the answer to unlist_missing_document as `stale_doc_kept`, which skips the "a file is still at --output" early return. Behavior is unchanged: a dry run still previews would_remove for a stale OpenVEX document the real run would delete. Assisted-by: Claude Code:claude-opus-5-5

What
socket-patch vex --output socket.vex.json --grype-config [path]keeps the Grype config'svex-documentslist naming the document, so a plaingrype dir:.reads it without--vex. The default path is.grype.yaml.This is a stopgap on the CLI side. Longer term, the scanner integrations should be driven by Socket's backend.
Behaviour
Create or merge. A missing config is created as
vex-documents:with one item. An existing config gains one list item and keeps every other byte:Already listed. An entry listed in any spelling (
./socket.vex.json,out/../socket.vex.json,\separators) leaves the file unchanged.Removal. Grype fails a whole scan when a listed document is missing. A failed run that leaves no document at
--outputtherefore takes every spelling of the entry out again.Refused shapes. Grype refuses a key named twice. A config the editor cannot read with certainty is left as it is, with a
grype_config_not_updatedwarning naming the line to add. The VEX document and the exit status stay the run's own. Refused shapes are:A config or document path containing
..is not listed either, because a symlinked directory could send it elsewhere.Entry. The entry is relative to the config's directory, which is where Grype resolves it when run there.
Output.
--jsonreportsgrypeConfig: { path, entry, change }, and so does the error envelope when a failed run touched the config.--dry-runwrites nothing and says what it would do. A human run prints one line when the config changes.Usage error.
--grype-configwithout--outputis a usage error (grype_config_requires_output, exit 2).Env var.
SOCKET_VEX_GRYPE_CONFIGtakes a path. Like the otherSOCKET_VEX_*switches,1,trueandyesmean.grype.yaml, and0,falseandnomean off.Docs. Documented under "Grype config" in
CLI_CONTRACT.mdand indocs/usage.md.Grype behaviour this rests on
Checked with Grype 0.122.1:
vex-documents: [socket.vex.json], no--vex--vexVEX document "socket.vex.json" not found, exit 1.grype.yamlnext to an existing.grype/config.yaml-cfrom another directoryvex-documentsnamed twicemapping key "vex-documents" already definedvex-documents:with no itemsEnd to end, the release binary on an npm project with hosted patches added the entry to a team config holding
fail-on-severity: critical. Plaingrype dir:.then hid 13 findings and exited 0, because the only critical finding was a patched one.Testing
e2e_vex_grype_config:--dry-run;--grype-configwithout--output;SOCKET_VEX_GRYPE_CONFIGis added to both lists of variables cleared from child processes.e2e_vendor_cargo_build's two old-toolchain tests. Those fail on this machine with "Bad CPU type in executable", unrelated to this change; CI runs them.cargo clippy --locked --workspace --all-features -- -D warningsis clean./code-review high: 3 important and 7 minor findings, all fixed in the second commit.For the owner
--grype-config [<path>], and its env varSOCKET_VEX_GRYPE_CONFIG.vexcommand has the flag for now.scan,applyandvendor(--vex-grype-config) can follow.🤖 Generated with Claude Code
Generated by Claude Code