Skip to content

Test NuGet hosted mode under rules_csharp on real Bazel - #2140

Merged
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
bazel-small/52-nuget-rules-csharp
Nov 19, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
bazel-small/52-nuget-rules-csharp

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

No user-visible change.

What this is

Tests only: the NuGet module of the real-Bazel tests, its fixture and its workflow, and one edit to the shared test harness. socket-patch has no Bazel-specific code for NuGet, and until now no test ran its NuGet rewrite in a Bazel workspace. No file under crates/*/src changes.

The flow holds hosted mode for a package that rules_csharp 0.5.0 reads through nuget.from_lock(packages_lock_json = "//:packages.lock.json", nuget_config = "//:nuget.config") under Bzlmod: the lock dotnet restore writes beside a project, and a nuget.config whose one source is nuget.org. rules_csharp 0.5.0 is the ruleset for Bazel 9.3.2, 8.8.2 and 7.7.2 alike (one fixture era). The fixture's table gives that era to Bazel 7.1.0 and later: the ruleset's hub downloads with block = False, a parameter Bazel has from 7.1.0 (read in Bazel's source at the tags 7.0.0, 7.0.2 and 7.1.0). Only the three releases above ran.

Contents

Lines
Implementation (crates/*/src) 0
Tests: crates/socket-patch-cli/tests/e2e_bazel_build/nuget.rs (947), six lines in harness.rs and one mod line in main.rs 954
Fixture: crates/socket-patch-cli/tests/fixtures/bazel/rules_csharp/bzlmod/{common,e9}, five text files, no binary 65

Plus .github/workflows/bazel-nuget.yml (137 lines), a caller of bazel-compatibility.yml modelled on bazel-npm.yml. The diff is nine files and 1156 added lines. The reusable workflow and the other ecosystems' files are untouched.

  • nuget.rs: the two fixture packages, built per run (a zip of a manifest and one placeholder assembly, no signature); the stand-in for the Socket API, nuget.org's flat container and the Socket source of a patch (service index and flat container); NuGet's global packages folder staged by hand as dotnet restore leaves it; one flow, nuget::hosted_from_lock; two hermetic tests that hold the fixture, the downloader config and the workflow's path lists to the test code.
  • harness.rs, the one shared edit: NETRC joins the variables removed from every Bazel child, and the list of the hermetic test that guards them. Bazel's http_archive and its downloader read the credentials file that variable names, and rules_csharp reads it for every package it downloads. Measured on Bazel 9.3.2 before the edit: with NETRC naming a file that does not exist, the flow failed at its first fetch (a FileNotFoundException in Bazel's own http_archive); with a file that holds a login for 127.0.0.1 and one for api.nuget.org, the stand-in received the loopback login with both package downloads, and not the other one. After the edit the flow passes with NETRC=/nonexistent exported, and the stand-in receives no Authorization header. The edit applies to every ecosystem's flow.
  • Fixture: MODULE.bazel, nuget.config, packages.lock.json, App.csproj and a BUILD.bazel whose consumer is a genrule over @nuget//:<package>, the label a C# rule names in deps. The fixture's assembly is a line of text; the rule writes it into the script it builds. No C# rule is built and no .NET SDK is downloaded.
  • The names of the two packages end in an id made for the run (SP.Victim.R<32 hex>). nuget.org has no scopes, so a name committed here could be pushed there by anyone; a name that is new for every run cannot. The three committed files that name a package hold @RUN@ where a checkout holds that id. NuGet takes no @ in a package id, so the committed project and lock name no package that could exist on nuget.org either. A hermetic test reads every id those files name (the references of the project, the keys of the lock, the label in the BUILD file) and holds each to ending in the placeholder. The lock of a checkout pins bytes the run made, so no cache holds a package under test.

What it proves, and where

