Repository navigation
Assert the VEX document in the Bazel flows that build patched - #2139
Conversation
`scan --mode vendored` and agent mode (`scan --mode agent`, `apply`) patch a Go module by keeping a patched copy of it in the checkout, under `.socket/vendor/golang` or `.socket/go-patches`, and pointing `go.mod` at it with a directory `replace`. Only the hosted flow had a test on a real Bazel. This adds the two other modes for the same gazelle `go_deps` workspace, on Bazel 9.3.2, 8.8.2 and 7.7.2, and records what the code does there today. The next build is patched in both modes, and the undo is clean (`vendor --revert`) or leaves only the emptied `.socket/manifest.json` (`rollback`). The user's next step breaks the build: - `bazel run //:gazelle` writes a BUILD.bazel into the copy. gazelle's `go_deps` copies the directory with that file, and every target that uses the module fails to load: `No repository visible as '@rules_go'`. - When the module ships a BUILD file of its own, `bazel build //...` fails right after the command: the copy is a package of the checkout whose load of `@io_bazel_rules_go` nothing maps. Each test asserts that break by its error, so that the commit that fixes it has to change the expectation. The fixture gains a `gazelle` target, and its BUILD file is now the one gazelle writes, so a gazelle run on the unpatched checkout changes nothing and what a later run writes comes from the patch. Agent mode copies the module from the user's module cache; the test lays that directory out itself, so the runner needs no Go toolchain beyond the one rules_go downloads. gazelle is built from Go modules of its own: a flow that runs it has proxy.golang.org last in its GOPROXY list, after the stand-in that serves the module under test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Vendored and agent mode patch a Go module by keeping a copy of it under the project's `.socket` directory and pointing `go.mod` at it with a directory `replace`. In a Bazel workspace that copy is a directory Bazel and gazelle walk like any other. The next build is patched, and then the user's ordinary steps break it, on Bazel 9.3.2, 8.8.2 and 7.7.2 with gazelle's `go_deps`: - `bazel run //:gazelle` writes a BUILD.bazel into the copy, `go_deps` copies the directory with it, and every target that uses the module fails to load (`No repository visible as '@rules_go'`); - when the module ships a BUILD file of its own, `bazel build //...` fails right after the command. One line in the `.bazelignore` at the root of the workspace prevents both, and socket-patch now writes it. This is the first Bazel file socket-patch writes. Where it applies A project is in a Bazel workspace when its directory, or one above it up to the root of its git checkout, holds a regular file `MODULE.bazel`, `REPO.bazel`, `WORKSPACE` or `WORKSPACE.bazel`. Those are the names Bazel's client looks for from the working directory up (`WorkspaceLayout::InWorkspace`, src/main/cpp/workspace_layout.cc line 36 at the tags 7.7.2, 8.8.2 and 9.3.2). The nearest such directory is the Bazel root; a directory of that name does not count. Without such a file nothing is read or written, and the run writes the same files as before, byte for byte. The checkout is the one `repo_root::find_git_repo` finds, and it counts only when its `.git` belongs to a trusted owner (`GitRepo::trusted`: the user, root, or the user sudo ran for; a root process trusts any), which is the rule the `socket.yml` lookup has for the repository root. Without it, another user's `/tmp/.git` and `/tmp/MODULE.bazel` on a shared machine would make a command in `/tmp/job/proj` create `/tmp/.bazelignore`. A project in no such checkout (a Docker build context, an unpacked source archive, a checkout of another user) is looked for in its own directory only: nothing above it is read, so a workspace file there gives no line and no warning. Neither does a Bazel root above the root of the checkout (a git submodule, several checkouts below one workspace): this repository reads no project file outside the checkout, so a look there could see the workspace file and not whether the line is in place, and its warning would never end. The nearest directory with a workspace file is the root. In a workspace that is nested in a larger one the line is therefore in the inner file, which a run from the outer workspace does not read. Measured on Bazel 9.3.2 with gazelle 0.54.0, outside the committed tests: from the outer root `bazel build //...` loads the packages of the inner tree, a BUILD file in the copy among them, and `bazel run //:gazelle` writes a BUILD.bazel into the copy, after which the inner build fails as above; with the line in the outer file, by its path from the outer root, neither happens. The writes are not widened for that. The docs name these limits and the line to add by hand. What is written - While `<project>/.socket/vendor/golang` or `<project>/.socket/go-patches` exists, the root's `.bazelignore` names it by its path from the root, on a line of its own under the comment line `# socket-patch: patched Go module copies, not Bazel packages (to opt out, comment out the next line)`. The pair is added at the end of the file, in the file's line breaks, and the file is created when missing. Never `.socket` alone: other things live there. - Nothing is added when a line already covers the directory: the path or a directory above it, with or without a trailing `/` or a leading `./`. Bazel reads a line literally, so a line with a blank before or after it, a pattern or a string prefix covers nothing. - Nothing is added either when the user declined the pair: the comment line with the path line commented out under it (`#`, blanks, the path, which may end in one `/` or start with `./` as in a line that covers). No command adds a line for that directory, warns about it or touches the two lines again, on removal either. Deleting the pair is no opt-out: the next command writes it back. Neither is commenting out both lines, or a path line changed in another way. - socket-patch knows its pair by the start of the comment line, `# socket-patch:`, not by the whole sentence: a path line under a line that starts so is its own, and that path line commented out is the opt-out. A later release can reword the comment without leaving the pairs of this one behind. - Only a directory that is not found is gone. One that cannot be probed (a directory above it that may not be searched, a transient error) keeps its pair, and gets none. - Once the directory is gone the pair is removed, and the file is the one of before, byte for byte. A file whose last line has no line break gets a line break and the pair without a final one, and loses that line break again with the pair: exactly the one the comment line ends in, which is the one that was written before it, so that a last byte that is a carriage return on its own stays. Bazel and gazelle honour a last line without a line break: the agent test on real Bazel has one. A file left empty is deleted, an empty one the user had included: it cannot be told from one socket-patch created. Only a line under such a comment line is ever removed. - The line follows the directory, not the `replace`: `rollback --preserve-state` drops the `replace` and keeps the vendored copy, whose BUILD files would be back in the workspace without the line. - A read-only file is neither replaced nor deleted. The file is opened for appending before any change, a removal included, because a rename or an unlink succeeds in a writable directory. - A file that is not updated is the new warning `bazelignore_not_updated`: it could not be read or written (a directory or a symbolic link in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted. The command succeeds as before. - A human run reads `Updated <path>` or `Removed <path>` on stdout when the file changed, once for each file, in words that hold for lines that came and for lines that went, and the warning on stderr. Under `--json` the warning is a run-level `warnings[]` entry; there is no new field. Which commands `commands::sync_bazelignore` is the one place the CLI asks for the file, behind one gate: not in a dry run and not in a `--global` run. Each command that can write or remove a copy calls it once, after its last step that can change a copy or take one back: `apply` (and with it `scan --mode agent` and `get`), the vendored step of `scan` and `get`, `vendor`, `vendor --revert`, `rollback`, `remove`, `repair` (also when it failed), and a hosted scan that took the lock, since a takeover removes the vendored copy. A hosted scan that took no lock may write nothing (`patches.enabled: false` in `socket.yml`, a rollout cap, no granted reference) and leaves this file alone too. The eject of a hosted project calls it after its rollback, so that an eject which vendored the Go module and was then rolled back leaves no pair for a copy that is gone again. `apply` and `vendor` in a project with no manifest end before that step. A run whose `--ecosystems` leaves `golang` out adds no line. It still takes away the pair of a copy that is gone, because `remove` of a Go patch and `vendor --revert` remove the Go copy whatever that option says. With a `--manifest-path` into another project the agent copies are those of `--cwd` and the vendored ones those of the manifest's project, so the helper brings the file of each project's Bazel root in line. `scan --prune` comes to the file a second time, after a pass that reverted a vendored entry or swept an orphan directory, which can remove the last copy after the scan's own step. That second call only takes a pair away: it adds no line and gives no warning, so the run warns once and no state is kept between the two. What it costs: a warning the scan's own step gave for a copy the pass then removed is out of date, and a file the pass cannot write is reported by the next command. The scan's own call cannot be left to that pass instead: the pass also follows the nested apply of `scan --mode agent --prune`, and it does not run at all when it cannot take the apply lock. The file is written after the commands' group commits, outside them: it is no part of a commit journal. A run that dies in between leaves a copy without its line, which the next command adds; a command that fails after it removed a copy can leave the pair behind, which ignores nothing, until the next command. A file several projects share Two projects under one Bazel root share the file, and each command holds only its own project's apply lock. So the edit, from its read to its write, is made under an advisory lock on the root directory itself: `fs2` on a handle to the directory, with contention told as the apply lock tells it (`apply_lock::is_lock_contended`). No lock file is made, in the workspace or anywhere else. A run that finds nothing to change takes no lock, also when the file cannot be read and the project has no copy to name in it. Where the directory cannot be locked (Windows, where it cannot be opened this way; a file system without such locks), or the lock stays held for a second, the edit is made without it: an add is still one appending write, which keeps what another project adds at that moment, and a removal replaces the file and can then lose such a pair until the next command in that project. With the lock, a removal in one project against an add in its sibling keeps the added pair in every one of 25 rounds of a unit test, which asserts that half on Unix only; without the lock that test fails. What a run costs The Bazel root and the bound of the checkout come from one walk up (`search_dirs`), which runs with the rest of the edit on the blocking pool. For a project outside a Bazel workspace, `d` directories below the root of its checkout, that is 2 path canonicalisations, `d + 2` stats of `.git` and `4 (d + 1)` stats of the four names, and nothing else. In a Bazel workspace it adds two stats of the copy directories and one read of `.bazelignore`; the lock and the write come only when something changes. (Counted from the code, not traced.) A side effect The line does more than keep gazelle out. Bazel leaves an ignored directory out of every `glob()` of a package above it (9.3.2, 8.8.2 and 7.7.2), so a target that hands the project's Go files to a `go` command of its own through such a glob no longer receives the copies. Built on Bazel 9.3.2 with a genrule that runs the Go SDK's `go build` over `glob(["**/*.go", "**/go.mod", "**/go.sum"])`, outside the committed tests: without the line it builds patched until the first `bazel run //:gazelle`, whose BUILD file in the copy takes the copy out of the glob in the same way, and then fails (`replacement directory ./.socket/vendor/golang/... does not exist`) together with every rules_go target that uses the module. With the line the rules_go targets build, and that genrule fails with the same error from the start; it builds when it names the copy's files as labels beside the glob, or runs outside the sandbox. A workspace that has such a target and never runs gazelle can decline the line as above. Not covered Only Go module copies get a line. Other ecosystems keep unpacked packages under `.socket/vendor/<ecosystem>` too (a crate can ship a BUILD.bazel); nothing was measured for them under Bazel, so nothing is written for them. A BUILD file that gazelle wrote into a copy before the line existed stays there: the next `scan --mode vendored` rebuilds the copy, and in agent mode the BUILD files under `.socket/go-patches` have to be deleted by hand. A project directory whose path from the root starts with `#` or white space, or holds `*`, `?` or `[`, cannot be named in `.bazelignore`: its line is written, and Bazel or gazelle does not honour it. `ignore_directories` in REPO.bazel is not read; a workspace that has it gets the line too. Tests The real-Bazel tests now assert the fixed outcome: the build prints the patched marker after the command and `bazel build //...` passes, the two tests of a module without a BUILD file build it again after `bazel run //:gazelle`, which writes nothing, and the undo takes the line away. The agent test starts from a `.bazelignore` of the user's whose last line has no line break, and ends with that file as it was. Tests without Bazel hold: the root finder (each of the four names, a directory of such a name, a link, a file above the checkout, a checkout of an owner that is not trusted and a project in no checkout, which both reach no further than the project); the line rules (what covers, the opt-out and what is none, a pair under another wording of the comment, the pair in LF and CRLF files and after a last line without a line break, the removal that leaves the file of before, a last carriage return included, a run that leaves Go out); the write (appended to the file that is there, a read-only file and a link left alone on an add and on a removal, a copy directory that cannot be probed, the lock on the root directory and none where nothing can change); two edits at once; and through the built binary each command's call: that a dry run of ten commands writes nothing in either mode, that a declined pair stays declined over scan, repair, apply, rollback and revert, that a rolled-back eject leaves the project as it was, that a prune pass and a hosted takeover take the line away with the last copy, that `--ecosystems npm` adds no line and takes the pair of a copy it removed away, that a scan which `socket.yml` lets write nothing leaves the file alone in every mode, that a manifest in another project brings both files in line, that a file which cannot be written is one warning for each command (in the envelope, and on stderr for a scan whose prune pass comes to the file a second time), what a human run prints for lines that came, lines that went and a file that went, that a project in no git checkout below a Bazel root gets no line and no warning, and that the same run in a project with no Bazel workspace file writes the same files, byte for byte but for the time in a vendored copy's marker, and no `.bazelignore`. No test depends on what lies above the temp directory: they pass with it inside a git checkout and outside one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` and `--vex` read what socket-patch wrote and what the project's package manager installed. They read no Bazel file, so under Bazel a document can say `not_affected` for a package Bazel builds unpatched. Before the product learns to tell, this records where the document and the build agree today. It changes tests, one docs section and four workflow path lists; no file under `crates/*/src`. Each of the eight real-Bazel flows whose build is patched (Go hosted, vendored, agent, and vendored with a module that ships a BUILD file; npm hosted and vendored; PyPI hosted; RubyGems hosted) now also asserts: - the command of the mode, given `--vex`, writes the document of its own run in the checkout Bazel has built in; - `vex` writes one before the patched build and one after it, and one with `--no-verify`; - after the undo `vex` writes none and removes the last: exit 2 `manifest_not_found`, or exit 1 `no_patches` after an agent rollback, which keeps its emptied manifest; - the command and `vex` write the same two documents in a checkout that no Bazel has built in, whose files outside `.socket/` are those of the checkout that built patched. A document is held to one statement: `not_affected`, `inline_mitigations_already_exist`, the advisory of the record, the package as the one subcomponent of the product, and `Patched via Socket patch <id>` with the id of this run, ` (redirected)` or ` (vendored)` by mode, and `; not verified on disk` exactly under `--no-verify`. The envelope is held to its exact warnings. Agent mode's `apply --vex` and the second scan of the npm flows are held to the same. All of it passes on Bazel 9.3.2, 8.8.2 and 7.7.2 (macOS arm64) as the product is: no expectation had to follow a wrong document. One thing a reader of such a document should know is now asserted. For a hosted pin no form hashes a file, since the bytes come with the next build and `vex` never reads Bazel's output: the statement rests on the lock entry and the patch record. The scan says so (`vex_hosted_unverified` in `vex.warnings`); stand-alone `vex` gives no warning, before the build or after it. The added socket-patch runs take 0.2 to 0.5 seconds per flow. `e2e_vex_lockfile/bazel_beside.rs` holds what later changes must keep. A pnpm project in `web/`, beside a root `MODULE.bazel` or `WORKSPACE` that builds Java and names none of its files, gets from `vex --json`, `vex` and `apply --vex` the exit code, both streams and the document it gets without Bazel, byte for byte but for the checkout's path, the document id and the time, for a hosted pin and for an installed patch. With Bazel files that do name the project's lock the output is the same today as well (tried, not kept): that is the case later work changes. In the harness a VEX document goes beside the workspace copy, so no comparison of a checkout's files sees one, and `Cell::twin` is a shutdown plus the new `Cell::unbuilt`. The push paths of the four Bazel workflows gain `crates/socket-patch-core/src/vex/**`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A code review of the VEX assertions in the real-Bazel flows found gaps in what the tests hold. This closes them. It changes tests, one docs sentence and the path lists of the four Bazel workflows; no file under `crates/*/src`. - The documents of a flow are compared with each other. Each one was checked alone, and its package through a normalising function, so the `%40` and the `@` spelling of an npm scope both passed and nothing showed that the forms write the same document. Now every document read in a checkout (of the run, of `vex`, of `vex --no-verify`) must equal the first one read there in every string but the document id, the timestamps and the `; not verified on disk` mark, and the documents of the checkout that Bazel has not built in must equal those of the one it has. The check of each document alone stays. The product spells all of it alike in all eight flows on Bazel 9.3.2, 8.8.2 and 7.7.2: no expectation had to differ per form. - `vex --output <file>` with no `--product`, the command a user types, runs once after the patched build in every flow. In the npm and the Go checkouts it exits 0 without a warning and writes the same document for the product of the project's own file, beside Bazel's links: `pkg:npm/socket-fixture@0.0.0` from `package.json`, `pkg:golang/example.com/consumer` from `go.mod`. The PyPI and the RubyGems fixture have no file a product is read from: there it exits 2 with `product_undetected` and writes no document. - The marker of a vendored copy is compared between the two checkouts as well, as JSON without `vendoredAt`, its one time field. The whole file was left out before, so a marker with another purl, patch id or advisory passed. - The `; not verified on disk` mark is the constant the product exports, `socket_patch_core::vex::NOT_VERIFIED_SUFFIX`. - The two hermetic tests of `e2e_vex_lockfile/bazel_beside.rs` tell each form the id of its document (`--doc-id`, and `--vex-doc-id` for `apply`) in place of rewriting the ids in what a run printed. - `docs/ecosystems.md` says that for PyPI on Bazel 8.5 and later a hosted scan leaves `MODULE.bazel.lock` stale: a build with `--lockfile_mode=error` fails until the lock is updated and committed. The PyPI flow already asserts both. - The pull request path lists of the four Bazel workflows gain `crates/socket-patch-core/src/vex/**` and `crates/socket-patch-cli/src/commands/vex*.rs`, the three files of the `vex` command. The flows hold exact VEX output, and the first commit added the core directory to the push lists only: a pull request that changed VEX code started no Bazel leg and could break all eight flows on main unseen. One hermetic test holds the two comparisons themselves: two spellings of a scope are two wordings, and a marker that names another package is another tree. The fixture checks hold the two product names to the fixtures' `package.json` and `go.mod`. Each new or changed assertion fails under one mutation, the real-Bazel ones on Bazel 9.3.2. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview The Bazel e2e harness gains shared VEX checks ( New hermetic Reviewed by Cursor Bugbot for commit d12790f. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. Each of the eight real-Bazel flows (Go, npm, PyPI, Ruby) now checks the full OpenVEX document at about nine points:
A new hermetic test shows Risk: low. No product code changes. The real-Bazel flows are Stacked: the base is Look here
Verified
Changes I made: none. Open questions (minor, none blocking):
Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed at d12790f. No product source changes. The new assertions are not vacuous: attests exact-matches the whole statement including the per-run patch id, and the hermetic self-test shows wording still tells two purl spellings and two patch ids apart. All 12 real-Bazel legs passed on this head. Non-blocking: detects_product may fail falsely on a local run when TMPDIR sits inside a git clone with an origin remote (not reproduced). Lands after #2123.
…nto bazel-vex/01-assert-document
…ocument # Conflicts: # .github/workflows/bazel-go.yml # crates/socket-patch-cli/tests/e2e_bazel_build/go.rs # crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs
The parent branches landed on main as squash commits (#2123, #2139, #2148), so this re-applies only this PR's own changes on top of main. main (#2155) turned build_document_with into the one builder, taking an Attested struct and adding code_not_present; this PR had added a separate build_document_with_affected. The affected PURLs are now an `affected` field of Attested, handled by build_document_with: - an affected PURL still gets a statement of its own with status `affected` and its action statement; - a not_affected statement keeps main's justification rule (vulnerable_code_not_present only when no subcomponent is patched); - `vex` passes both code_not_present and affected. Tests of the affected statements now go through build_document_with. CLI_CONTRACT.md keeps main's folded warning text and adds this PR's partialFailure-on-affected sentence. The bazel LOC budget is main's plus this PR's growth. Assisted-by: Claude Code:claude-opus-5-5
No user-visible change.
What this is
The first pull request of VEX support under Bazel. It holds tests, one docs section and four workflow path lists. No file under
crates/*/srcchanges:git diff --name-onlyagainst the base lists none.socket-patch vex, and--vexonscanandapply, read what socket-patch wrote and what the project's own package manager installed. They read noMODULE.bazel,WORKSPACEor BUILD file. So in a Bazel workspace a document says what was patched, and that is what Bazel builds only where Bazel builds from the files socket-patch rewrote. Elsewhere a document can saynot_affectedfor a package that Bazel builds unpatched. Before the product is changed to tell the two apart, this pull request records on real Bazel where the document and the build agree today, and fixes what must stay the same for a project that Bazel does not build.Contents
crates/socket-patch-cli/tests/e2e_bazel_build/harness.rsClaim,How), the arguments of the forms, a place for documents beside the workspace copy, a checkout that Bazel has not built in (Cell::unbuilt;Cell::twinnow uses it), the six checks the flows share, the two comparisons they rest on (wordingof two documents,undatedof two trees) and a hermetic test of those two.../e2e_bazel_build/go.rsgo.mod.../e2e_bazel_build/npm.rsvexcheck that was there is replaced; the fixture check holds the product ofpackage.json.../e2e_bazel_build/pypi.rs.../e2e_bazel_build/ruby.rs.../e2e_bazel_build/main.rscrates/socket-patch-cli/tests/e2e_vex_lockfile/bazel_beside.rsvexsays what it says without Bazel.../e2e_vex_lockfile/main.rsdocs/ecosystems.md.github/workflows/bazel-{go,npm,pypi,ruby}.ymlcrates/socket-patch-core/src/vex/**andcrates/socket-patch-cli/src/commands/vex*.rs; the comment of each list says whyProduct code: 0 lines. Tests: +804 −60. Docs: +35. Workflows: +54 −22. Fixtures: 0. Of that, the review commit is tests +223 −33, docs +4 −1 and workflows +54 −26.
What it proves, and where
Each of the eight flows whose Bazel build is patched now also asserts the VEX document, in nine places:
--vex, writes the document of its own run, in the checkout Bazel has already built in.vexwrites one after that command, before the patched build.vexwrites one after the patched build.vex --no-verifywrites one.vexwrites none and removes the last one.--vexwrites the same document, and it leaves the files of the checkout that built patched, byte for byte but for one field:vendoredAt, the time in the marker file of a vendored copy (socket-patch.vendor.json).vexwrites the same document there.; not verified on diskmark of--no-verify, and the documents of the checkout Bazel has not built in must equal those of the one it has.vex --output <file>with no--product, as a user types it, runs once after the patched build, beside Bazel's links.A document is held to exactly one statement:
not_affected,inline_mitigations_already_exist, the advisory of the patch record, the package as the one subcomponent of the product, and an impact statement that names the patch of this run. The patch id is new for every run, so no document of an earlier run can pass. The envelope is held to its exit code, its oneverifiedevent and its exact list of warnings. Every form but the run of item 9 is told one product.go_deps.from_filePatched via Socket patch <id> (redirected)manifest_not_found... <id> (vendored)manifest_not_found... <id> (vendored)manifest_not_foundapply --vex)Patched via Socket patch <id>no_patches(the rollback keeps its emptied manifest)npm_translate_lock(also from the second scan)... <id> (redirected)manifest_not_foundalready_vendored)... <id> (vendored)manifest_not_foundpip.parse... <id> (redirected)manifest_not_foundbundle_fetchwithoutgem_checksums... <id> (redirected)manifest_not_foundUnder
--no-verifyeach impact statement ends with; not verified on disk, and the run warnsvex_not_verified.Without
--product(item 9):vexdoespkg:npm/socket-fixture@0.0.0: the name and the version of the checkout's ownpackage.json, which Bazel's links show a second timepkg:golang/example.com/consumer: the module of the checkout's owngo.mod, which records no versionproduct_undetected, no document: the fixtures have no file a product is read fromAt the head of this pull request the Go and npm flows pass on Bazel 9.3.2, 8.8.2 and 7.7.2, and the PyPI and RubyGems flows on 9.3.2, on macOS arm64, run the way the workflow's run step runs them. The PyPI and RubyGems flows passed on 8.8.2 and 7.7.2 at the first commit and were not run again after the review commit. Seconds per test, from one loaded machine:
go::hosted_go_depsgo::vendored_go_depsgo::agent_go_depsgo::vendored_go_deps_module_with_a_build_filenpm::hosted_npm_translate_locknpm::vendored_npm_translate_lockpypi::hosted_pip_parseruby::hosted_bundle_fetchThe
socket-patchruns the first commit added take 0.2 to 0.5 seconds per test; the review adds one morevexrun per flow, which was not timed on its own. On Linux, on GitHub's runners, all twelve Bazel legs of this pull request pass at its head (Go, npm, PyPI and RubyGems on Bazel 9.3.2, 8.8.2 and 7.7.2; 95 to 280 seconds per leg), with the other 59 checks.Each check was shown to bite on Bazel 9.3.2. With each of these changes all eight tests fail: a document expected to hold two statements; the patch id of another run expected;
vexskipped where an earlier document is at the path, with the check of its document kept; the "no document" check moved before the undo. The mutations of what the review added are under "Code review".The new hermetic module holds what later changes must keep. A pnpm project in
web/sits beside a rootMODULE.bazel(with aBUILD.bazel) or a rootWORKSPACEthat builds Java and names none of the project's files. For a hosted pin and for a patch innode_modules,vex --json,vexandapply --vexgive the exit code, both output streams and the document they give in the same checkout without Bazel, byte for byte after the path of the checkout and the timestamps are replaced; each form is told the id of its document (--doc-id, and--vex-doc-idforapply). The comparison bites: with another pin or another installed file beside Bazel only, both tests fail. These tests are part of the workspace tests. On a pull request that is not a draft the Linux leg runs them (thecoveragejob ofci.yml); a draft runs none, and the Windows and macOS legs run in the nightly schedule and on dispatch. A later change that makes one fail, or that needs an edit to that file, has changed the answer for a project Bazel does not build.What it shows about the release
vexand ofvex --no-verify, in the checkout Bazel has built in and in the one it has not, name the product, the package, the advisory with its aliases and the status with the same strings; for npm every form writes the scope as%40. No expectation had to differ per form.--product,vexbeside Bazel's links finds the product of the project's ownpackage.jsonorgo.modand no second one behind the links. Where a checkout has no such file it writes no document and says which option to pass.vexnever reads Bazel's output, so the statement rests on the lock entry and the patch record. The scan says so (vex_hosted_unverifiedinvex.warnings). Stand-alonevexgives no warning, before the patched build or after it. Both are now asserted.vexreads no Bazel file. With Bazel files that do name the project's lock, the output is the same as without Bazel today, also for a patch that is only innode_modules, which rules_js never builds. That is why the docs now list the shapes that are tested and the ones measured to be wrong.Code review
A review of the first commit found eight things. The second commit, "Hold the VEX documents of the Bazel flows to each other after review", holds what changed: tests, one docs sentence and the workflow path lists.
%40and the@spelling of an npm scope both passed. Now the documents are held to each other (items 6 to 8); the check of each document alone is unchanged. On Bazel 9.3.2: with the@spelling in the stand-alone document both npm flows fail; with another alias of the advisory there, a field no single-document check reads, all eight fail; with the documents of the unbuilt checkout worded apart, alike among themselves, all eight fail.pip.parsewithout the stale lock. "Bazel workspaces: VEX" now says that for PyPI on Bazel 8.5 and later a hosted scan leavesMODULE.bazel.lockstale: a build with--lockfile_mode=errorfails until a build that may update the lock has run, and the updated lock has to be committed. The PyPI flow already asserts both.crates/socket-patch-core/src/vex/**to the push lists only, while the flows hold exact VEX output. That pattern andcrates/socket-patch-cli/src/commands/vex*.rs(it matchesvex.rs,vex_consumed.rsandvex_sources.rs, the files of the command, and nothing else) are now in the pull request list and the push list of all four callers. Each pull request list is still a subset of its push list, and its comment says that VEX code starts the legs of every ecosystem because the flows hold the document.actionlintandscripts/check-tool-pins.pypass.vexwithout--productno longer ran in a checkout Bazel has built in. It runs once per flow after the patched build (item 9 and its table). The outcome was measured first with one run per ecosystem and is asserted in all eight flows, in two to four lines each. On 9.3.2: with another product expected all eight fail, and so do the two fixture checks that hold the product names topackage.jsonandgo.mod; with the run given a product after all, the npm, PyPI and RubyGems flows fail (not run on Go).vendoredAt, its one time field, so another purl, patch id or advisory in it fails. On 9.3.2: with another advisory in the marker of the unbuilt checkout the three vendored flows fail (npm vendored, both Go vendored); under the filter of the first commit the same marker passes (run on npm), which was the gap.; not verified on diskmark was hard-coded. The harness uses the constant the product exports,socket_patch_core::vex::NOT_VERIFIED_SUFFIX. With the mark expected on the verified forms instead, the PyPI flow fails. Left open: the other strings of a document that the harness spells out (the context URL,not_affected,inline_mitigations_already_exist,Patched via Socket patch,(redirected),(vendored),openvex-0.2.0).bazel_beside.rs.vexhas an option that pins the document id, so each form is told one (--doc-id,--vex-doc-id) and the id is no longer rewritten in the output; one of the two expressions is gone. Without the option on the first form both tests fail. Left open: the hand-written pnpm lock, and the expression for timestamps, still compiled per call.A hermetic test in the harness holds the two comparisons themselves: two spellings of a scope are two wordings, a marker that names another package is another tree, and no other file is read for a time. It fails when
wordingalso drops the products and whenundatedalso drops the purl.Gate at the head:
cargo fmt --check;cargo clippy --workspace --all-features -- -D warnings; clippy on thee2e_bazel_buildtarget; that target without Bazel (28 passed, 8 ignored); the two hermetic tests ofbazel_beside;--test cli --test spawn_env_hygiene(98 and 21 passed);actionlintandscripts/check-tool-pins.pyon the four callers. One pattern in the Go lists matches no tracked file,crates/*/src/**/*golang*/**; main has it there and ingo-compatibility.yml, and this pull request leaves it as it is.Not claimed
bazel_besidepass on Windows, in a run of the workspace tests started by dispatch on this branch (run 44407451977). That run is red for one other test,scan_project_discovery_e2e::agent_scan_names_a_python_project_below_with_its_own_venv, in a file this pull request does not touch: it builds a virtualenv with the Unix layout (lib/python3.12/site-packages), which is not where a Windows virtualenv keeps its packages.WORKSPACEshape, no other ruleset or ruleset version than the fixtures', no Bazel release but the three, noGemfile.lockwithout aCHECKSUMSsection.vexwithout--productin a checkout that has a gitoriginremote. Detection reads that remote first, and the workspace copies of the flows are in no git checkout. A run of these tests with the temp directory inside a clone would detect the clone's remote and fail item 9.vexchecked the bytes Bazel built. The marker the build prints and the document are two observations of one checkout.What follows
node_modules, a virtualenv or a gem home; a vendored PyPI or gem artifact), and where a lock that Bazel reads holds the package without the patch.WORKSPACEfiles, and for Go where ago_repositoryrule supplies the module or gazelle may select another version.gem_checksumsentry, and then Maven, Cargo and NuGet.Generated by Claude Code