Skip to content

Attest a Cargo or NuGet patch as affected in VEX where a Bazel hub builds the package from the lock - #2224

Open
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
bazel-vex/04-cargo-nuget-installed
Open

Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
bazel-vex/04-cargo-nuget-installed

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

socket-patch vex and --vex now attest a Cargo crate or a NuGet package as affected, not as patched, when its patch is only in the copy a package manager installed and a rules_rust or rules_csharp hub of the Bazel workspace builds the package from the project's lock.

Based on main, with main merged in. Agent mode is not supported for a project that Bazel builds, and nothing here changes that: this change only makes the VEX document tell the truth about a patch that was applied that way. Support for projects that Bazel builds is being marked experimental as a whole in #2222.

Decisions for the maintainer

  1. What the document tells the user to run. For a crate: hosted mode, with the note that the crate.from_cargo call has to name the project's cargo config (cargo_config), or vendored mode. For a NuGet package: hosted mode, with the note that the nuget.from_lock call has to name the project's nuget.config (nuget_config). These are the modes that a test of this repository builds patched on real Bazel under each hub, so vendored mode is not named for NuGet. Say if the wording should differ.
  2. A rules_csharp hub with several nuget.from_lock calls is read as one hub for its configs. rules_csharp makes one hub of all the calls: the sources of the last call that has any serve every package, and the first lock that names a package decides its version and hash. So a project patched in agent mode can be built patched through the hosted pin of another project of the same workspace, and affected would be false there (measured on Bazel 9.3.2: the build prints the patched marker). The nuget_config of every call is therefore searched for the patch. The document keeps main's not_affected statement when one of them names the patch, is not a plain label or cannot be read, or when a call passes * or **. The locks are still read one call at a time, and feeds and local_package_dirs are not read. Reading which lock pins the package, the way hosted mode does, would let the document say affected in more of those workspaces. It is more code and I left it out. Say if you want it.
  3. The VEX cells in "Bazel workspaces: what is supported". Cargo goes from "Supported with a hosted or vendored patch" to "Supported". NuGet goes from "Supported with no restored copy on the machine" to "Supported; for a hosted patch, with no restored copy on the machine".
  4. CI. The Cargo and NuGet Bazel legs now also start on a pull request that changes the VEX code, bazel/built.rs or the reader of the workspace files, each named by its path. They stay not required for merge. Each agent flow ends with a build on a second machine, which adds about 30 to 60 s to a Cargo leg and about 6 s to a NuGet leg (macOS arm64).
  5. A NuGet lock below the directory of the run is the project's own. For the other ecosystems a lock below the run is the lock of another project and decides nothing, as on main. A NuGet project is every project file below the directory a command runs in, each with a packages.lock.json beside it, and agent mode, hosted mode and vex already read a solution that way. So a run at the root of a solution says affected when nuget.from_lock names a lock below it. This came out of the review of this change. Say if such a run should keep main's statement instead.

What the code does today

Agent mode patches a crate in the cargo home ($CARGO_HOME/registry/src) and a NuGet package in NuGet's global packages folder. In a Bazel workspace neither copy is built: crate.from_cargo(cargo_lockfile = ...) and nuget.from_lock(packages_lock_json = ...) have Bazel download what the project's lock pins.

The first commit records this on real Bazel, with no product change:

  • scan --mode agent --yes exits 0 with the patch applied.
  • bazel build and bazel run //:consumer print the upstream marker before the command and after it.
  • A second machine prints it too. It is a copy of the checkout without MODULE.bazel.lock and with an empty output base, so its Bazel evaluates the hub anew, and it has the patched cargo home or NuGet folder in its environment. The build right after the command is a warm one and looks at nothing outside the checkout again.
  • scan --mode agent --vex, apply --vex, vex and vex --no-verify each write one not_affected statement.

That document is false for what Bazel builds. For npm, PyPI and RubyGems main already says affected in this situation.

What changes