One flow, in a fresh output base:

  1. bazel build and bazel run //:consumer print the unpatched marker; the upstream package came from the stand-in.
  2. scan --mode hosted --yes rewrites nuget.config (the Socket source of the patch, ahead of nuget.org) and packages.lock.json (the contentHash of the patched package), and nothing else.
  3. The same two Bazel commands, with no step in between, print the patched marker, which holds an id made for the run. The package came from the stand-in patch host, and Bazel rewrote MODULE.bazel.lock and no other file. The next build changes nothing and a --lockfile_mode=error build passes. A second scan and two vex runs after that change no file of the checkout.
  4. rollback --yes restores the two files byte for byte at once; after the next build every file of the checkout is the one of before and the build prints the unpatched marker.
  5. On a second machine, where the patch host serves other bytes than the grant pins, the build fails in both states the checkout can be in: over the contentHash of packages.lock.json while Bazel's lock is stale (nuget.org is not asked for the package), and over the sha256 in MODULE.bazel.lock once that lock pins the granted package, where Bazel also refuses the copy on nuget.org that the hub tries next.

Run on macOS arm64 at this commit, as the workflow's run step runs it (the ignored tests of the module by exact name, the release required), with a fresh output root and an empty repository cache per row. The last four rows are the other ecosystems' flows, run once because harness.rs changed:

Bazel Tests Result Seconds
9.3.2 nuget::hosted_from_lock pass 14.2
8.8.2 nuget::hosted_from_lock pass 17.3
7.7.2 nuget::hosted_from_lock pass 13.5
9.3.2 go::hosted_go_deps pass 92.0
9.3.2 npm:: (two tests) pass 36.4
9.3.2 pypi::hosted_pip_parse pass 31.4
9.3.2 ruby::hosted_bundle_fetch pass 54.7

The machine was under load from other builds; the NuGet flow took between 12 and 27 s per release over the runs of this review.

Changes that must fail the tests. Before the review, seventeen were tried and each failed at the intended assertion. Fourteen on Bazel 9.3.2: the scan left out; upstream bytes served under the patched name; the second patch host serving the granted bytes, in the first state and in the second state alone; a frozen build while Bazel's lock is current; a build between the rollback and the frozen build; vex first on the machine without the package; the patched package in NuGet's folder before the first vex; the first scan on a machine that has the package; a second scan that rewrites files; vex before any pin; the second tamper build with a lock that does not pin the granted package; the stand-in registry without the upstream package; and the downloader config without the nuget.org rewrite. Three without Bazel: the era table without Bazel 7, the downloader config without block nuget.org, and a placeholder that could be part of a package id. Of those seventeen, only the second scan that rewrites files and the placeholder were run again after the review.

For the review's changes, on the code of this commit, each of these failed at the assertion it is aimed at. On Bazel 9.3.2: the step after the first patched build expecting the unpatched marker; that step given the checkout of before the build (Bazel's lock then changes under it); a rollback run before the check that ends the step; a second scan that rewrites files. Without Bazel: a pattern of the workflow under a directory that does not exist; a file in the fixture that is not text (the message names it); a file in a subdirectory of the fixture that holds the placeholder; an id without the placeholder in the project, in the lock and in the BUILD file, one at a time; a placeholder without @ in the code and the three files; a lock whose pinning changes more than the two hashes; the old order of the un-pinning with a run tag that occurs in a hash; NETRC taken out of the removed variables; and NETRC taken out of the guarding test's list. Two controls passed, as they must: a subdirectory of the fixture with a text file that holds no placeholder, and the new order of the un-pinning with that same run tag.

Linux x86_64 (the CI runner): the flow passed on its first run there, on all three releases (run 44393008302; checks nuget / bazel (9.3.2, e9), (8.8.2, e9), (7.7.2, e9)): 13 s on 9.3.2, 14 s on 8.8.2, 15 s on 7.7.2 of test time, with no cache saved yet. Because this pull request adds one name to the shared harness, the same run covered the Go, npm, PyPI and RubyGems legs as well; all 68 checks pass. The macOS leg has not run on a GitHub runner.

What starts on main

