Repository navigation
Attest a package as affected in VEX where a Bazel module hub builds it unpatched - #2159
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>
Whether a patch reaches a Bazel build depends on which file the
workspace's rules read: `npm.npm_translate_lock(pnpm_lock = ...)`,
`pip.parse(requirements_lock = ..., requirements_by_platform = {...})`,
`ruby.bundle_fetch(gemfile_lock = ..., gem_checksums = {...})`,
`go_deps.from_file(go_mod = ...)`. socket-patch has no reader of Bazel
files. This adds one, as library code in
`crates/socket-patch-core/src/bazel/` beside `bazel_root`. Nothing calls
it yet and no command changes: its first caller is the VEX step that
withholds a statement for a copy Bazel does not build.
What it reads
`starlark.rs` lists every call `name(...)` and `a.b(...)` of a file, at
any depth: the callee as written, its line and bytes, and each argument,
positional, by keyword, `*` or `**`. An argument is a string literal
(either quote, tripled or raw, decoded as Bazel's lexer decodes it), a
list of strings, a dict from strings to strings or lists of strings, a
bare name, or "other". A call says whether it is a whole statement, an
argument of another call, in a comprehension; only the first says that
it runs, and once. Beside the calls it lists what each statement binds
(`x = f(...)`, `x = y`, the symbols of a `load` with their aliases) and
every other place a name stands, marked where the name may be given a
value there: a tuple target, the variable of a comprehension. A name
means what the last statement before it bound it to. That is how these
files run: Bazel allows no `if`, `for` or `def` statement and no
`lambda` in them (`DotBazelFileSyntaxChecker`, the same at 7.7.2, 8.8.2
and 9.3.2). Tokens end where Bazel's lexer ends them: a name that ends a
line and a parenthesis that starts the next are two statements, and the
`for` of `0for` is a word of its own.
`workspace.rs` reads MODULE.bazel and the files it includes, through a
view: a function from a path below the Bazel root to text, absent or
unreadable, so the same code serves a checkout on disk and files held in
memory. `disk()` is the view of a checkout and opens nothing outside the
Bazel root. `Workspace::tags(extension, tag)` returns the calls of one
tag of one module extension, with the file and line of each. An
extension is known by the module and the `.bzl` file that define it
(through the name a `bazel_dep(repo_name = ...)` gives the module, or
the root module itself), never by the name of its proxy: rules_go's
`go_sdk.from_file` and gazelle's `go_deps.from_file` take the same
`go_mod`. `Workspace::label` reads a label of a tag as Bazel does: from
the root package, whichever file the tag is written in
(`StarlarkBazelModule.create`), with the root module's own repository
name as the main repository. `include` is read by Bazel's rules
(`CompiledModuleFile.checkModuleFileSyntax`,
`ModuleFileFunction.advanceHorizon`; it exists from 7.2.0): a statement
of its own with one string that starts with `//` and ends in
`.MODULE.bazel`.
Why nothing is evaluated, and what is reported instead
To evaluate Starlark is to run the workspace's code and its rulesets'.
The reader states what the text says outright and says where it cannot,
as doubts: those of the workspace (`Workspace::doubts`), which are about
every answer, and those of one answer (`Tags::doubts`). With neither,
the calls listed are the calls of that tag which the files of a
workspace Bazel accepts can make. That is held by tests, one for each
way found so far to write a call that would not be listed, and not
proven; what Bazel is told outside the files (a flag, an override on the
command line) is not known to the reader. A doubt is:
- a file that is missing, cannot be read, is not UTF-8, is over 1 MiB,
is reached through a path or a link that leaves the Bazel root, or
includes itself; a 257th file, or text past 8 MiB in all;
- a string or a bracket that is never closed, which Bazel refuses too;
- an `include`, `use_extension`, `module` or `bazel_dep` whose label or
name is not written as a plain string, or that may not run: one that
gives a name or a file and is not a whole statement (behind `and`, in
a conditional, in a comprehension);
- an `include` with a second argument (9.3.2 takes `dev_dependency`);
- one of those four names, `use_repo` or `inject_repo` used other than
to call it: under such a name, `getattr` calls a tag;
- `True`, `False` or `None` where the file may give it another value:
Bazel then reads `repo_name = None` otherwise;
- for the extension asked about, a proxy used for anything but calling
a tag on it or as the whole first argument of `use_repo` or
`inject_repo`. `override_repo` is such a use: it puts another
repository in the place of one the extension makes.
A computed argument is no doubt: the call is listed and the argument is
"other", never a guess. A label can name a target of a BUILD file
instead of a file; the reader gives its path, and whether the file
exists is for the caller to ask. WORKSPACE files and the `.bzl` files
they load are not read yet; `load` bindings and labels relative to a
package are there for them, and what a name is bound to inside a
function of a `.bzl` file is not told yet.
The reader takes any bytes and panics on none. It makes one pass over
the bytes and one over the tokens, with no recursion, a name bound again
shares what it stands for, and a query looks at each call, binding and
use once, so the work grows with the size of the files. The tests hold
that with the largest file that is read in each shape that nests or
repeats, with one long symbol, call or label that many names stand for,
and with a sample file cut and altered at every byte.
Measured, outside the tree, on the 17,842 MODULE.bazel, *.MODULE.bazel,
WORKSPACE, WORKSPACE.bazel, WORKSPACE.bzlmod and .bzl files of 35
repositories (rulesets with their examples, Bazel itself, the Bazel
Central Registry): 17,841 are read and one is refused, a fixture with
an unclosed string. Of 13,664 directories with a MODULE.bazel, 13,653
are read without a doubt. The four lookups find 941
`go_deps.from_file`, 389 `npm_translate_lock`, 984 `pip.parse` and 42
`bundle_fetch` calls; a second reading of the same files with regular
expressions finds the same calls with the same string arguments in
every directory, and 66 of them were compared by eye. What a person
can read there and the reader reports as a doubt: an include through a
directory link that leaves the Bazel root (8 directories), and a
`repo_name` given as a constant (1). What it lists without a value: 18
lock arguments that are computed, each in a comprehension. The largest
of those workspaces is 55 KiB in 70 files. A workspace made to be
costly, 8 MiB of nothing but names, takes about 1 GiB for under a
second.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The reader of `MODULE.bazel` files in
`crates/socket-patch-core/src/bazel/` still has no caller. This closes
the cases where a caller would have got a certain answer that was
wrong, or a reader that held far more than its input. No command
changes.
What a reader holds is bounded
The bounds were 1 MiB for a file, 256 files and 8 MiB of text for a
workspace. That bounds the text, not the index: every call, argument
and use owns its strings and vectors. `MODULE.bazel` and seven included
files of 1 MiB of `f(a,b,c,d)` lines made a release build hold 541 MiB
of live allocations (790 MiB resident), nested `f(f(f(` 1,082 MiB, and
one `tags()` query over a proxy that is used on every line 749 MiB.
Now a file may have 131,072 tokens (`starlark::MAX_TOKENS`), and so may
the files of one workspace together: `index` refuses a file with more,
and `Workspace::read` hands each file what the ones before it left. A
file that does not fit is a doubt about every answer ("it is too large
to read with certainty ...") and takes nothing from what is left, so a
smaller file after it is still read. An index holds at most one call,
argument, binding, use or string for a token; a test asserts that for
27 shapes. Two things grew with the input beside the index and are
bounded too. A list of doubts keeps its first 1,024: a file that names
`use_repo` on every line held 180 MiB, most of it doubts. And the label
of an included file may be 4,096 bytes long, because every doubt names
the path of its file.
Measured in a release build as peak live allocations, with the resident
size in brackets, for the largest workspace of each shape that is still
read:
calls `f(a,b,c,d)` 14.7 MiB (20.6)
arguments `f(a,a,...)` 13.9 MiB (19.2)
uses `a a a` 13.4 MiB (20.8)
bindings `a=b` 12.3 MiB (18.3)
nested calls `f(f(f(` 27.0 MiB (31.1)
strings of a list 6.9 MiB (8.9)
a proxy used on every line,
with one query 13.4 MiB (21.1)
nested calls, and seven files
of one 1 MiB name each 34.0 MiB (43.3)
255 files of 32 KB of calls 10.3 MiB (15.9)
The seven-file inputs above are now refused, and take 6 to 7 MiB. The
bound is far from real files: the largest of 13,664 real workspaces has
4,669 tokens in 70 files, 28 times fewer; the largest `MODULE.bazel`
has 3,316; and the largest of 17,842 files of any kind, a 289 KB `.bzl`
file that no workspace reads yet, has 39,954.
A WORKSPACE file beside MODULE.bazel is reported
Bazel 7 takes repositories from a `WORKSPACE` file beside
`MODULE.bazel` by default, Bazel 8 under `--enable_workspace`, Bazel 9
never: the flag defaults to true at 7.7.2 and to false at 8.8.2
(`BuildLanguageOptions.java` 7.7.2:265, 8.8.2:289) and is a no-op at
9.3.2 (`BazelRulesModule.java`:880), which has no
`WorkspaceFileFunction`. The reader said nothing of that file: a
`MODULE.bazel` without a pip tag beside a `WORKSPACE` that calls
`pip_parse(requirements_lock = ...)` gave no call and no doubt.
`Workspace::read` now asks the view for the file Bazel would take:
`WORKSPACE.bzlmod`, else `WORKSPACE.bazel`, else `WORKSPACE`
(`WorkspaceFileFunction.compute` 7.7.2:124-137, 8.8.2:132-145;
`BazelSkyframeExecutorConstants.java` 7.7.2:51, 8.8.2:32). Bazel takes
the first that is a file (`ExternalPackageHelper.checkWorkspaceFile`
7.7.2:69, 8.8.2:75), so a directory of that name is passed over: a
disk that folds case has one for `workspace`. When the file holds a
call other than `workspace(...)`, `Workspace::legacy` holds its name
and its index, or why it could not be read.
It is a field of its own and no doubt, because whether Bazel reads the
file is not in these files. A caller that knows the release, from a
`.bazelversion`, can pass over it; a caller that looks for one ruleset
can see whether the file calls it; and both can tell it from a
`MODULE.bazel` that could not be read, which is a doubt whatever the
release. Without either, an answer is certain only when the field is
`None` too. The file is read with or without a `MODULE.bazel`, last,
and within the bounds of the workspace.
Of the 13,664 real workspaces 137 have such a file, 22 of them one that
defines something, and 4 of those call a rule that reads a lock or
names packages: `maven_install` twice, `go_repository`, and a gazelle
repository macro. None calls `pip_parse`, `npm_translate_lock` or
`bundle_fetch`.
Statements Bazel refuses are doubts
A call in the body of an `if`, `for` or `def` statement was listed as a
statement that runs, with no doubt: `if False:` and an indented
`pip.parse(...)` came back as a call that runs. Bazel refuses such a
`MODULE.bazel` (`DotBazelFileSyntaxChecker.java`, identical at 7.7.2,
8.8.2 and 9.3.2: `visit(DefStatement)` :120, `visit(ForStatement)`
:138, `visit(IfStatement)` :149, and `visit(LoadStatement)` :110 for a
file that may not load, which a module file is:
`CompiledModuleFile.java` 7.7.2:96, 8.8.2:111, 9.3.2:109), and the
reading rested on that alone. `starlark::File::blocks` now lists the
statements that start with one of the three words, and in a module
file each is a doubt about every answer. So is a `load`. None of the
13,787 real module files has either, so no real workspace gains a
doubt.
`disk()` reads what the run has written
A later caller writes `MODULE.bazel` and reads the workspace in the
same run. `disk()` opened files itself, so it did not see a write that
a group commit still holds in memory. It now asks the group commit
first, for a path made of plain names only, and puts what it gets
through the same size and UTF-8 checks. A file the run has removed is
absent.
`disk()` also reads one byte more than the bound of a file, and refuses
a file that has it. Before, a file that grew after its size was taken
was cut at 1 MiB and parsed as if it ended there. The root is resolved
once, when the view is made, and no longer for every file. Its doc now
says what is not guaranteed: another process that swaps a directory for
a link between the resolving of a path and its opening is not seen.
Smaller changes
- The bindings of `load` (`Bound::Loaded`) are gone: 18 code lines and
two tests. Bazel takes no `load` in a module file, no reader used
them, and they come back with the reader of `WORKSPACE` files that
needs them. `load` stays a call in the index.
- `tags()` takes the `use_repo` arguments of each file from
`Workspace::read` instead of collecting them again for every query,
and passes over a file that does not ask for the extension.
- A file with a byte that is not UTF-8 is still refused, although Bazel
builds one whose byte is in a comment: 0 of 17,842 real files have
one, and the module doc now names the limit.
Checked
- 17,842 real Bazel files: 17,841 indexed, the same one refused, no
panic. 13,664 workspaces: none gains a doubt, and the files read and
the hub calls with every argument are the same as before in all of
them. An independent reading by regular expressions agrees on every
hub call.
- 161 hand-written hostile cases give the same output as before, but
for the four new doubts of one case. 82,000 fuzz inputs: no panic,
none over 200 ms.
- 20 mutations, at least one for each new check: each is caught by a
named test.
- The `bazel::` unit tests are 75, from 69. The two files hold 937 code
lines, from 888, and the cap of the `bazel` group in
scripts/loc-budget.json follows the code: 1,131, from 1,082.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…to bazel-vex/03-not-in-build
Windows refuses to open a directory with "Access is denied", so the regular-file check after the open never ran there: a WORKSPACE.bazel directory became a doubt instead of being passed over for WORKSPACE, and the_checkout_on_disk_is_read_through_the_same_code failed on the Windows test shard. Check for a directory before opening. Assisted-by: Claude Code:claude-opus-5-5
…vex/03-not-in-build
Two flows of the real-Bazel tests, and a twin of each that needs no
Bazel, for two shapes in which `socket-patch vex` says `not_affected` of
a package that Bazel does not build patched. They assert what
socket-patch does today; no file under crates/*/src changes.
npm::agent_npm_translate_lock. The fixture's hub is aspect_rules_js's
`npm.npm_translate_lock(pnpm_lock = "//:pnpm-lock.yaml")`. The test lays
the package out in `node_modules` as `pnpm install` does (the two files
of the tarball in pnpm's virtual store and the link to them; no pnpm
runs), and `scan --mode agent --yes` patches that copy. rules_js builds
the package from the tarball the lock names and never reads
`node_modules`: on Bazel 9.3.2 the build prints the unpatched marker
before the scan and after it, while `scan --vex`, `apply --vex`, `vex`
and `vex --no-verify` each write a document with one `not_affected`
statement for the package.
pypi::vendored_pip_parse. The fixture's hub is rules_python's
`pip.parse(requirements_lock = "//:requirements.txt")`. `scan --mode
vendored --yes` commits the patched wheel under `.socket/vendor/pypi`
and puts the path of that wheel in the place of the package's pin.
rules_python 2.5.0-rc4 takes the path for the name of a project: on
Bazel 9.3.2 the next build fails in the `pip` extension ("invalid
user-provided repo name 'pip_311__/_socket/vendor/pypi/...'"), while
`scan --vex`, `vex` and `vex --no-verify` each write the `not_affected`
document. `vendor --revert` restores every file and the unpatched build.
The twins (npm::an_installed_patch_beside_a_hub_that_reads_the_lock and
pypi::a_vendored_wheel_beside_a_hub_that_reads_the_requirements) run the
`socket-patch` steps of the two flows in a copy of the fixture, so the
workspace test job holds them on every pull request.
In the test code, the record of an npm patch moved into a function that
the hosted, the vendored and the new agent grant share, and the PyPI
grant takes the sums it names as an argument: vendored mode downloads
the wheel itself and takes it only with a sha512. The hosted and
vendored flows that were there are served the same bytes as before.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…build
`socket-patch vex`, and `--vex` on scan, apply and vendor, say
`not_affected` for a package from what socket-patch wrote and what the
project's package manager installed. They read no Bazel file, and in a
Bazel workspace that is not what Bazel builds. The two flows of the
commit before this one show it. There, on Bazel 9.3.2, every form wrote
the statement; the builds they assert are the same on 9.3.2, 8.8.2 and
7.7.2:
- Agent mode beside aspect_rules_js 3.6.0. `npm.npm_translate_lock`
builds a package from the tarball `pnpm-lock.yaml` names and never
reads `node_modules`: the build prints the unpatched package before
`scan --mode agent` and after it.
- Vendored mode beside rules_python 2.5.0-rc4. `pip.parse` takes the path
line that vendored mode puts into `requirements.txt` for the name of a
project, and the build fails ("invalid user-provided repo name
'pip_311__/_socket/vendor/pypi/...'").
The step. `generate_vex` gains one step after the Go checks and before
the gate omissions are joined, so every form passes through it: `vex`,
`vex --no-verify` and the three embedded ones. For each package it is
about to attest that is not a hosted pin, the new
`bazel::built::unbuilt` says whether the files of the project's Bazel
workspace show a call that builds the package from a file without the
patch:
- The patch is in the installed copy of an npm, PyPI or RubyGems
package, and a call of `npm.npm_translate_lock`, `pip.parse` or
`ruby.bundle_fetch` names the project's own lock, which lists the
package at that version and does not name the patch. The project's
own lock is the one in its directory, or the lock of a pnpm workspace
above it that names that directory among its importers
(`formats::pnpm::workspace::lock_text_member_importers`, the keys the
existing `lock_text_has_member_importers` asked about).
- The patch is a PyPI or RubyGems copy under `.socket/vendor`, and such
a call names the file lockfile discovery found the vendored reference
in (`Plan::vendor_pins`, new). A `bundle_fetch` with `srcs` is left
alone: rules_ruby 1.0.0-rc2 copies those files to where `bundle
install` runs, the gem maybe among them. rules_js builds a vendored
tarball, so vendored npm is never withheld.
Such a package is omitted with the new code `vex_bazel_not_in_build`,
and a run warning of that code names the patch, the call with its file
and line, the file Bazel builds from, and what to do:
pkg:npm/left-pad@1.3.0: patch <uuid> is in the installed copy, which
Bazel does not build from. `npm.npm_translate_lock` (MODULE.bazel:6)
builds this package from pnpm-lock.yaml, which does not name the
patch. Run `socket-patch scan --mode hosted` in the directory of that
lock to pin the patch there.
For a vendored copy it says `socket-patch vendor --revert`, then
`socket-patch scan --mode hosted`. Both ways out are part of the two
flows: after the hosted scan the build prints the patched package and
`vex` attests it.
Exit codes. `vex` exits 1 with `no_applicable_patches` when nothing else
is attested, as for every other omission. An embedded `--vex` that
attests nothing, and withheld at least one patch for this reason, leaves
its host command the exit code and status it had
(`VexGenError::fails_host`, asked at the eight call sites). Before the
patch was withheld that run attested it, wrote its document and passed,
whatever else it omitted, and an `apply --vex` in an install hook must
not start failing installs because the project is also built with
Bazel. So the rule asks for one such patch, not for every omission to be
one: a manifest that also records a patch for a package this checkout
does not have is ordinary. No document is written and a previous one at
the path is removed, as for every failure; the envelope has no `vex` key
and no `error`, and carries the warning and one `vex_omitted` per
omitted package; a person reads `No VEX document written: ...` on
stdout, and nothing under `--silent`, as for every other document that
is not written while the command passes. A run that withholds no patch
for this reason fails as before.
What stays as it was. Nothing is read for a run without a package of
these three ecosystems, outside a Bazel workspace (`bazel_root`, which
looks no higher than the git checkout) or in a `--global` run. A lock
elsewhere that lists the same package is the lock of another project
and decides nothing: in a directory beside the project, below it, or
above it without naming it among the importers of a pnpm workspace. So
a project of the checkout that Bazel does not build keeps its
statement, also one with a lock of its own under a root whose lock a
hub reads, and the two tests of e2e_vex_lockfile/bazel_beside.rs pass
unedited. The workspace is read through `bazel::workspace` only, and
its answer is used only when it is certain. With a doubt of the reader
about the workspace or about the hub, with a `WORKSPACE`,
`WORKSPACE.bazel` or `WORKSPACE.bzlmod` that holds more than
`workspace(...)` (Bazel 7 reads it beside `MODULE.bazel`, and its rules
are not read yet), with a label that is not a plain string of the main
repository, or with a lock that cannot be read, the statement is the
one of a project without Bazel: a code for "could not be verified" does
not exist yet, and until it does an uncertain reading changes nothing.
A hosted pin is never withheld here, also not beside a second hub whose
lock lists the package without the patch.
How a lock is read. Like a file of the workspace: as the run left a
file it has not committed yet, and never through a link that leads out
of the Bazel root, although Bazel follows such a link (no answer then).
Only a lock that lies where the project's own lock can lie is opened,
once however many calls name it, and up to 64 MiB: a pnpm lock is
larger than the 1 MiB bound of the workspace's own files.
Tests. `bazel::built` has a table per case (the three hubs, installed
and vendored, a hub in an included file and in a comprehension, a file
per platform, every label form, the project in the lock's directory,
below it as a member and as none, above it and beside it, each kind of
uncertain workspace, which locks are read and how often) and two tests
on disk, one of them for a linked lock, a lock past the bound and a
pending write. The CLI has a unit test of the exit rule, one of the
step on a workspace on disk, with the two warnings in full and a
`--global` run, and one of the pin files of a package that one file
vendors and another pins on the patch host. The two real-Bazel flows
now expect no document, the exit codes above, the skipped event with
the code and the warning, with the same builds as before, and then the
remedy. Their twins without Bazel run the same steps; `apply --vex` and
`vendor --vex` of a checkout without a manifest, `vendor --vex` with
one, and `vendor --vex` over a hosted pin; a hosted scan that pins
nothing over a patch agent mode left; a second manifest patch whose
package is not installed; what a person reads, with the exit code, and
that `--silent` prints nothing; a project below the Bazel root, with
its own lock and as a member of a pnpm workspace at the root; and seven
workspaces in which the statement must stay.
Also here: the three workflows whose flows this module now decides for
(npm, PyPI, RubyGems) start on a change under
`crates/socket-patch-core/src/bazel/`; docs/ecosystems.md and
CLI_CONTRACT.md describe the code, the warning and the exit rule; the
`bazel` cap of scripts/loc-budget.json follows the 237 new code lines
under `bazel/`; three `Plan` literals of unit tests gain the new field.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The step that withholds a VEX statement for a copy a Bazel module hub does not build took a true statement away in two cases, passed a run that fails without Bazel in a third, and slowed a function that hosted mode calls on pnpm locks. This narrows what the step judges, and gives an embedded `--vex` a typed outcome for "no document, and the host command passes", which each host had to remember to ask for. What is judged. - Only a call that is a statement of its own (`Call::whole`): it runs, once. `[pip.parse(...) for v in []]`, `ENABLE and npm.npm_translate_lock(...)`, a conditional and a call in the arguments of another call may never run, and a statement was withheld for a call Bazel never makes, with a warning that named it. Such a call is passed over now, for an installed copy and for a vendored one; a call of the same hub that does run is judged as before. - Only the project documents of a pnpm lock. pnpm 11 keeps the packages of its own configuration (`configDependencies`) in a first document, which rules_js does not link, and the importers were already read from the project documents alone. A package that only that document lists was withheld; it keeps its statement now. The keys are read with the format's keys-only parse (`PnpmLock::parse_keys`, now visible to the crate), not the full one with every resolution map: 31 ms in place of 57 ms for a lock of 4.8 MB and 17,000 packages in a test build. - Only a patch a run would attest. A record that names no advisory gets no statement from any run. `apply --vex` over such a patch alone exits 1 with `no_applicable_patches`; beside a hub the patch was tagged for Bazel instead, and the command passed with a note that blamed Bazel. The step leaves such a patch alone, and the run ends as it does in the same checkout without a workspace file: the same exit code, envelope and lines. The outcome of an embedded `--vex`. That a run which attests nothing and withheld a patch for Bazel leaves its host the exit code was a rule on the error (`VexGenError::fails_host`), which each of the eight hosts had to ask in up to three places: the exit code, the envelope's error and the printed line. A new host, or an edit that marks the error itself, would fail installs again without a compile error. The enum of the manifest-less hosts is now the outcome of every host (`EmbeddedVex`, from `ManifestlessVex`), with `NotWritten(warnings, line)` beside `Written` and `Failed`: it holds both runs that write no document and pass, the one where nothing references a patch and the one where Bazel does not build what could be attested, with the line a person is told. `generate_vex_from_manifest_path` is private to the `vex` command, so a host can only get an `EmbeddedVex` (`generate_vex_embedded`), and only `Failed` fails it. The hosts' `Failed` arms are the lines they had before the step. No output and no exit code changes by this. The pnpm importers. `lock_text_has_member_importers` and `lock_has_member_importers` tell hosted mode whether a lock is a shared workspace lock, on locks of many megabytes. They had been rebuilt on a reader that collects every importer and parses every key line to the end of the lock. They are again what they were: they stop at the first member and parse no key line outside `importers:`. The names of the members, which only this step asks for, are read by a function of its own beside them (`lock_text_member_importers`), which reads comment lines, CRLF and the env document as they do. The lock reader. `lock_text` in `bazel::built` asks the run for a pending write only by a path of plain parts, as `workspace::disk` does for the files of the workspace; any other spelling reads the disk. No label gives such a path today. A directory was no lock already, on Windows because the open fails; a test says so on every system. This function repeats `disk` with a larger bound until the reader has a view with a byte bound. `vex --manifest-path` into another project needed no change: `vex` runs in the manifest's project, and every host command refuses such a path with `--vex`, so the step asks about one project. The step's docs say so, and a test holds it in both directions: a vendored wheel of the manifest's project is withheld when the hub reads that project's file, with a warning that names it, and attested when the hub reads the file of the project the command was run in. Docs. The list of Bazel shapes in which a document is still wrong had lost agent mode and vendored PyPI, which the step withholds only where it can be sure. docs/ecosystems.md lists what remains, per kind: agent mode where the hub reads a lock above the project that does not name it, a lock below the directory the command runs in, or a file above a Python or Ruby project; both kinds behind a `WORKSPACE` file that defines something, without `MODULE.bazel`, or under a call that is not a statement of its own; hosted PyPI with a file per platform; Go under `go_repository` or behind a higher version. It and CLI_CONTRACT.md name the three new cases in which nothing is withheld. Tests. `bazel::built`: the comprehension, the `and`, the conditional and the nested call, for both kinds of copy, beside a call that runs; a lock of two documents; a pending write asked for by another spelling; a directory. Its fixture's Python hub is a plain call now, which moves two line numbers. `formats::pnpm::workspace`: a commented-out importer. `commands::vex`: the exit rule as a table over the outcome, and a record without an advisory in the step's test, whose other records gained one. `e2e_bazel_build`, without Bazel: the run over a patch without an advisory against the same run without `MODULE.bazel`, and the manifest path in another project. Each new condition fails a named test when it is taken out, and so does each of the hosts' `NotWritten` arms. The `bazel` cap of scripts/loc-budget.json follows the code: 1372 to 1378. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Embedded Real-Bazel and hermetic e2e tests cover agent npm beside Reviewed by Cursor Bugbot for commit 4371598. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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 4371598. Configure here.
|
[agent] PR shepherd: final review of 4371598. I found no correctness bug: every uncertain reading keeps the statement, so the step can only remove a false It needs the owner's decisions before I can hand it on, because it changes what a user's CI sees:
Also worth knowing: these lock forms aren't read, so the statement is kept for them. Nits (not blocking):
Generated by Claude Code |
The step that finds a patch Bazel does not build (one in an installed
copy, or a PyPI or RubyGems copy under .socket/vendor, beside a module
hub that reads the project's own lock) left the package out of the
document. When every patch of a run was in that state there was
nothing to write: `vex` exited 1 with no_applicable_patches, and
`scan --vex`, `apply --vex` and `vendor --vex` passed without a
document and removed an earlier one, through an outcome of their own.
`vex` is to say what state the package is in, and to exit 1 only when
it cannot write a document or meets an error. An OpenVEX document must
hold a statement, so leaving the package out cannot give one. The
package is now attested as not patched. Each advisory of its patch
gets a statement with the status `affected`, the package as the
subcomponent of the product, named as a `not_affected` statement names
it, and an action statement that says what Bazel builds the package
from and what to run so that the build holds the patch:
Bazel builds this package from pnpm-lock.yaml
(`npm.npm_translate_lock`, MODULE.bazel:6), which does not name
Socket patch <uuid>: the patch is only in the installed copy. Run
`socket-patch scan --mode hosted` in the directory of that lock to
pin the patch there.
Bazel builds no package from the line of requirements.txt that
points at the copy of Socket patch <uuid> under .socket/vendor
(`pip.parse`, MODULE.bazel:15): the build fails, or takes the
registry's package. Run `socket-patch vendor --revert`, then
`socket-patch scan --mode hosted`.
The statement has no justification and no impact statement. An
advisory that a patched package and such a package share has two
statements, the `not_affected` one first.
So a document is always written when a package is judged this way.
`vex` exits 0 with it, also when every statement says `affected`. A
command run with `--vex` writes it and keeps its exit code and its
usual envelope with the `vex` key. Nothing is omitted for this reason,
no earlier document is removed, and no "omitting ... from VEX" line is
printed. The run warning `vex_bazel_not_in_build` stays, one per
package: it says that the document says affected, then the action
statement. `vex --json` reports each package of a statement as the
`verified` event it reported before, and `details.status` of that
event is the status of its statement, where it was the constant
`not_affected`. A host's envelope carries the warning in
`vex.warnings`. Which packages are judged does not change, and neither
does anything outside a Bazel workspace.
In the code, `vex::build::build_document_with_affected` takes such
packages and their action statements beside the applied set, and
`build_document_marking_unverified` is that builder with none. The
step in `commands/vex.rs` hands them over. `apply.rs`, `vendor.rs`,
`scan/mod.rs` and `scan/hosted.rs` are the files they were before
this pull request: `ManifestlessVex` is back, and `EmbeddedVex`,
`generate_vex_embedded` and the rule that let a run with a withheld
patch pass are gone.
The two real-Bazel flows and their twins now expect, from every form,
the document that says affected, and after the remedy the one that
says not affected. A new twin holds a document with one statement of
each status for one advisory. Unit tests of the builder and a
conformance test hold an `affected` statement to its fields.
Two smaller things. `bazel::built` asks for a pending write of a lock
only once the path is known to be made of plain components: it asked
first and dropped the answer. And the docs name two more lock forms
that are not read, so their statement stays `not_affected`: an
`npm_package_lock` or `yarn_lock` of `npm_translate_lock`, and a
requirements file that another one brings in with `-r`.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The maintainer answered questions 1 and 2 on 2026-11-19, and commit The decision: What changed:
The special exit rule and its eight call sites are gone, so Still open (question 3, and the description's "Decisions for the owner"): only the project's own lock counts; a The label Generated by Claude Code |
A package that a Bazel hub builds without its patch is attested as `affected`. Seven things about that are changed here. `vex --json` reported such a package with the `verified` event of a patched one, so `summary.verified` counted it and the envelope's status was `success`: a script that counts verified events took an unpatched build for a patched one. It is now a `skipped` event with the code `vex_bazel_not_in_build` and `details.status: "affected"`, counted in `summary.skipped`, and the status is `partialFailure`, as for any run that leaves a patch unattested. The exit code stays 0 whenever the document is written, also when every statement says `affected`. The line a person reads counts them (`Wrote OpenVEX document with 2 statements (1 affected) to out.json`, and the same in the dry-run and stdout forms), and the `vex` object of `scan`, `apply` and `vendor` with `--vex` gains `affected` when any statement says so. Affected packages that share an advisory were merged into one statement whose action statement was the texts of all of them after one another, each about "this package". Each such package now has a statement of its own, after the `not_affected` one of the advisory, so an action statement is about exactly one subcomponent. A vendored PyPI package that is attested as affected no longer gets the `vendored_tree_out_of_sync` warning: it says the attestation is based on the committed copy and to install again, where the statement says to revert the copy. A vendored gem is no longer judged. That rules_ruby builds nothing from the path of the copy was read from its source and never built, and a wrong verdict would tell a user to revert a patch that works. The rule for a gem that is patched in its installed copy stays. A `pip.parse` call with `uv_lock` is not judged: rules_python 2.2.0 and later can take the packages of such a call from that file, which is not read, so the requirements file decides nothing. Neither is a call that passes `*` or `**`, whose arguments are not all written out. The text of a lock was kept and searched once per package for its patch id. It is searched once for all of them and dropped, and the importers of a pnpm lock are read to the end of their section only. For a lock of 5 MB with 17,000 packages and twelve patched ones the judgement takes 47 ms in place of 118 ms in a test build. The warnings of several such packages came in the order of a hash map, which changes from run to run. They are in the order of the packages. docs/ecosystems.md and CLI_CONTRACT.md follow, and the docs list two more shapes in which a document is still wrong: a vendored package whose own files the hub does not read while the lock it does read lists the registry's package. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
In a Bazel workspace `vex`, and `--vex` on scan, apply and vendor, take the Bazel build for the product: where a hub of MODULE.bazel reads the project's own lock, and that lock lists a package without its patch, the document says `affected` for a patch that is only in the installed copy. That is wrong for a repository that ships what its package manager installed, for example a container image built with `pnpm install` and `socket-patch apply`, and keeps the hub over the same lock for something else, such as its tests. There the patch is in what ships, and the repository had no way to say so. The option is that way, in three spellings: `--no-bazel` on `vex`, `--vex-no-bazel` on scan, apply and vendor, and SOCKET_VEX_NO_BAZEL in the environment, read as SOCKET_VEX_NO_VERIFY is (`1` or `true` sets it, an empty value does not). With it the step that asks what Bazel builds (unbuilt_by_bazel) returns before it opens a file, so the run is the one of the same checkout without its Bazel files: the document, the events, the warnings, the exit code and every printed line. The package is attested as `not_affected` through its patch, as in a checkout without Bazel. What changes without the option is one sentence. The action statement of a package that is affected because its patch is in the installed copy alone, and so the `vex_bazel_not_in_build` warning that repeats it, now ends with: "If what you ship is the installed tree and not what Bazel builds, pass `--no-bazel` (`--vex-no-bazel` on scan, apply and vendor)." It names both spellings because the statement is part of the document, which reads the same whichever command wrote it. The statement of a vendored PyPI copy does not get the sentence: there the build is broken or takes the registry's package, and the installed tree is not the patched one either. What stays: every statement, warning, event and exit code of a run without the option, apart from that sentence, and everything outside a Bazel workspace, where the option changes nothing and is accepted silently. The variable joins the lists that hold every flag-bound name (LOCAL_ARG_ENV_VARS and the table of boolean bindings beside it, and core's CHILD_ENV_SCRUB, so that no child process inherits it), and the option is left out of the short help like `--doc-id` and the other `--vex-*` options. CLI_CONTRACT.md, docs/ecosystems.md and docs/usage.md describe it. Tests: - The parse of the option on `vex` and on each command that takes `--vex`: the flag, and the variable as `1`, as `true`, empty and unset. The parse tests of apply, scan and vendor that pass every `--vex-*` option pass this one too. - The unit test of the step: with the option every set it was given is untouched, and nothing is returned or warned of. - Without Bazel: `vex`, `apply --vex` and `scan --mode agent --vex` beside a hub that reads the lock, with the option and with the variable, are held to the run of the same checkout without MODULE.bazel: the exit code, both streams byte for byte, and what the document says. Without the option the document says `affected`, as before. - On real Bazel, in the agent npm flow: after the build printed the unpatched package and `vex` said `affected`, `vex --no-bazel` exits 0 with a `not_affected` document. That document speaks of node_modules, not of the Bazel build. The two parse tests in vex.rs are now serial, like every test that parses with the environment: the table of boolean bindings sets SOCKET_VEX_* while it runs, and a parse beside it reads the value. Two struct literals of the `vex` arguments in in_process_alternate_installers.rs name the new field. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Two more commits, both pushed.
Still open, in the description's "Decisions for the owner": only the project's own lock counts; a The label Generated by Claude Code |
|
[agent] PR shepherd: review brief for the approver What it does. When Risk: medium. This is the first time the CLI emits Stacked: the base is Look here
Verified
Changes I made: none. Open questions
Generated by Claude Code |
…nto bazel-vex/01-assert-document
…to bazel-vex/02-reader
…vex/03-not-in-build
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
|
[agent] PR shepherd: merge from main, for the approver The approval stands. This note only covers the merge commit What it does: The PR's own six commits are re-applied on top of main. Main had replaced the builder's argument list with an Risk: medium. The merge combines two changes to the same function. The result keeps both rules: an affected PURL gets its own Look here
Verified: Changes I made: only the merge. The Open questions: none. Generated by Claude Code |
The parent branch landed on main squashed (#2157), so every file it added conflicted add/add. The merge takes the parent's last tip as its base, so only what main changed since then is merged in: #2159's VEX attestation, #2153's terminal UI and the rest. - scan/hosted.rs: keep this branch's removal of the hub notice from the hosted run. A hosted run patches a pinned hub or says why not among its rewriters' warnings, so the notice would repeat or contradict them. - scripts/loc-budget.json: the bazel group's cap is 2486, the count after the merge (this branch's 775 lines over main's 1711). cargo clippy -D warnings, the core lib tests, vendor_jvm_cli, e2e_bazel_maven_beside and the Maven CLI tests pass. Assisted-by: Claude Code:claude-opus-5-5

socket-patch vexand--vexnow sayaffected, with what to run, for a package that a Bazel module hub of aspect_rules_js, rules_python or rules_ruby builds without its patch, where they saidnot_affected; the run warns with the new codevex_bazel_not_in_build, andvex --jsonreports the package as skipped, not as verified. A repository that ships what its package manager installed says so with--no-bazel(--vex-no-bazelonscan,applyandvendor, orSOCKET_VEX_NO_BAZELin the environment), and the document then describes the installed tree.Decided
Decided by the maintainer on 2026-11-19, on whether
vexshould exit 1 for such a package and whether a command run with--vexmay pass without writing a document:vexreports the actual state of a package. It attests a package that is not patched as such, or leaves out a patch that is broken, and exits 0. It exits non-zero only when it cannot write a document or meets an error.The first three commits left such a package out of the document. When every patch of a run was in that state,
vexexited 1 withno_applicable_patches, andscan --vex,apply --vexandvendor --vexpassed without a document and removed an earlier one. The fourth commit applies the decision:affectedand an action statement that says what Bazel builds the package from and what to run.vexexits 0 with the document, also when every statement saysaffected. A command run with--vexwrites the document and keeps its exit code and its usual envelope.vexexits non-zero only where it did before this pull request: when it has no statement to write, or meets an error.The decision allows leaving the package out as well. An
affectedstatement was chosen for three reasons. An OpenVEX document must hold at least one statement, so a run whose every patch is in this state would have nothing to write and could not exit 0 with a document.affectedis the state of the package in what Bazel builds. And the action statement carries the remedy to whoever reads the document, not only to whoever saw the warnings of the run.Decided by the maintainer on 2026-11-19 as well, on a repository that ships what its package manager installed (for example a container image built with
pnpm installandsocket-patch apply) and keeps a Bazel hub over the same lock for its tests, where the patch is in what ships and the document saidaffected: such a repository says so with an option, and the document then describes the installed tree. The other choice was to accept that a workspace with such a hub gets a document about its Bazel build. The sixth commit adds the option; see The option below.What the code does today
vex, and--vexonscan,applyandvendor, read what socket-patch wrote and what the project's package manager installed. They read no Bazel file. The first commit adds two real-Bazel flows that record the result (run on Bazel 9.3.2 against the product code of the base):npm::agent_npm_translate_lock).npm.npm_translate_lock(pnpm_lock = "//:pnpm-lock.yaml")builds a package from the tarball the lock names and never readsnode_modules. The build prints the unpatched package beforescan --mode agentand after it, whilescan --vex,apply --vex,vexandvex --no-verifyeach write anot_affectedstatement for it.pypi::vendored_pip_parse).pip.parsetakes the path line that vendored mode puts intorequirements.txtfor the name of a project, and the build fails (invalid user-provided repo name 'pip_311__/_socket/vendor/pypi/...'), whilescan --vex,vexandvex --no-verifyeach write the statement.What changes
generate_vexgains one step, after the Go checks, that every form passes through. For each package it is about to attest that is not a hosted pin, and whose patch record names an advisory, it asks the newbazel::built::unbuiltwhether the files of the project's Bazel workspace show a call that builds the package from a file without the patch. Only a call that is a statement of its own, with all its arguments written out, counts: Bazel runs it, once, and nothing it reads is hidden. A package is attested asaffectedin exactly two cases:npm.npm_translate_lock(pnpm_lock),pip.parse(requirements_lock,requirements_by_platform,requirements_darwin,requirements_linux,requirements_windows) orruby.bundle_fetch(gemfile_lock,gemfile) names the project's own lock; that lock lists the package at that version (a pnpm lock in one of its project documents); and its text does not name the patch. The project's own lock is the one in the project's directory, or the lock of a pnpm workspace above it that names that directory among itsimporters..socket/vendor, and apip.parsecall names the file in which lockfile discovery found the vendored reference. A vendored npm tarball is never judged: rules_js builds it. A vendored gem is not judged either: no build has shown what rules_ruby does with one (see What follows).The statement. Each advisory of the patch gets a statement of the package's own. It names that package alone as the subcomponent of the product, with the advisory and its aliases. Its
action_statementsays what Bazel builds the package from and what to run so that the build holds the patch; for a patch in the installed copy it ends with the option for a repository that ships that tree. It has nojustificationand noimpact_statement. Packages that share an advisory are not merged into one such statement, so each action statement is about exactly one package. Thenot_affectedstatement of the advisory, for the packages that are patched, comes first. This is the document of a checkout in which hosted mode pinned one package and a second is patched only innode_modules:{ "@context": "https://openvex.dev/ns/v0.2.0", "@id": "urn:uuid:0777a364-bcfc-426e-b96c-858bfd50bcb9", "author": "Socket", "timestamp": "2026-11-19T15:14:47Z", "version": 1, "tooling": "socket-patch 5.1.0", "statements": [ { "vulnerability": { "name": "GHSA-test-aaaa-bbbb", "aliases": ["CVE-2024-0001"] }, "timestamp": "2026-11-19T15:14:47Z", "products": [ { "@id": "pkg:npm/socket-fixture@0.0.0", "subcomponents": [{ "@id": "pkg:npm/%40socketsecurity/bazel-fixture-upstream@1.0.0" }] } ], "status": "not_affected", "justification": "inline_mitigations_already_exist", "impact_statement": "Patched via Socket patch 901ac69f-20f1-4e34-ad01-8db7c97f5fe5 (redirected)" }, { "vulnerability": { "name": "GHSA-test-aaaa-bbbb", "aliases": ["CVE-2024-0001"] }, "timestamp": "2026-11-19T15:14:47Z", "products": [ { "@id": "pkg:npm/socket-fixture@0.0.0", "subcomponents": [{ "@id": "pkg:npm/%40socketsecurity/bazel-fixture-second@1.0.0" }] } ], "status": "affected", "action_statement": "Bazel builds this package from pnpm-lock.yaml (`npm.npm_translate_lock`, MODULE.bazel:7), which does not name Socket patch e793b25a-1f76-41e0-8b6e-96afb63764c3: the patch is only in the installed copy. Run `socket-patch scan --mode hosted` in the directory of that lock to pin the patch there. If what you ship is the installed tree and not what Bazel builds, pass `--no-bazel` (`--vex-no-bazel` on scan, apply and vendor)." } ] }For a vendored PyPI copy the action statement is the one below. It does not name the option: there the build is broken or takes the registry's package, and the patch is in the committed copy, which an installed tree holds only after the next install.
What a person reads. One warning per such package, in the order of the packages, then the usual line, which counts the statements that say
affected:The dry-run line and the line for a document on stdout count them the same way (
[dry-run] Would write OpenVEX document with 2 statements (1 affected) to out.json,Emitted 2 VEX statements (1 affected)). A vendored PyPI package that is attested asaffectedgets novendored_tree_out_of_syncwarning: that warning says the attestation is based on the committed copy and to install again, and the statement says to revert the copy.Exit codes and
--json. Nothing is left out of the document for this reason, so no run ends differently because of it, and no run reports such a package as patched. Whatvex --json --output <path>gives a script:statussummarywarnings[]not_affectedsuccessverifiedper packageverified= packages,skipped0affectedpartialFailureverifiedfor each patched package;skippedwitherrorCode: "vex_bazel_not_in_build"for eachaffectedstatementverified= patched packages,skipped=affectedstatementsvex_bazel_not_in_buildper affected packageaffectedpartialFailureskippedonlyverified0,skipped= statementsEvery event carries
detailswith the advisory, its aliases and thestatusof its statement.partialFailurewith exit 0 is whatvexalready gives a run that leaves a patch out beside one it attests; a patch left out for another reason is askippedevent too, under its own code.scan --vex,apply --vexandvendor --vexwrite the document and keep their exit code and status; under--silentthey print nothing and still write it. Their events are their own. Thevexobject of their envelope (path,statements,format,warnings) gainsaffected, the number of statements that say so, when there is one, andvex.warningsholds avex_bazel_not_in_buildentry per package. For that the four host files (apply.rs,vendor.rs,scan/mod.rs,scan/hosted.rs) hand the count on: 17 code lines, and nothing else in them changes.--no-verifychanges none of this.Nothing changes:
--globalrun is skipped.not_affectedstatement, and so does a project with a lock of its own under a root whose lock a hub reads. Such a lock is not even opened. The two tests ofe2e_vex_lockfile/bazel_beside.rspass unedited.and, in a conditional or in the arguments of another call is passed over:[pip.parse(...) for v in []]never runs. So is a call that passes*or**, and apip.parsewithuv_lock: rules_python 2.2.0 and later can take the packages of such a call from that file, which is not read. A call of the same hub that is a statement of its own, with its arguments written out, is judged.apply --vexover such a patch alone exits 1 withno_applicable_patches, as it does without a workspace file.configDependenciesin a first document of the lock, which rules_js does not link; only the project documents are read.bazel::workspaceonly, and its answer is used only when it is certain. With a doubt of the reader about the workspace or about the hub, with aWORKSPACE,WORKSPACE.bazelorWORKSPACE.bzlmodthat holds more thanworkspace(...), with a label that is not a plain string of the main repository, or with a lock that cannot be read, is larger than 64 MiB or is a link that leads out of the Bazel root, the statement is the one of a project without Bazel. There is no code for "could not be verified" yet.affected, and a run that attests nothing for such reasons still exits 1.A lock is read like a file of the workspace: as the run left a file it has not committed yet, never outside the Bazel root, once however many calls name it, and up to 64 MiB (a pnpm lock is larger than the 1 MiB bound of the workspace's own files). Of a pnpm lock only the package keys of its project documents are parsed. The text is searched once for the patches of all the packages and is not kept.
The option
One option, in three spellings:
socket-patch vex--no-bazelscan,applyandvendor, with--vex--vex-no-bazelSOCKET_VEX_NO_BAZEL, read asSOCKET_VEX_NO_VERIFYis:1ortruesets it, an empty value does notIt says that the document describes what the package manager installed. The step above then does nothing: it returns before it looks at a package, so no Bazel file is opened. The document, the events, the warnings, the exit code and every printed line are those of the same checkout without its
MODULE.bazel, so the package is attested asnot_affectedthrough its patch, as on the base. Outside a Bazel workspace the option changes nothing and is accepted without a word, and--vex-no-bazeldoes nothing without--vex, like the other--vex-*options.Without the option one sentence changes. The action statement of a package that is affected because its patch is in the installed copy alone, and the warning that repeats it, end with the way out for such a repository:
The sentence names both spellings because the statement is part of the document, and the documents of a checkout read the same whichever command wrote them. The statement of a vendored PyPI copy does not get it.
The help of
vex(the one of--vex-no-bazelsays the same in one sentence and points here):The option is in
--helpand left out of the short-h, like--doc-idand the other--vex-*options. The variable is in the three lists that hold every flag-bound name (LOCAL_ARG_ENV_VARSand the table of boolean variables inargs.rs, and the core'sCHILD_ENV_SCRUB), so an exported but empty value is dropped before the parse and no child process inherits it.CLI_CONTRACT.mdhas it in its option tables, in a paragraph of its own and in the row ofvex_bazel_not_in_build;docs/ecosystems.mdsays what it is for where it said that the document describes what Bazel builds;docs/usage.mdnames it beside--no-verify.Contents
Six commits, stacked on #2148 (the reader of Bazel workspace files), which is stacked on #2139 (the VEX document asserted in the real-Bazel flows) and #2123. The base of this pull request is #2148's branch, so the diff here is these six commits. It moves onto main when those have landed.
scripts/loc-budget.pybazel/built.rs251,commands/vex.rs97,vex/build.rs29,formats/pnpm/workspace.rs24,lib.rs13,commands/vex_sources.rs7,commands/apply.rs7,json_envelope.rs5,commands/scan/hosted.rs4,commands/vendor.rs4,commands/scan/mod.rs2,args.rs1,utils/process.rs1,bazel/mod.rs1,vex/mod.rs1)tests/e2e_bazel_build, 72 in the parse tests of the option and two struct literals, 1,113 in unit-test modules)docs/ecosystems.md,docs/usage.md,CLI_CONTRACT.md)The fourth commit takes 18 code lines away: the outcome that let a command pass without a document goes with its reason, and the document builder gains
vex::build::build_document_with_affected, which takes the packages and their action statements beside the applied set; the existing builders are that one with none. The fifth adds 45. Reporting anaffectedstatement as skipped and counting it is 38 of them: 16 incommands/vex.rs, 5 for theaffectedkey of the envelope'svexobject, and 17 in the four host files, which hand the count to their envelope and their line. The search of a lock for all patches in one pass, with the calls that are no longer judged, is 8 inbazel/built.rs, the end of the importer scan 3, and the two lines that take a package off the out-of-sync list and the one that orders the warnings 3; the builder loses 7 with the joining of action statements. The sixth adds 35: 20 incommands/vex.rs(the option on the two option structs, the field that carries it, the return of the step and the sentence), 13 inlib.rs, one each inargs.rsand the core'sutils/process.rs. The 13 are one name in each of the four lists of what the short help of a command leaves out; twelve of them are line breaks, because rustfmt writes the lists ofapplyandvendorone name per line once they hold five.formats/pnpm/workspace.rshas one function that names the member importers of a lock; the two existing predicates, which hosted mode calls on large locks, are the ones of the base. The keys-only parse of a pnpm lock (PnpmLock::parse_keys) is visible to the crate. The npm, PyPI and RubyGems Bazel workflows also start on a change undercrates/socket-patch-core/src/bazel/, which decides whatvexsays for their flows. Thebazelcap ofscripts/loc-budget.jsongoes from 1134 to 1386.What it proves and where
Every result below is from macOS arm64 with the pinned Bazel binaries. What was run at the sixth commit says so; every other result is from the fifth commit unless it says otherwise. On Linux, on GitHub's runners, all twelve Bazel legs pass at the sixth commit (npm, PyPI, Go and RubyGems on Bazel 9.3.2, 8.8.2 and 7.7.2; 167 to 436 seconds per leg), with the other checks of the repository's own workflows.
affected, the package under the product, the advisory, and an action statement that names the lock, the call withMODULE.bazel:<line>and the commands to run.vex --jsonreports oneskippedevent with the codevex_bazel_not_in_buildanddetails.status: "affected", none verified, the statuspartialFailureand the warning;scan --vexandapply --vex(for the wheel alsovendor --vex) report the document in their envelope withaffected: 1and keep their status. Then what the document says to do: afterscan --mode hosted(for the wheel aftervendor --revert) the build prints the patched package, the document saysnot_affected, andvex --jsonreports oneverifiedevent andsuccess. 13 to 16 seconds per flow, and 27 seconds for the npm one on 9.3.2, which ran first.vexsaidaffected,vex --no-bazelexits 0, reports the package as verified, warns of nothing and writes onenot_affectedstatement through the patch, and no file of the checkout changes. That document speaks ofnode_modules, not of the Bazel build, which is still the unpatched one. The flow then goes on as before (25, 12 and 13 seconds). The other two npm flows on the three releases and the two PyPI flows on 9.3.2 pass with their assertions unedited (15 to 30 seconds each). Not run again at the sixth commit, which changes none of their texts and nothing they read: the PyPI flows on 8.8.2 and 7.7.2, RubyGems and Go.uv_lockcall, the*and**call, the patch id of each package in the one-pass search, and the end of the importer scan; in the builder, the statement per package; in the step, the out-of-sync list and the order of the warnings; in the envelope ofvex, the action, the code and the status of the event, the status of the run and the count; each of the three lines ofvexand the wording of their count; theaffectedkey; and every one of the 13 places where a host command hands the count to its envelope or its line. The 18 mutations of the fourth commit were run at that commit. Each of 7 mutations of the sixth fails a named test: the option ignored by the step, byvexand by the host commands; the variable not bound onvexand on the host commands; the closing sentence missing; and the closing sentence on the statement of a vendored PyPI copy. With the product code of the first commit both flows fail on Bazel 9.3.2; that run is from the second commit and was not repeated.apply --vexandvendor --vexof a checkout without a manifest,vendor --vexwith one, andvendor --vexover a hosted pin, which commits a copy again; a hosted scan that pins nothing over a patch agent mode left; a second manifest patch whose package is not installed (the commands pass with the document of the first, andvexreports both as skipped, each under its own code); a patch whose record names no advisory, whereapply --vexgives the same exit code, envelope and lines as in the same checkout withoutMODULE.bazel;vexwith a manifest path in another project, which judges the files of that project in both directions; what a person reads fromapply,vendorand each scan (the warning, the line that the document was written with its count, exit 0), and that--silentprints nothing while the document is written; a hub in an included file; a project below the Bazel root, with its own lock and as a member of a pnpm workspace at the root; the mixed checkout of the example above, wherevexwrites the two statements, reports one package as verified and one as skipped, and words its three lines with(1 affected), andapply --vexcounts one; a checkout with two packages that are patched in their installed copies alone for one advisory, wherevexexits 0 with two statements, one per package, each with the patch of its own package in its action statement, two skipped events and none verified; and seven workspaces in which the statement must staynot_affected(the lock of another project beside, above and below, a hub in a comment, an included file that is missing, aWORKSPACEfile that defines repositories, a hosted pin beside a second hub). At the sixth commit, for the option: in the checkout of the agent flow, where every form saysaffected,vex --no-bazel,apply --vex --vex-no-bazelandscan --mode agent --vex --vex-no-bazel, and the same three withSOCKET_VEX_NO_BAZEL=1in place of the option, give what the same command gives in that checkout without itsMODULE.bazel, with--jsonand without: the exit code, both streams byte for byte, and the document but for its id and its times. Each writes onenot_affectedstatement and exits 0. In the checkout withoutMODULE.bazelthe option changes nothing.bazel::builthas a table per case (the three hubs, installed and vendored, a vendored gem and a vendored npm tarball that are not judged, a file per platform, every label form, a call that may not run in each of four forms, a call withuv_lock,*or**, a pnpm lock of two documents, the members of a pnpm workspace, which locks are opened and how often, several packages of one lock with their own and with a shared patch, each kind of uncertain workspace) and two tests on disk, one for a linked lock, a lock past the bound, a directory and a pending write. The document builder has two tests foraffectedstatements (one per advisory; a statement per affected package after thenot_affectedone of a shared advisory, a package in both sets, a record without an advisory), and the conformance tests ofvex/hold such a statement to its fields: an action statement about one subcomponent, no justification, no impact statement, and a document ofaffectedstatements alone has every required field and reads back as written. The CLI has one test for the step, with both action statements and warnings in full and in the order of the packages, the out-of-sync list, a record without an advisory and a--globalrun; one for the pin files of a vendored package; and one for the count in each line. At the sixth commit the test of the step also runs with the option, where every set the step was given is untouched and nothing is returned or warned of, and the parse tests hold the option onvexand on each ofscan,applyandvendor: the flag, and the variable as1, astrue, empty and unset, with every other field as it was.bazel,vex, pnpm and process tests of the core (1,051) and 73 test targets that exercisevex,--vex, their host commands, the help text and the lists of environment variables pass. One of them,e2e_redirect_gem_stale_install, was run withoutGEM_HOMEandBUNDLE_USER_HOMEin the environment, where it passes 47 of 47; with them two of its hosted gem tests failed in an earlier run, with or without this change. The whole core unit suite (7,994) was last run at the fifth commit; the sixth changes one line of the core, a name in a list. No expectation of a test that exists on the base changed. Two of those tests were touched for a changed signature: the calls ofvex_summary_lines_pluralizegained an argument, and thevexobject ofvex_summary_omitted_when_none_present_when_setgained its new field and two assertions about it. Two comments invex/conformance_tests.rswere reworded (that the builder never writesaffected, and that no two statements share an advisory). The sixth commit adds to tests that exist on the base and changes no expectation of theirs: the parse tests ofapply,scanandvendorthat pass every--vex-*option pass the new one, the table of boolean variables has two more rows, two struct literals of thevexarguments name the new field, and the two parse tests invex.rsare serial, like every test that parses with the environment (the table of boolean variables setsSOCKET_VEX_*while it runs, and in one run here a parse beside it read the value).MODULE.bazelset back before each run, a run without the option moved it, and a run with the option left it where it was (the flag and the variable, onvexand onapply --vex). The file is not opened.Code review
A review of the second commit raised ten points. The third commit answers them; the fourth changes the answer to one.
--cwdwhile the pin files of a vendored copy are from the manifest's project, sovex --cwd app --manifest-path ../svc/.socket/manifest.jsonwould judge the wrong files. It does not happen:vexruns in the manifest's project, andscan,applyandvendorrefuse such a path with--vex. A test runs that command in both directions; it passed on the code as it was, and fails whenvexis kept in--cwd. No product change; the step's docs say why one project is asked about.apply --vexover such a patch alone exits 1 without Bazel; beside a hub it was tagged for Bazel and the command passed with a note that blamed Bazel. The step leaves a patch alone that no run attests, and the run ends as on the base.and, in a conditional or inside another call was judged and named in the warning, although Bazel may never make it. Only a call that is a statement of its own is judged.configDependencieswere listed with the project's. Only the project documents are read, as for the importers.--vex. Not changed here; see Left open.docs/ecosystems.mdlists what remains, per kind.A second review, of the fourth commit, raised ten more. The fifth commit answers them.
affectedand still gotvendored_tree_out_of_sync, which says the attestation is based on the committed copy and to install again, against the statement's own remedy. Such a package gets no such warning. The other notes of a run were checked: the--no-verifywarning counts only the statements of packages still attested as patched, so it never spoke of such a package; the note of a hosted scan is about the scan, not about a package, and stands (see Not covered).vex --jsonreported an unpatched package like a patched one. It was averifiedevent, counted insummary.verified, under the statussuccess: a script that counts verified events, or reads the summary, passed an unpatched build. It is askippedevent with the codevex_bazel_not_in_buildanddetails.status: "affected", counted insummary.skipped; the status ispartialFailure, and the exit code stays 0 whenever the document is written. The lines a person reads count theaffectedstatements, and thevexobject of a host's envelope has the count asaffected, besidestatements.pyproject.tomland its lock whilepip.parsereads a requirements file exported before; an npm package vendored throughpackage-lock.jsonwhilenpm_translate_lockreads apnpm-lock.yaml), Bazel builds the registry's package and the document still saysnot_affected. Not changed: the check of an installed copy cannot be reused as it is. Reading the rulesets shows that the lock a call names does not always decide: rules_js rewrites the pnpm lock from the other files underupdate_pnpm_lock,npm_package_lockoryarn_lock, and rules_python 2.2.0 and later can take the packages fromuv_lock. Both shapes are in the docs' list of what is still wrong, in Not covered and in What follows. The same reading showed that apip.parsecall withuv_lockwas judged by a requirements file Bazel may not take its packages from; such a call, and one that passes*or**, is no longer judged.affectedand the user told to revert a patch that works. A vendored gem is not judged until a real-Bazel flow shows what rules_ruby does with it: the arm was one code line, which is a constant now, 20 lines of unit rows went with it, and the rule for a gem patched in its installed copy stays.pip.parsebreaks the build, and only the document says so. Not changed here:vendorandscanwithout--vexstill exit 0. It is the next pull request (What follows).affectedstatement whose action statement was their texts after one another, each about "this package". Each affected package has a statement of its own.One more thing came up while the three cases above were run by hand: the warnings of several such packages came in the order of a hash map, which changes from run to run. They are in the order of the packages.
Not covered
WORKSPACEfiles. A workspace withoutMODULE.bazelis not read, and one with aWORKSPACEfile that defines repositories is left as it was, although the same two false statements exist there. Many repositories in the middle of a migration have both files. Measured on Bazel 9.3.2, which never reads that file (by hand, not a committed test): beside aWORKSPACEthat calls the same ruleset the build printed the unpatched package while every form wrote thenot_affectedstatement.web/pnpm-lock.yaml), and a pnpm lock above that does not name the project keep theirnot_affectedstatement, also where Bazel builds that package for the project.pyproject.tomland its lock beside a requirements file exported before, an npm package vendored throughpackage-lock.jsonbeside apnpm-lock.yaml. The statement staysnot_affected (vendored)while Bazel builds the registry's package.srcsto where it runsbundle installis read from its source (1.0.0-rc2); no test here builds a vendored gem.npm_package_lock, ayarn_lockor auv_lock. Only thepnpm_lockofnpm_translate_lockand the requirements files ofpip.parseare read. Anpm_translate_lockthat is given one of the other two keeps thenot_affectedstatement, and so does everypip.parsewithuv_lock, also for a patch in the installed copy.-r. A vendored line counts only in a file that thepip.parsecall names. When that file takes the line from another one through-r, the statement staysnot_affected.*or**, also where it does run: a comprehension over a list that is not empty keeps thenot_affectedstatement.not_affected.not_affected.@rules_python//python:extensions.bzlis not known either.--override_repository, an rc file) and BUILD files.requirements_linux.txt, which hosted mode does not rewrite yet, and for a patch the patch service has no hosted artifact of (the hosted scan then says so and pins nothing).affectedstatement, or with several statements for one advisory. Theaffectedones come last so that a reader that keeps the last statement about a product and an advisory keeps one of those; how a given tool reads them is not tested.vex_hosted_unverified). It says so also of a document whose only statement isaffected. That is the scan's own rule, and it is not changed here.pip.parse, which breaks the Bazel build, is then attested asnot_affected (vendored), as on the base: the document does not speak of the Bazel build at all. Nothing checks that the repository does ship the installed tree; the option is the user's word for it, and the document does not record that it was given.vex. On real Bazel onlyvex --no-bazelin the agent npm flow is run.apply --vexandscan --vexwith the option are run without Bazel, for npm.vendor --vex --vex-no-bazelis held by its parse test and by the test of the step, which builds its options as every host command does; no test runs it. The step returns before it looks at a package, so the ecosystem makes no difference, but no test with the option has a PyPI or RubyGems package.bazel::builtand of the VEX step, the parsing tests of the new option, and the targetse2e_bazel_buildande2e_vex_lockfilewithout Bazel. The unit test that reads a lock through a link is Unix-only. 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.Left open
--vexnothing is said. The check runs only while a VEX document is generated.scan --mode vendoredorvendorof a PyPI package underpip.parsestill reports success while the Bazel build fails, and agent mode still patches a copy Bazel does not build without a word. The next pull requests say so in the commands that create that state.bazel::builtrepeats the contained read of the workspace reader with a larger size bound. Another pull request adds that reader's view with a byte bound; whichever of the two lands second replaces the function here by it.What follows
Say it where the state is made: a notice, and declining by default, when vendored or agent mode is about to patch a copy that the workspace's files show Bazel does not build.
Build a vendored gem beside
ruby.bundle_fetchon real Bazel (with and withoutsrcs), and judge it by what that shows.Say
affectedwhile another lock that Bazel reads (above or below the project, a file per platform, a second lock, the lock a hub reads while a vendored package is wired in other files) holds the package without the patch; for that, readuv_lock, and whatupdate_pnpm_lock,npm_package_lockandyarn_lockmake rules_js do.Read
WORKSPACEfiles, with a second code for what cannot be verified, so that an uncertain reading is reported instead of left alone.Decisions for the owner
not_affectedstatement, and a project that Bazel builds from a lock elsewhere keeps a false one until the next pull request. The other choice saysaffectedon any such lock, and takes a true statement from a project with a lock of its own under a root whose lock a hub reads.WORKSPACEfile that defines repositories turns the step off for the whole workspace until those files are read. The other choice is to judge by theMODULE.bazelcall alone, which is right for Bazel 8 and 9 and unproven for Bazel 7 with both systems on.Generated by Claude Code