Cargo and NuGet join the table of hubs in crates/socket-patch-core/src/bazel/built.rs. When a call that is a statement of its own names the project's own Cargo.lock or packages.lock.json in a plain string, and that lock lists the package at the patched version without the patch, the document says affected. For NuGet the project's own lock is also one below the directory of the run (decision 5). The action statement names the lock, the call and its line, and what to run:

Bazel builds this package from Cargo.lock (`crate.from_cargo`, MODULE.bazel:10), 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 (the call has to name the project's cargo config, `cargo_config`), or `socket-patch scan --mode vendored` to commit a patched copy of the crate. If what you ship is the installed tree and not what Bazel builds, pass `--no-bazel` (`--vex-no-bazel` on scan, apply and vendor).

The event (vex_bazel_not_in_build, details.status: "affected"), the partialFailure envelope, the exit code 0 and the --no-bazel switch are main's and are not changed.

What the table holds for the two rulesets:

  • rules_rust: the extension by both files that define it at 0.56.0 and 0.75.0, the tag from_cargo, the attribute cargo_lockfile. From the lock it takes the crates of a registry that no [replace] swaps out, which are the ones Bazel downloads.
  • rules_csharp: the extension as bazel/nuget.rs already names it, the tag from_lock, the attribute packages_lock_json. A packages.lock.json never names a patch (a hosted pin there is a hash), so the nuget_config of every nuget.from_lock call is searched for the id of the patch as well (decision 2). Each call has to give it as one plain label of the main repository, or not at all.

The sentence that says what to run moved from commands/vex.rs into the table, one per hub. For npm, PyPI and RubyGems it is the same bytes as before, and their calls are judged one at a time as before.

Limits

  • The document says affected only where the committed files show it. It keeps main's not_affected statement for:
    • a crate.from_cargo with a cargo-bazel lock (lockfile) or without cargo_lockfile;
    • a workspace in which the nuget_config of any nuget.from_lock call names the patch, is not a plain label or cannot be read, or in which such a call passes * or **;
    • a call that is not a statement of its own, or passes * or **;
    • a lock in another directory than the project's (for NuGet: one that is neither in the directory of the run nor below it);
    • a WORKSPACE file that defines repositories, or a workspace without MODULE.bazel.
  • A Cargo project is judged in the directory of its Cargo.lock. A member of a Cargo workspace whose lock lies above it keeps its statement (see "Code review").
  • The locks of a rules_csharp hub are read one call at a time (decision 2).
  • Agent mode stays unsupported under Bazel. This change only makes the document say so.
  • Everything below ran on macOS arm64. Linux and Windows run in CI.

Contents

Two commits on 52bbeaa95, a merge of main (fab1270fd) and one commit of review fixes: 11 files, +1287 / -192 against main. The merge had two conflicts: the RubyGems row of the support table is main's and the VEX cells of Cargo and NuGet are this change's; the bazel line budget is the count of the merged tree.

  1. Tests only. One real-Bazel flow per ecosystem that records today's behaviour, the shared helpers Cell::patches_outside and Cell::builds_anew in the harness, and the two workflows.
    • tests/e2e_bazel_build/cargo.rs +176 / -30, nuget.rs +180 / -23, harness.rs +58 / -0
    • bazel-cargo.yml +25 / -18, bazel-nuget.yml +36 / -25
  2. The product change, with tests and docs.
    • bazel/built.rs +422 / -43: +144 / -35 outside its tests (251 to 317 code lines), +278 / -8 unit tests
    • commands/vex.rs +14 / -13, no more code lines
    • bazel/cargo.rs +1 / -1 (one constant becomes visible to the table)
    • tests/e2e_bazel_build/cargo.rs +122 / -28, nuget.rs +123 / -23, harness.rs +38 / -0 (Cell::keeps_its_statement, the body the two tests without Bazel share)
    • docs/ecosystems.md +64 / -24, CLI_CONTRACT.md one row
    • bazel-cargo.yml +18 / -5, bazel-nuget.yml +9 / -5
    • scripts/loc-budget.json: bazel/ 3615 (main) to 3681 after the merge
  3. The review fixes (see "Code review").
    • bazel/built.rs +74 / -32: +67 / -31 outside its tests, +7 / -1 unit tests
    • docs/ecosystems.md +10 / -5, CLI_CONTRACT.md one row, one comment in tests/e2e_bazel_build/nuget.rs
    • scripts/loc-budget.json: bazel/ 3681 to 3704

One existing unit test changed: the_workspace_of_a_project_on_disk_is_read took a Cargo purl as its example of a package with no hub. Cargo has a hub now, so it takes a Go module. No assertion of the hosted and vendored flows of either ecosystem is edited.

What it proves, and where

Real Bazel 9.3.2, 8.8.2 and 7.7.2 on macOS arm64, run the way the workflow's run step runs it. Cargo with rules_rust 0.75.0 (Bazel 9 and 8) and 0.56.0 (Bazel 7), NuGet with rules_csharp 0.5.0.

Test 9.3.2 8.8.2 7.7.2
cargo::agent_from_cargo_with_config pass pass pass
cargo::hosted_from_cargo_with_config pass pass pass
cargo::hosted_from_cargo_without_config pass pass pass
cargo::vendored_from_cargo_with_config pass pass pass
nuget::agent_from_lock pass pass pass
nuget::hosted_from_lock pass pass pass
nuget::hosted_no_config pass pass pass

A Cargo leg takes 170 to 196 s and a NuGet leg 18 to 20 s.

In the two agent flows the build prints the upstream marker before and after scan --mode agent, and on the second machine. The run, apply, vex and vex --no-verify each write one affected statement, and vex --no-bazel writes one not_affected statement. On Bazel 7.7.2 the patched crate is the copy the hub's own cargo unpacked in the cargo home.

Other checks:

  • The first commit alone, on main's product code: both agent flows pass on Bazel 9.3.2 with the not_affected expectation (NuGet in 14 s, Cargo in 92 s with an empty repository cache), and the tests without Bazel pass.
  • Without the product change (a binary built from main's product code): both agent flows fail on Bazel 9.3.2, and the four new tests without Bazel fail.
  • Two nuget.from_lock calls on Bazel 9.3.2 (a run that is not a committed test): two projects under one root, the hub reads b with its lock and config, then a with its lock. After scan --mode hosted in b the build prints the patched marker. After scan --mode agent in a, vex in a exits 0 with one not_affected statement, and the build still prints the patched marker. A unit test and a test without Bazel hold the same state.
  • No change elsewhere. The head binary and a binary of main's product code were run in the same checkouts, in 13 states: with --no-bazel beside the hub, under hubs that decide nothing (one over another directory's files, a cargo-bazel lock, a config that is not written out, a second NuGet call whose config names the patch, is computed or is passed with **), under a WORKSPACE file alone, and without a Bazel workspace, for Cargo and for NuGet. The exit code, both streams with and without --json, and the document without its id and times were equal every time.
  • Each new assertion guards a line. Five single-line changes of the hub reading were tried at the final head (the count of configs, the */** check, only the first config searched, the doubt check of the two extension files, the */** check applied to every hub), and each fails a test. Thirteen others were tried before the last change to that function.
  • Suites. The core unit suite (8411), the CLI unit suite (1058) and the hermetic VEX test targets (cli, cli_parse_vex, e2e_bazel_build, e2e_bazel_maven_beside, e2e_embedded_vex, e2e_vex, e2e_vex_lockfile, e2e_vex_redirect, e2e_vex_vendor, spawn_env_hygiene, vex) pass. So do both clippy runs, cargo check --all-targets --all-features, the script tests, actionlint and the tool-pin check on the two workflows.

After the merge of main (the tree the pull request shows): cargo check on all targets, both clippy runs, the Bazel and VEX unit tests (1,080 in core, 51 in the CLI), the hermetic VEX test targets named above and e2e_bazel_build without Bazel pass; on real Bazel 9.3.2, nuget:: passes 3 of 3 and cargo:: 4 of 4. Bazel 8.8.2 and 7.7.2 were not run again after the merge; the CI legs run them.

After the review fixes (the head): cargo check on all targets, both clippy runs, the Bazel and VEX unit tests (1,080 in core, 51 in the CLI), the test targets cli (118), e2e_bazel_build without Bazel (69, 30 ignored), e2e_bazel_maven_beside (24), e2e_vex (28) and vex (29), the script tests (423) and the line budget pass. On real Bazel 9.3.2 nuget:: passes 3 of 3 (20 s). cargo:: was not run on real Bazel again after the fixes: the machine was at its free-disk limit, and a Cargo leg takes about 3.6 GB at its peak. The tests without Bazel hold the Cargo documents on the head, and the CI legs run all three releases.

Not covered

  • Whether a hub takes a hosted pin of the project itself. Hosted mode decides that on main; a package with a hosted pin keeps its statement here.
  • A vendored NuGet package: the build is known to fail, no test builds it, and the statement stays not_affected. The VEX section lists it.
  • A rules_csharp hub in which the lock of another call comes first and names the package at another version, a call with feeds or local_package_dirs, and nuget.from_lock calls of another Bazel module of the build. There the document can say affected and name this project's lock while the hub builds something else.
  • A rules_csharp hub in which another call's config names the patch while this project's lock comes first. By the ruleset's source the build then fails on the hash; it was not built here, and hosted mode writes no such pin. The document says not_affected there, as on main.
  • The two-call state on Bazel 8.8.2 and 7.7.2: it ran on 9.3.2 only.
  • A run of the command in a solution whose only lock is below the directory of the run: a unit test of the hub table holds the answer, and no test runs the command in that layout.
  • Crates that come through crate.from_specs, through a crates_repository of a WORKSPACE file, or from a hub with a cargo-bazel lock.
  • The VEX cells of Go, Composer and Maven, which keep their conditions.
  • The real-Bazel flows of npm, PyPI and RubyGems were not run again, although the function that reads the table is shared. Their unit tests and their tests without Bazel pass, and a unit test holds that their calls are still judged one at a time.
  • Linux and Windows: nothing ran there locally.

Code review

A review of the diff against main gave eight findings. Each was checked against the code.

Fixed in the last commit:

  • A NuGet lock below the directory of the run decided nothing. nuget.from_lock(packages_lock_json = "//src/App:packages.lock.json") with a run at the root of the solution kept not_affected, although agent mode, hosted mode and vex treat every lock below the run as the project's. The NuGet hub now takes a lock at or below the directory of the run (decision 5). A unit test holds the root of the solution, a directory beside the lock, one below it and one whose name only starts the same.
  • Whether every nuget_config is a plain label was a comparison of two counts: the labels that resolve and the calls that give the attribute. A dict counts once as given and once per key as resolved, so the counts could be equal while a config was not read. Each call is now asked on its own: no nuget_config, or one string that names a file of the main repository. rules_csharp takes no dict there, so no workspace that Bazel loads changes. A unit test holds a call with a one-key dict, which the counts let through.
  • The attributes that make a call take its packages from a file that is not read (uv_lock, lockfile) were one list for every hub. Each hub has its own now. No ruleset here has the other's attribute, so nothing changes for a workspace that Bazel loads, and no test was added.
  • The configs of a rules_csharp hub were read again for every lock. They are read once for the hub, when the first lock asks.

Without the first two fixes their assertions fail (tried on the final tree).

Not fixed:

  • A run in a member of a Cargo workspace keeps not_affected, because the Cargo.lock lies above it. A Cargo.lock does not say which directories its workspace has, so taking it for the lock of a member means reading the workspace's manifests (the member globs, exclude, a member with a lock of its own). That is a change of its own. Hosted and vendored mode refuse to run in a member and name the workspace root, where the document is right. "Limits" names the case, and the list of statements that stay wrong in docs/ecosystems.md names it now too.
  • A hub with a cargo-bazel lock (lockfile) is passed over while the Cargo cell of the table says "Supported". Such a hub builds what that file names until a repin, and nothing holds it to Cargo.lock, so saying affected there takes reading that file. The legend of "Supported" for VEX sends the reader to the VEX section for the limits, and that section names this one, as it names npm_package_lock, yarn_lock and uv_lock for the hubs whose cell says the same.
  • The sentence that says what to run is the same whatever the call has. It says what hosted mode needs of the call, which holds whether or not the call has it. Hosted mode reads the call itself and says so in a warning of its own when the attribute is missing. Working it out here would repeat that reading. The wording is decision 1.
  • A change to any VEX file starts every Cargo and NuGet leg on a pull request. The npm, PyPI, RubyGems and Go workflows on main list the same paths for the same reason: each agent flow holds the exact document. The legs are not required for merge.

🤖 Generated with Claude Code

…om the lock

Two flows on real Bazel, tests only, that record what socket-patch does
today in a workspace where a ruleset builds a package from the project's
lock and agent mode patches the copy a package manager unpacked outside
the checkout:

- `cargo::agent_from_cargo_with_config`: rules_rust's
  `crate.from_cargo(cargo_lockfile = "//:Cargo.lock", ...)`, and the crate
  in `$CARGO_HOME/registry/src`, as after `cargo fetch`.
- `nuget::agent_from_lock`: rules_csharp's
  `nuget.from_lock(packages_lock_json = "//:packages.lock.json", ...)`, and
  the package in NuGet's global packages folder, as after `dotnet restore`.

In both, `scan --mode agent --yes` exits 0 with the patch applied to that
copy and writes nothing into the checkout but `.socket/`, and `apply`
passes. `bazel build` and `bazel run //:consumer` print the unpatched
marker before the command and after it: each hub has Bazel download the
package the lock pins, and no build reads a cargo home or NuGet's folder.
The build right after the command is a warm one, which looks at nothing
outside the checkout again, so each flow ends with a build on a second
machine: a copy of the checkout without `MODULE.bazel.lock` and with an
empty output base, whose Bazel has the patched cargo home or NuGet folder
in its environment and evaluates the hub anew. It prints the unpatched
marker too.

Meanwhile `scan --mode agent --vex`, `apply --vex`, `vex` and
`vex --no-verify` each write an OpenVEX document whose one statement says
the package is `not_affected`, "Patched via Socket patch <uuid>". That
document is false for what Bazel builds. The flows assert it as it is
today and mark it KNOWN GAP, with what a fix changes in the test.

The copy in the cargo home is the one the hub's own cargo unpacked there
where the ruleset runs that cargo with the home of the environment
(rules_rust 0.56.0), and is laid out by the test where it does not
(0.75.0); NuGet's folder is laid out as the hosted flow already does. No
cargo and no dotnet runs. The Bazel commands of the NuGet flow get the
two variables of the .NET home that `socket-patch` gets
(`NUGET_PACKAGES`, `DOTNET_CLI_HOME`), so a build that read the folder
would find it.

What the flows share is in the harness: `Cell::patches_outside`, and
`Cell::builds_anew` for the second machine, which removes the first
workspace copy before it builds where the repository cache outlives
that copy. The grant helpers of the two modules are split so that a
patch record can carry the file contents agent mode patches from, and
in the Cargo module the helper that names the hosts of a child takes its
cargo home as well; the hosted and vendored flows call them as before
and assert what they asserted.

The two workflows say that their legs now run agent mode, and start on a
pull request that changes the VEX code (`vex/` of the core, the `vex`
command) or, for NuGet, agent mode's own file.

Both flows pass on Bazel 9.3.2 (macOS arm64) with no change to the
product: NuGet in 14 s, Cargo in 92 s with an empty repository cache.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ilds the package from the lock

Agent mode patches a crate in the cargo home (`$CARGO_HOME/registry/src`)
and a NuGet package in NuGet's global packages folder. In a Bazel
workspace neither copy is built: rules_rust's
`crate.from_cargo(cargo_lockfile = ...)` and rules_csharp's
`nuget.from_lock(packages_lock_json = ...)` have Bazel download what the
project's lock pins. The flows of the commit before this one measured it
on Bazel 9.3.2: `scan --mode agent` exits 0 with the patch applied,
`bazel build` prints the upstream marker before and after, also on a
second machine that evaluates the hub anew, and `scan --vex`,
`apply --vex`, `vex` and `vex --no-verify` each attest the package as
`not_affected`. That document is false for what Bazel builds.

Cargo and NuGet join the table of hubs in `bazel/built.rs`, so what main
does for npm, PyPI and RubyGems holds for them too. When a call that is
a statement of its own names the project's own `Cargo.lock` or
`packages.lock.json` in a plain string, and that lock lists the package
at the patched version without the patch, the document says `affected`
of the package, with an action statement that names the lock, the call
and its line, and what to run. `vex --json` reports a `skipped` event
with `vex_bazel_not_in_build` and `details.status: "affected"`, the
envelope is `partialFailure` and the exit code is 0, as on main.
`--no-bazel` / `--vex-no-bazel` / `SOCKET_VEX_NO_BAZEL` leaves Bazel out
of it.

What the table holds for the two:

- rules_rust: the extension by both files that define it at 0.56.0 and
  0.75.0 (the constant of `bazel/cargo.rs`), the tag `from_cargo`, the
  attribute `cargo_lockfile`. Of the lock, the crates of a registry that
  no `[replace]` swaps out: those are the ones Bazel downloads. A call
  with a cargo-bazel lock (`lockfile`) is passed over, because the hub
  renders its crates from that file until a repin. So is one without
  `cargo_lockfile`, which names no lock.
- rules_csharp: the extension as `bazel/nuget.rs` names it, the tag
  `from_lock`, the attribute `packages_lock_json`. A `packages.lock.json`
  never names a patch (a hosted pin there is a hash), and rules_csharp
  0.5.0 makes one hub of all the `nuget.from_lock` calls: the sources of
  the last call that has any serve every package, and the first lock
  that names a package pins it. So a project patched in agent mode can
  be built patched through the hosted pin of another project of the
  workspace (measured on Bazel 9.3.2 with two calls). The `nuget_config`
  of every call is therefore searched for the id of the patch together
  with the lock. Where one names it, or is not a plain label, or cannot
  be read, or a call passes `*` or `**`, nothing is said of the hub. The
  locks are still read one call at a time, and `feeds` and
  `local_package_dirs` are not read.

The action statement names the modes that a flow of this repository
builds patched on real Bazel under that hub, so a hub carries its own
sentence: hosted mode with the attribute it needs of the call
(`cargo_config`, `nuget_config`), and for a crate vendored mode as well.
The sentence of the three hubs on main is the same bytes as before, and
their calls are judged one at a time as before.

Left as main has them: a hosted pin (the caller hands none over, and
whether a hub takes one is for `bazel/cargo.rs` and `bazel/nuget.rs` to
say), a vendored crate (rules_rust builds it), a vendored NuGet package
(no test builds one under its hub), a project whose lock no call names,
a workspace that is not read with certainty, and a project in no Bazel
workspace.

Tests: unit tests of the table (what a lock lists, which calls are
passed over, the hub of several `nuget.from_lock` calls, a doubt on the
hub by either file of the rules_rust extension, the sentence of each
hub). Two tests without Bazel per ecosystem run the binary in a checkout
of the fixture: one runs the scans the action statement names and holds
the document after each to `not_affected`; the other holds `vex`,
wherever the hub decides nothing and with `--no-bazel`, to what it gives
in the same checkout without its `MODULE.bazel` (exit code, both
streams, the document), through `Cell::keeps_its_statement` of the
harness. For NuGet one of those hubs has a second call whose
`nuget_config` names the patch. The two agent flows now expect
`affected` from the run, from `apply`, from `vex` and from
`vex --no-verify`, and `not_affected` from `vex --no-bazel`, while the
build still prints the upstream marker, on the second machine too. No
assertion of the hosted and vendored flows is edited. One existing unit
test took a Cargo purl for a package of no hub; it takes a Go module
now.

Docs: the VEX cells of Cargo and NuGet in "Bazel workspaces: what is
supported", the section "Bazel workspaces: VEX" and the
`vex_bazel_not_in_build` row of the CLI contract. The two workflows
start their legs on a change to `bazel/built.rs` and to the reader of
the workspace files, each by its path. The size budget of `bazel/`
follows the code (3337 to 3403 lines).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained the gem_checksums withhold and the Maven scan of a pinned
hub. Two conflicts:

- docs/ecosystems.md, the table of "Bazel workspaces: what is
  supported": main's RubyGems row (its hosted cell names the
  gem_checksums conditions) with this branch's VEX cells for Cargo and
  NuGet.