.github/workflows/bazel-nuget.yml calls bazel-compatibility.yml with three Linux legs (Bazel 9.3.2, 8.8.2, 7.7.2) and one macOS leg (9.3.2).

  • On a pull request that touches the workflow itself, the reusable workflow, the Bazel installer or its pins, nuget.rs, harness.rs, the fixture, or one of the NuGet files of the product the flow runs through: formats/nuget/, the NuGet crawler, vendor/nuget_config.rs, vendor/nuget_feed.rs, vex/discover/nuget.rs, the upstream restore of rollback and the hosted scan's NuGet check.
  • On a push to main that touches those, or the root of the test target, the shared engine code (patch/redirect/, hosted/, vex/, the CLI commands), the shared test helpers, the Cargo manifests and lock, or the toolchain files.
  • Nightly at 05:07 UTC and on workflow_dispatch. Only those two runs have the macOS leg, and no other workflow uses that minute.

Every path of both lists names at least one tracked file, and the pull request list is a subset of the push list; a hermetic test holds the subset, every plain path to a file and every pattern to the directory before its first *.

Because this pull request changes harness.rs, which is in the pull request list of every caller, it also starts the Go, npm, PyPI and Ruby legs.

Outside hosts of a leg, beyond what the reusable workflow needs for itself: bcr.bazel.build, github.com and release-assets.githubusercontent.com. With an empty repository cache a leg received 0.7 MB on Bazel 9.3.2, 0.4 MB on 7.7.2 and 13.0 MB on 8.8.2 (macOS arm64, measured before the review, which changed nothing a leg downloads). The rules_csharp archive is 142 kB of that; Bazel 8.8.2 fetches protobuf 29.0 (11.1 MB), rules_python, rules_java and rules_cc for its own modules, as it does in a workspace without rules_csharp. The repository cache of a leg holds 1.1 MB, 13 MB and 0.5 MB. No leg asks nuget.org or the patch host: the test's downloader config sends every URL of api.nuget.org and patch.socket.dev to the loopback stand-in and blocks both hosts.

Not required for merge: no merge_group trigger, and no job is a needs of ci-ok.

Known behaviour the flow records

The first three are gaps of the product, not its contract. The flow asserts them as the release has them, so that the measurement does not drift; the module docs name them under one heading, and each assertion is marked KNOWN GAP in the test with what a fix would change there.

  • Known gap: under Bazel alone socket-patch does not find NuGet packages from packages.lock.json today. It needs a restore record (a folder that an obj/project.assets.json in the checkout names), a packages/ folder of a packages.config project, or NuGet's global packages folder. In a checkout without any of them, on a machine where nobody ran dotnet restore (a runner that only ever runs Bazel), scan --mode hosted --yes exits 0, reports success, finds no package and writes no file: hosted mode does nothing. The flow asserts that. Its patched path exists only because the test then stages the two packages in NuGet's global folder by hand. The other two places are not in the flow; in one-off runs on Bazel 9.3.2 before the review, a checkout whose obj/project.assets.json names a folder with the two packages was scanned and pinned on a machine without a global folder, and a checkout with the packages under packages/ had both found. So today the scan has to run where the project was restored, and the two rewritten files have to be committed.
  • Known gap: vex on the machine that ran the scan exits 1 and writes no document (not_applied) while Bazel builds the patched package. It reads the unpatched copy in NuGet's folder, which is not what Bazel built. On a machine where the folder holds nothing, vex exits 0 and attests the package from the pin in the two files.
  • Known gap: Bazel prints the access token of the grant. rules_csharp asks the Socket source for every package of the lock, at three URLs each. For a package the source does not hold, the stand-in answers 404 and Bazel prints one warning per URL, with the URL of the source, which holds the token. The package then comes from nuget.org as before. The flow asserts the request and the warning for the first of the three URLs.
  • The scan warns redirect_nuget_stale_global_package: the folder still holds the unpatched copy. That is what dotnet restore would go on using; no Bazel build reads it.
  • The scan leaves MODULE.bazel.lock stale, and so does the rollback. A --lockfile_mode=error build fails ("MODULE.bazel.lock is no longer up-to-date") until a build that may update the lock, or bazel mod deps --lockfile_mode=update, has run and the lock is committed. The failure is asserted on the three releases; that bazel mod deps is enough was tried once on each release before the review and is not in the flow.
  • A second scan, as a pipeline runs it, reports the patch applied again and rewrites no file.
  • rollback brings back the two files at once; Bazel's own lock comes back with the next build. rollback also warns reinstall_required, which under Bazel needs no step: the next build is on the upstream package again. The warning is not asserted.

Not claimed

  • What the real patch host answers for a package it does not hold. The stand-in answers 404, and the build goes on to nuget.org. Whether the one working NuGet shape under Bazel works against production depends on that answer, and it was not measured here.
  • Signed packages. Every package on nuget.org is signed, and its contentHash is then not the sha512 of the file; the fixture's packages are unsigned.
  • A real dotnet restore. The folder is staged by hand, and the project's obj directory, which a restore in the checkout also leaves, is not written. A restore of the fixture directory as committed, with its placeholder, was not run either.
  • A C# compile. The consumer reads the assembly that the hub hands to a C# rule; no csharp_library or csharp_binary is built.
  • Vendored and agent mode under rules_csharp, rules_dotnet, a hub without a nuget.config, feeds or local_package_dirs on the tag, and central package management.
  • Windows. Any Bazel release other than 9.3.2, 8.8.2 and 7.7.2: the lower bound 7.1.0 of the fixture's table is read from Bazel's source, and no release between 7.1.0 and 7.7.1 ran. Any rules_csharp release other than 0.5.0.
  • The second tamper state uses the lock the patched build wrote, with the four values of the second patch put in place of the first's. A build cannot write that lock without fetching the granted package, and the repository cache would then hand it to every later build. The build runs with --lockfile_mode=error, so Bazel has to take the lock as current; with the granted bytes served in that state the build passes.
  • A credentials file with a default entry. That such an entry would go to the stand-in like the loopback one is read from Bazel's source, not run. The other ecosystems' flows ran without NETRC set.

Decisions for the owner

  1. The first known gap. A scan in a checkout that only Bazel ever built is a silent no-op with exit 0. Read the packages from packages.lock.json in a later pull request, make the scan say what a Bazel-only user has to do, or leave it?
  2. The second known gap. On the machine that ran the scan, vex withholds a package that the Bazel build has patched, until the upstream copy leaves NuGet's folder. Is that the verdict wanted for a Bazel workspace, or should it be changed in a later pull request?
  3. The third known gap. Bazel prints the Socket source URL, token included, three times for every package of the lock the source does not hold, on every fetch. Accept, or change what hosted mode writes for this ruleset?
  4. Package names per run. If a fixed name is preferred, it needs a reserved prefix on nuget.org.
  5. A C# compile leg (csharp_binary, with the .NET SDK the ruleset downloads) is not here. Add one on one release, or leave the leg without an SDK?
  6. Before the docs call this shape supported: the answer of the real patch host for a package it does not hold.
  7. Size. The test module is 947 lines for one flow. Two parts can go without losing the proof that the build takes the patched package: the second tamper state with its derived MODULE.bazel.lock (about 55 lines) and the test of the workflow's path lists (about 30 lines). Keep them, or cut?

Code review