- scripts/loc-budget.json: the cap of the `bazel` group is the count of
  the merged tree, 3681.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he Bazel VEX answer

A NuGet project is every project file below the directory a command runs
in, each with a `packages.lock.json` beside it: agent mode patches what
any of them restored, and hosted mode and `vex` read a pin in each of
their locks. The hub table took only the lock in the run's own directory
for the project's, as it does for the other ecosystems. So for a run at
the root of a solution, where `nuget.from_lock` names
`//src/App:packages.lock.json`, the document kept `not_affected` for a
package that Bazel downloads unpatched. The NuGet hub now takes a lock
at or below the directory of the run. The other hubs are as they were:
a lock below the run is still the lock of another project there.

Three smaller changes to the same function, none of which changes what
is said of a workspace that Bazel can load:

- Whether every `nuget_config` of the hub is a plain label was a
  comparison of two counts: the labels that resolve, and the calls that
  give the attribute. A dict counts once as given and once per key as
  resolved, so the counts could be equal while a config was not read.
  Each call is now asked on its own: no `nuget_config`, or one string
  that names a file of the main repository.
- The attributes with which a call can take its packages from a file
  that is not read (`uv_lock`, `lockfile`) were one list for every hub.
  Each hub now has its own.
- The configs of a rules_csharp hub were read again for every lock. They
  are read once for the hub, when the first lock asks.