A review of the commit found ten things. Each was checked by reading, and by a run where one was possible.

  • N1, fixed. The hermetic test un-pinned its lock by replacing the bare run tag first, which also rewrites the tag inside a contentHash. It holds: with the tag RA in place of R1, the hash of SP.Victim.RA contains RA and the old order failed, while today's two hashes happen not to contain R1. The hashes are now put back first, and a comment says why.
  • N2, fixed. The workflow check skipped every path with a *. For a pattern, the directory before its first * now has to exist.
  • N3, fixed in harness.rs, the one shared edit. NETRC is removed from every Bazel child and is in the list of the hermetic test that guards the removed variables. One part of the finding did not hold as written: a login for api.nuget.org in that file does not reach the stand-in, because Bazel looks up credentials by the URL it fetches after the rewrite. What does reach it is the login for the loopback host (measured) or a default entry (read in Bazel's source). The failure with a file that does not exist was reproduced, and is gone.
  • N4, fixed. The fixture check read every entry of common/ as text and panicked on a stray file or a subdirectory. It now walks the regular files at any depth, and a file that is not UTF-8 fails with a message that names it.
  • N5, fixed. The assertion that the placeholder contains @ only restated a constant. The test now reads every id the committed files name and holds each to ending in the placeholder and holding an @.
  • N6, marked and kept. The three outcomes that are gaps of the product (the scan that finds nothing under Bazel alone, vex withholding on the scanning machine, the token in Bazel's warning) are asserted as before. Each is now marked KNOWN GAP in the test with what a fix would change, the module docs name them under one heading, and they come first in the section above.
  • N7, not changed. The caller's pull request list leaves out patch/redirect/mod.rs, where the NuGet rewrite lives. That is the stated policy of every caller: shared engine code runs on the push to main and nightly. The sentence in the workflow's header that says so is still true.
  • N8, left open. frozen_build_fails in nuget.rs is a second copy of the frozen-lock step that pypi.rs and the harness have. Folding them is a harness change of its own.
  • N9, left open. sha256_hex, text and the workflow check are copies of helpers in the sibling modules (ruby.rs, npm.rs, pypi.rs). Same reason.
  • N10, fixed. Step 3 built the patched state three times and ran it twice. The build and run after the first patched build are gone, and the shared step that checks the marker, the unchanged checkout and the frozen lock now runs right after that first build, before the second scan and the two vex runs, as the module docs always had it. The step is four Bazel commands, down from six. The two removed commands took 0.22 s on Bazel 9.3.2, 0.30 s on 8.8.2 and 0.26 s on 7.7.2 in a timed run: about a quarter of a second per leg, less than the run-to-run spread of a leg on this machine.

Generated by Claude Code

socket-patch has no Bazel-specific code for NuGet, and no test ran its
NuGet rewrite in a Bazel workspace. This adds the NuGet module of the
real-Bazel tests, its fixture and its workflow, and makes one edit to
the shared harness: NETRC is removed from every Bazel child (below).
No file under crates/*/src changes.

The flow holds hosted mode for a package that rules_csharp 0.5.0 reads
through `nuget.from_lock(packages_lock_json, nuget_config)` under
Bzlmod, on Bazel 9.3.2, 8.8.2 and 7.7.2. One test,
`nuget::hosted_from_lock`, in a fresh output base:

- builds the workspace and reads the unpatched marker from
  `bazel run //:consumer`; the upstream package came from the stand-in;
- runs `scan --mode hosted --yes`, which rewrites nuget.config (the
  Socket source of the patch, ahead of nuget.org) and
  packages.lock.json (the contentHash of the patched package), and
  nothing else;
- runs the same two Bazel commands and reads the patched marker, which
  holds an id made for the run: the package came from the stand-in
  patch host, and Bazel rewrote MODULE.bazel.lock and no other file;
- runs `rollback --yes`: the two files are the ones of before at once,
  and after the next build so is every file of the checkout, and the
  build prints the unpatched marker again;
- on a second machine, where the patch host serves other bytes than
  the grant pins, the build fails in both states of the checkout: over
  the contentHash of packages.lock.json while Bazel's lock is stale,
  and over the sha256 in MODULE.bazel.lock once that lock pins the
  granted package. There Bazel also refuses the copy on nuget.org,
  which the hub tries next.

Three outcomes the flow asserts are gaps of the product, not its
contract. They are asserted as the release has them, so that the
measurement does not drift; the module docs name them under one
heading, and each is marked KNOWN GAP where it is asserted, with what
a fix would change in the test:

- Under Bazel alone socket-patch does not find NuGet packages from
  packages.lock.json. `scan` finds a NuGet package only where a restore
  unpacked it: a folder that `obj/project.assets.json` records, the
  `packages/` folder of a packages.config project, or NuGet's global
  packages folder. In a checkout without a restore record, on a
  machine whose global packages folder does not hold the package (a
  runner that only ever ran Bazel), `scan --mode hosted --yes` exits
  0, finds no package and writes no file: hosted mode does nothing.
  The flow asserts that case. Its patched path exists only because the
  test then stages the global folder by hand, as a restore leaves it;
  no dotnet runs.
- `vex` on the machine that ran the scan exits 1 and writes no
  document (`not_applied`) while Bazel builds the patched package: it
  reads the unpatched copy in NuGet's folder. Where the folder holds
  nothing, `vex` attests the package from the pin in the two files.
- rules_csharp asks the Socket source for every package of the lock.
  For the package the source does not hold, the stand-in answers 404,
  and Bazel prints a warning with the URL it asked, which holds the
  access token of the grant. The package then comes from nuget.org as
  before.

What the flow asserts beside that, because a user meets it:

- The scan warns `redirect_nuget_stale_global_package`: the folder
  still holds the unpatched copy. That copy is what `dotnet restore`
  would go on using; no Bazel build reads it.
- The scan leaves MODULE.bazel.lock stale, and so does the rollback: a
  `--lockfile_mode=error` build fails ("MODULE.bazel.lock is no longer
  up-to-date") until a build that may update the lock has run.
- A second `scan` reports the patch applied again and rewrites no file.

The names of the two fixture packages end in an id made for the run.
nuget.org has no scopes, so an id that is committed here could be
pushed there by anyone; an id that is new for every run cannot. The
committed project, BUILD file and lock hold `@RUN@` where a checkout
holds that id, and NuGet takes no `@` in a package id, so those files
name no package that could exist either: a hermetic test reads every
id the three files name and holds it to that. The downloader config of
the test sends every URL of api.nuget.org and of patch.socket.dev to
the loopback stand-in and blocks both hosts, so no build asks either.
The lock of a checkout pins bytes that the run made, so no cache holds
a package under test.

The consumer is a genrule over the assembly that the hub's label
(`@nuget//:<package>`, what a C# rule names in deps) hands out. The
fixture's assembly is a line of text, no C# rule is built, and no .NET
SDK is downloaded. With an empty repository cache a run fetched 0.7 MB
on Bazel 9.3.2, 0.4 MB on 7.7.2 and 13.0 MB on 8.8.2, from
bcr.bazel.build, github.com and release-assets.githubusercontent.com
(macOS arm64). The rules_csharp archive is 142 kB of that; Bazel 8.8.2
fetches protobuf 29.0, rules_python, rules_java and rules_cc for its
own modules, as it does in a workspace without rules_csharp.

The fixture has one era, for Bazel 7.1.0 and later: the hub of
rules_csharp 0.5.0 downloads with `block = False`, which Bazel has
from 7.1.0. Only the three releases above ran.

The harness edit. Bazel's `http_archive` and its downloader read the
credentials file that NETRC names, and rules_csharp reads it for every
package it downloads; the harness passed the variable of the caller's
shell on to every Bazel child. With NETRC naming a file that does not
exist, the NuGet flow failed at its first fetch, in Bazel's own
`http_archive` (FileNotFoundException). With a file that holds a login
for 127.0.0.1, the stand-in received that login with each package
download; a login for api.nuget.org in the same file did not reach it.
NETRC now joins the variables removed from every Bazel child, for
every ecosystem's flow, and the hermetic test that guards that list
holds the name.

- crates/socket-patch-cli/tests/e2e_bazel_build/nuget.rs: the packages,
  the stand-in (the Socket API, nuget.org's flat container, the Socket
  source of a patch), the staged packages folder and the flow; two
  hermetic tests hold the fixture, the downloader config and the path
  lists of the workflow.
- crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs: NETRC, in
  the list of what every Bazel child loses and in the list of the test
  that guards it.
- crates/socket-patch-cli/tests/fixtures/bazel/rules_csharp/bzlmod: the
  workspace, with a placeholder where a checkout holds the id of its
  run and the contentHash of its packages.
- .github/workflows/bazel-nuget.yml: three Linux legs on a pull request
  that touches these files or a NuGet file the flow runs through, on a
  main push that also touches the shared engine code, nightly and on
  dispatch; one macOS leg nightly and on dispatch. Not required for
  merge.

Not covered: what the real patch host answers for a package it does
not hold (the stand-in answers 404), signed packages, a real
`dotnet restore`, a C# compile, vendored and agent mode, rules_dotnet,
and a hub without a nuget.config.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only and CI changes with no production src edits; the shared NETRC scrub only affects e2e Bazel harness behavior.

Overview
Adds real-Bazel coverage for NuGet hosted mode when rules_csharp loads packages via nuget.from_lock from packages.lock.json and nuget.config. The new nuget::hosted_from_lock flow (plus hermetic checks on the fixture, downloader rules, and workflow path filters) drives scan, vex, and rollback through stand-ins for nuget.org and the patch host, including frozen MODULE.bazel.lock and tampered-patch failure cases. Fixture work adds a rules_csharp/bzlmod workspace with a genrule consumer so legs need no .NET SDK.

Introduces .github/workflows/bazel-nuget.yml, calling the shared bazel-compatibility.yml for Bazel 9.3.2, 8.8.2, and 7.7.2 (Linux) and 9.3.2 on macOS via nightly/dispatch.

Harness: strips NETRC from Bazel child environments so credential files cannot skew downloads—applies to every ecosystem’s real-Bazel tests when harness.rs changes.

Reviewed by Cursor Bugbot for commit 1b61ea7. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. Adds a real-Bazel end-to-end flow for NuGet in hosted mode under rules_csharp 0.5.0 (nuget.from_lock). It covers scan, the patched build, a repeat scan, vex, rollback and a tamper refusal. It also adds a caller workflow bazel-nuget.yml (Bazel 9.3.2, 8.8.2 and 7.7.2 on Linux, 9.3.2 on macOS, nightly and on path changes) and two hermetic tests. Nothing under crates/*/src changes.

Risk: low. This PR only adds tests. The real-Bazel test is #[ignore], skips when Bazel is absent, and only fails hard when the reusable workflow sets SOCKET_PATCH_BAZEL_E2E_REQUIRED=1. The new workflow is not a required check. The one shared change is that every Bazel child now runs without NETRC; the description reports all Linux Bazel flows green with it.

Look here

Verified

  • cargo check -p socket-patch-cli --tests passes.
  • cargo test -p socket-patch-cli --test e2e_bazel_build: 11 hermetic tests pass and 6 are ignored.
  • The ignored real-Bazel test prints SKIP and passes when Bazel is absent.
  • Every path in the workflow's path lists exists. The workflow mirrors bazel-npm.yml, has contents: read and uses no third-party actions.
  • CI on 1b61ea70f: ci-ok and clippy are green, with no failing checks and no open threads.
  • Real Bazel and dotnet were not run here. For that result I relied on the CI run the description cites.
  • No textual conflict is expected with Test Composer hosted and agent modes under Bazel on real Bazel #2146 or Test Cargo hosted and vendored modes under rules_rust on real Bazel #2147. Those two will conflict with each other in main.rs.

Changes I made: none.

Open questions (the description's "Decisions for the owner"; none blocks merging this test-only PR):

  1. Token in CI logs (item 3). Under this ruleset, a hosted-mode user's Bazel build prints the Socket source URL with its access token on every fetch. This PR pins that as a known gap. Should it be tracked as a product security issue before this setup is documented as supported?
  2. Silent no-op (item 1). In a checkout only Bazel has built, scan --mode hosted exits 0 with success and does nothing. Should a follow-up read packages.lock.json, or at least warn?
  3. Size (item 7). Keep or cut the roughly 55-line hand-derived MODULE.bazel.lock tamper state and the roughly 30-line path-list test?

Generated by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[agent] Reviewed at 1b61ea7. Tests, fixture and workflow only, plus the harness scrubbing NETRC. The flow ran and passed on 7.7.2, 8.8.2 and 9.3.2, asserting exact nuget.config and packages.lock.json contents, the patched marker from the build, and tamper refusal on both contentHash and the MODULE.bazel.lock sha256. Non-blocking: the test pins that vex withholds the patch (not_applied, exit 1) while the global packages folder still holds the unpatched copy, which is a user-facing limitation worth documenting.

Merged via the queue into main with commit 83d2b95 Nov 19, 2026
71 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the bazel-small/52-nuget-rules-csharp branch November 19, 2026 15:00
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.

2 participants