The docs and the contract row say which lock is the project's own for
NuGet, and the list of statements that stay wrong names the member of a
Cargo workspace, whose `Cargo.lock` lies above it.

The `bazel` line budget is the new count, 3704.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 24, 2026 21:33
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes VEX attestation and Bazel workspace interpretation for Cargo/NuGet, which affects compliance documents and user-facing remediation; mitigated by extensive e2e and unit tests.

Overview
VEX and --vex now treat agent-mode Cargo and NuGet patches as affected when a Bazel hub (rules_rust crate.from_cargo or rules_csharp nuget.from_lock) builds from the project lock and that lock does not name the patch—the same behavior npm/PyPI/Ruby already had.

bazel/built.rs grows from three to five hub types, with lock/config parsing (including nested NuGet locks and combined nuget_config search across nuget.from_lock calls). Unbuilt carries per-hub remedy text used in action statements and warnings (vex_bazel_not_in_build).

E2E: new real-Bazel agent flows for Cargo and NuGet, plus harness helpers (patches_outside, builds_anew, keeps_its_statement). CI path filters on bazel-cargo / bazel-nuget workflows now include VEX and bazel/built.rs so document wording changes re-run those legs. Docs (ecosystems.md, CLI_CONTRACT.md) and the bazel loc budget are updated accordingly.

Reviewed by Cursor Bugbot for commit 5a5cdc4. Configure here.

…gnore line

`cargo::vendored_from_cargo_with_config` comments out the line the scan
wrote in `.bazelignore` and expects `bazel cquery //...` and
`bazel query 'deps(//...)'` to fail on a repository that the main
repository does not see. It looked for the hub's repository
(`@crates__...`) alone. The build file that cargo-bazel writes into the
committed copy names `@platforms` as well, and Bazel reports the first one
it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms`
and the flow failed on its own check.

The flow now takes either name for that failure. Test only: nothing the
command does changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant