Repository navigation
Attest a Maven patch as affected in VEX where a pinned Bazel hub fetches the jar from its lock - #2236
Conversation
…m its lock Two tests, no product change, that record what socket-patch does today in a workspace where a pinned rules_jvm_external hub (`maven.install(lock_file = "//:maven_install.json", ...)`) fetches an artifact and agent mode patches the jar of that artifact in the Maven local repository: - `maven::an_agent_patch_beside_a_pinned_hub`, on real Bazel: the checkout has a `pom.xml` that declares the artifact, and the jar is in the Maven local repository as a Maven build leaves it. `scan --mode agent --yes` exits 0, puts the patch service's jar in its place and writes nothing into the checkout but `.socket/`; `apply` passes and warns `maven_bazel_hub_unpatched`. `bazel build` and `bazel run //:consumer` print the upstream marker before the command and after it: the hub fetches the jar its lock pins, at the lock's sha256, and no build reads the Maven local repository. - `maven::an_installed_jar_is_attested_beside_a_hub_that_fetches_its_own`, without Bazel: the same step in a checkout whose lock is written by the test, in the format rules_jvm_external 7.2 writes. In both, `scan --mode agent --vex`, `apply --vex`, `vex` and `vex --no-verify` each write an OpenVEX document whose one statement says the artifact is `not_affected`, "Patched via Socket patch <uuid>". That document is false for what Bazel builds. The tests assert it as it is today and mark it KNOWN GAP, with what a fix changes. What the tests share is in the Maven module: step 0 of a flow is split into the layout of the checkout and the ruleset's pin, so that a checkout no Bazel builds in can have the same stand-in, grants and local repository; `Pinned::patches_the_installed_jar` runs the agent step. `Cell::patches_outside` of the harness compares the installed file as bytes, since a jar is no text; the Cargo and NuGet flows call it as before. The real-Bazel flow passes on Bazel 9.3.2 and 7.7.2 (macOS arm64) with no change to the product, in about 20 s each. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hes the jar from its lock Agent mode patches the jar of a Maven artifact where a build tool installed it (the Maven local repository, a Gradle or Coursier cache). In a Bazel workspace a pinned rules_jvm_external hub does not build that jar: it takes the one its lock (`maven_install.json`) pins, at the lock's sha256. `apply` already warns of it (`maven_bazel_hub_unpatched`). The tests of the commit before this one measured the rest on Bazel 9.3.2 and 7.7.2: `bazel build` prints the upstream marker before and after `scan --mode agent`, and `scan --vex`, `apply --vex`, `vex` and `vex --no-verify` each attest the artifact as `not_affected`. That document is false for what Bazel builds. The document now says `affected` of such an artifact, as it does for npm, PyPI, RubyGems, Cargo and NuGet: one statement of the package's own, whose action statement names the lock of the hub, the `maven.install` with its file and line, and the command that patches a pinned hub, `socket-patch get <purl> --mode hosted` at the Bazel root, or with `--mode vendored`. It ends with the `--no-bazel` sentence. The warning is `vex_bazel_not_in_build`, `vex --json` reports a `skipped` event with `details.status: "affected"`, the envelope is `partialFailure`, the exit code is 0, and `--no-bazel`, `--vex-no-bazel` and `SOCKET_VEX_NO_BAZEL` leave Bazel out of the document, all through the code those ecosystems already run. The command comes with a condition, in brackets: "a `maven_bazel_*` warning of that run means that the Bazel build keeps the upstream jar". Hosted and vendored mode write no entry for a hub where they cannot show from the checkout that one works (Bazel before 7.4.0, an unknown release of the ruleset, an rc file, a jar the lock lists under no repository, an isolated `use_extension`). The command then exits 0 with such a warning, and beside a `pom.xml` it has still pinned or vendored the patch for the Maven build, which `vex` attests as `not_affected`. That statement is wrong for the Bazel build. It is the one hosted mode leaves there without an agent patch before it, so it is not new; it is in the docs' list of where the document is still wrong, and the action statement must not send a reader there without a word. Where the answer comes from. The table of hubs in `bazel/built.rs` decides by the project's own lock: where it lies from the project, what it lists, and whether its text names the patch. None of that fits a Maven hub. Its lock is no project's own and never names a patch (the patch of a hub is an entry of the block in the root `MODULE.bazel`), and whether a hub fetches a jar takes what `bazel/maven.rs` already reads for hosted and vendored mode: the tags that make a hub of one name, the lock in format 2 or 3 with its skipped and local artifacts, a `maven.override`, a `maven_install` of a `WORKSPACE` file, the block. A second reader could disagree with that one. So `built::unbuilt` asks `maven::upstream`, new, which reads the hubs once with `Hubs::read` and says for each jar what `Hubs::sure` and the block say: - a pinned hub fetches the plain jar at that version, every hub of the workspace was read, and the block holds no entry for the jar: the hub, for a statement that says `affected`; - anything else: nothing, and the statement stays the one of a project without Bazel. That is a jar no hub fetches, a jar the block patches, and every case in which something was not read: a hub without a `lock_file`, a tag or a lock that cannot be read, a `maven.override` of the artifact, a `maven_install` of a `WORKSPACE` file that Bazel may read, a block that was changed by hand. `Hubs::sure`, not `Hubs::built`, because a block that was changed by hand may still patch the jar, and its entries are not read. So `apply` can warn `maven_bazel_hub_unpatched` (it asks `Hubs::built`) where the document keeps `not_affected`: beside a hub that was not read. The docs say so. The warning and the statement share the check of the block (`Hubs::patches`). Two things follow from taking that reader, and the docs say both: - A `WORKSPACE` file. For the hubs of the table any such file that defines a repository leaves the statement as without Bazel. The Maven reader takes one for a doubt only when it calls `maven_install` or cannot be read, and only while the checkout names no Bazel 9 or later, which is the rule hosted mode writes its entries by. So beside a `WORKSPACE` file that defines other repositories a Maven jar is `affected`. - `m2local`. A lock with it takes a jar that no repository lists from the Maven local repository, at the lock's sha256. Such a jar counts as fetched, and its statement says `affected`: the patched jar does not have that sha256 (read from the ruleset's source at 7.2 and 6.5, not built here). The lock's sha256 is not compared with the patch. `Unbuilt::remedy` is a `String` now, since the Maven command names the package. A hosted or vendored entry of the block keeps its statement: the caller hands over no hosted pin, and a committed copy is not asked about. Nothing is read without a Maven jar among the patched packages, and nothing outside a Bazel workspace. Tests. Unit tests of `maven::upstream` (each case above; another version, a classifier and another packaging of the jar; a block's entry for another version of the artifact; a `WORKSPACE` file without `maven_install`; a jar under `m2local`) and of `built::unbuilt` on disk (the sentence, a project below the Bazel root, a committed copy, the block's entry). The two tests of the commit before now expect `affected` with the action statement. Without Bazel, each of the two modes the statement names is run after agent mode in a checkout of its own: where the command writes its entry it gives no `maven_bazel_*` warning and `vex` then says `not_affected`; in a checkout that names Bazel 7.3.0 it writes none and warns `maven_bazel_release`, and the `not_affected` that `vex` then writes is held as the known limit it is. A second test holds `vex`, with `--no-bazel` and beside four hubs of which nothing is said, to what it gives in the same checkout without `MODULE.bazel` (exit code, both streams, the document), and `apply --vex` to the line a person reads. On real Bazel the flow goes on after the documents: the hosted command pins the Maven build and the hub, the same build prints the marker of the patched jar, and `vex` says `not_affected`. Docs: the Maven cell of "Bazel workspaces: what is supported", the agent paragraph and the last limit of "Bazel workspaces: Maven", the section "Bazel workspaces: VEX" (the table of calls, the kinds of patch, the action statement and its condition, what changes nothing, what is tested, what is still wrong) and the rows `vex_bazel_not_in_build` and `maven_bazel_hub_unpatched` of the CLI contract. Two things that held before are now said. `--vex-no-bazel` is about the document, and what `scan`, `apply` and `vendor` themselves say in a Bazel workspace stays, such as `maven_bazel_hub_unpatched`: a sentence of the docs and of the contract's paragraph on the installed tree is narrowed to that. And a patch is judged only where the run found it in place, so `vex` on a machine whose installed jar is not the patched one ends as it does without Bazel. The Maven workflow names the agent flow and starts its legs on a change to the VEX code and to the two files agent mode patches a jar with. The size budget of `bazel/` follows the code (4006 to 4051 lines). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` and `--vex` say `affected` of a Maven artifact that agent mode patched in an installed jar while a pinned rules_jvm_external hub fetches that jar from its lock. This change makes the statement hold in the cases around it where the document was still false, or said less than socket-patch knows. A patch in any mode. A hub reads no `pom.xml`, no Gradle file and no vendored tree, so a hosted pin or a vendored copy of a Maven or Gradle build is in the Bazel build only through an entry of the block in the root `MODULE.bazel`. Hosted and vendored mode write no entry where they cannot show that one works: they exit 0 with a `maven_bazel_*` warning and pin or vendor for the other build. `vex` then attested that patch as `not_affected` while the hub fetched the upstream jar, and the action statement of an agent patch sent a reader into that state. The Bazel step of `vex` now asks about every Maven patch, also one with a hosted pin or a committed copy, so the document after a command that declined still says `affected`. The statement is one for every mode: "the patch is only in what Maven or Gradle builds from", and "If what you ship is what Maven or Gradle builds and not what Bazel builds, pass `--no-bazel`". The statements of the other ecosystems are word for word what they were, and a hosted pin of another ecosystem is left alone as before. The hub that fetches the jar, not every hub. `maven::upstream` asked `Hubs::sure`, which is the rule for writing an entry: any doubt, also one about another hub, gave nothing. So beside a second hub without a lock `apply` warned that the Bazel build stays unpatched while the document of the same run said `not_affected`. It now asks `Hubs::built`: a pinned hub that was read fetches the jar, and no `maven.override` names the artifact. A block that was changed by hand may hold an entry, so it still gives nothing. An entry of this patch. Any entry of the block for the jar counted as "Bazel builds the patch". The entry of another patch than the one the document attests does not: the statement is `affected`, and names that entry first. Whether Bazel reads `MODULE.bazel`. Nothing is said where the checkout does not show that it does: `.bazeliskrc` or `.bazelversion` names a Bazel before 7.0; neither names a release while a `WORKSPACE` file defines a repository; or an rc file names an option that switches Bzlmod off or drops tags of the root, or cannot be read. Such an option is found on whatever line, so it may hold for one `--config` alone: with it neither the hub nor an entry of the block is certain, which is why an entry of hosted mode is not attested there either. Before, a checkout that switched Bzlmod off got `affected` from a file that Bazel does not read. While a release from 7.0 on is named, Maven keeps its finer rule for a `WORKSPACE` file: a `maven_install` there is another hub, and changes nothing for the hub that was read. What to do. The action statement named `get <purl> --mode hosted` whether or not that command would write an entry. `upstream` now gives the remedy with the hub. Where hosted or vendored mode writes the entry (`Hubs::label` and `settings`, as for a run) it is the command. Where they do not, it is "Hosted and vendored mode write no entry for this hub (`<code>`): <reason>.", with the code and the reason of the warning that the command gives. One helper builds the command for the statement and for the `maven_bazel_hub_unpatched` warning, from the coordinates of the jar: a purl with qualifiers (`?type=jar&...`) no longer puts `?` and `&` into a command for a shell. `"maven.install"` and the sentence moved from `bazel/built.rs` to `bazel/maven.rs` with it. `built::unbuilt` no longer parses the workspace for its table of hubs in a run that has only Maven packages. The hubs and their locks are still read once more than lock discovery reads them for the block: the two are different layers of a run, and a read is one `MODULE.bazel` with the locks it names. Tests. `maven::upstream` has one unit test with a line per case above. Without Bazel, `e2e_bazel_build` runs agent mode and then the hosted and the vendored command in three checkouts: where the command writes its entry (`not_affected` after it), and under Bazel 7.3.0 and beside a second hub without a lock (`affected` before and after, with the code and the reason in the place of the command). It holds the statement of a project without Bazel beside an rc file that names `--noenable_bzlmod` for one config, beside a `WORKSPACE` file with no release named, and under Bazel 6. No existing test expected `not_affected` for a hosted or vendored Maven patch whose hub got no entry: each of them writes the entry, and passes as it was. docs/ecosystems.md, the CLI contract and the line budget of `bazel/` (4051 to 4084 implementation lines) follow. The contract's row of `vex_bazel_not_in_build` no longer says that a `--no-bazel` run reads no Bazel file: the option is about the document, and `apply` still reads the workspace for its own warning. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The path lists of the Maven real-Bazel workflow name the files agent mode patches a jar with, because one of its flows does that. They had `patch/jvm_jar.rs` and `patch/jar_members.rs`. The second calls `patch/jar_manifest.rs`, which was missing, so a change to how the manifest of a signed jar is rewritten did not start the legs. It is in both lists now. Two kinds of entry said nothing: `vex/**` covers `vex/discover/maven.rs` and `vex/discover/bazel_maven.rs`, and in the push list `commands/**` covers `commands/vex*.rs`. They are removed, and the comment says that lock discovery is under `vex/`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`maven::upstream` gave nothing whenever the block of `MODULE.bazel` was changed by hand, because such a block may hold an entry. For a block that can hold one, that check decided nothing: an `override_repo` outside the block as socket-patch writes it is a call the workspace reader does not follow, so no hub is read beside it, and nothing is said of any jar. What the check did decide is a block that overrides nothing any more (its first and its last line, say). That one holds no entry and the hub fetches the upstream jar: `apply` warns `maven_bazel_hub_unpatched` there, and the document said `not_affected`. The check is removed. Such a checkout gets `affected`, and the statement says why no mode patches the hub, in the words of the hosted command's warning: the block was changed by hand (`maven_bazel_unreadable`). The unit test of `upstream` holds both blocks, and the docs and the CLI contract say which one keeps the statement of a project without Bazel. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Implementation routes Maven through Reviewed by Cursor Bugbot for commit 6016a39. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. In a Bazel workspace where a pinned rules_jvm_external hub ( Risk: medium. It changes no file a user's install or build reads. Only the VEX output changes, and it gets stricter: some documents that said Look here.
Verified. I read the diff against the base branch (9 files, +984/−132). Non-Maven purls are left alone ( Changes I made. None. Open questions.
Generated by Claude Code |
socket-patch vexand--vexnow sayaffectedof a Maven artifact whose patch a pinned rules_jvm_external hub of the Bazel workspace does not take: the hub fetches the jar from its own lock, and the block inMODULE.bazelholds no entry of the patch.It builds on the open change that does the same for Cargo and NuGet, and is opened against its branch.
Decisions for the maintainer
pom.xmlor a Gradle file and a copy vendored for such a build are allaffectedwhile a pinned hub fetches the jar and the block has no entry of that patch. So the document after a hosted or vendored command that declined (maven_bazel_*) still saysaffected, where it saidnot_affectedbefore. To reverse: one condition incommands/vex.rs, and that false statement is back.maven_installof aWORKSPACEfile, the statement isaffected, asapplyalready warns there. It staysnot_affectedwhere that hub is in doubt: an override of the artifact, a block changed by hand that still overrides a repository. To reverse: one word inmaven::upstream.MODULE.bazel. That is a named Bazel before 7.0; no named release beside aWORKSPACEfile that defines a repository; and an rc file that namesenable_bzlmodoff or--ignore_dev_dependency, or cannot be read. The last part is not what review asked for (an entry that an rc file switches off should giveaffected). Such an option is found on whatever line, so it may hold for one--configalone, and where it holds it takes the hub out with the entry. Neither is certain, so the statement stays as without Bazel; before, a checkout with Bzlmod off gotaffectedfrom a file Bazel does not read. To getaffectedthere: drop one condition inmaven::upstream.affectedand names that entry: Bazel builds the other patch's jar.affectedtoo, beside a hub that pins the same artifact and version, now in every mode.--no-bazelis its way out.WORKSPACEfile. While a Bazel from 7.0 on is named, Maven keeps its finer rule: such a file changes nothing for a jar that a pinned hub ofMODULE.bazelfetches. Amaven_installthere, also one behind a function of a.bzlfile, which is not seen, is another hub: no mode patches it, and it cannot put the patch into the hub that was read. Where only such a hub fetches the jar, nothing is said.What changes
Agent mode patches no hub, and hosted and vendored mode patch one only where they can show that an entry works. On the base,
vexsaidnot_affectedof such a patch whilebazel buildprinted the upstream jar (measured on Bazel 9.3.2 and 7.7.2; the first commit holds it as tests). Now each advisory of the patch gets a statement of the package's own withstatus: "affected":Where hosted and vendored mode would write no entry, the statement names no command. It gives the code and the reason of their warning:
Everything else is what the other five ecosystems have, through the same code: the warning
vex_bazel_not_in_build, askippedevent withdetails.status: "affected", thepartialFailureenvelope, exit code 0,vex.affected, and--no-bazel. Their statements are word for word what they were.The answer comes from
bazel/maven.rs, the reader hosted and vendored mode write entries by:built::unbuiltasksmaven::upstream, which gives the hub and what to do.Unchanged: an entry of the patch in the block, a jar no hub fetches, a project in no Bazel workspace,
--global, a hosted pin of another ecosystem, and every run without a Maven package.Limits
not_affectedis still written where the hub that fetches the jar is not read with certainty, in the cases of the third decision, and for what the Maven section lists as not seen (a hub of another Bazel module, amaven_installinside a.bzlfunction).vexexits 1 with no document, as without Bazel.m2local) counts as fetched. The lock's sha256 is not compared with the patch.--mode vendoredwrites the entry.--vex-no-bazelis about the document:applyand an agentscanstill warnmaven_bazel_hub_unpatched.Code review
not_affected: fixed.upstreamasksHubs::built, and the block for an entry.not_affectedfor a hosted or vendored Maven patch whose hub got no entry: each writes the entry and passes unchanged.WORKSPACEfile: kept, with the guard of the third decision.?type=jar."maven.install"in two files: fixed, one helper inbazel/maven.rsfor the warning and the statement.patch/jar_manifest.rsadded, three redundant entries removed).--no-bazelrun reads no Bazel file: fixed.What it proves, and where
maven::an_agent_patch_beside_a_pinned_hub, real Bazel: the build prints the upstream marker before and after agent mode; the run,apply,vexandvex --no-verifyeach write oneaffectedstatement; afterget <purl> --mode hostedthe build prints the patched marker andvexsaysnot_affected.e2e_bazel_build/maven.rs: agent mode, then the hosted and the vendored command, in three checkouts. Where the command writes its entry,vexsaysnot_affectedafter it. Under Bazel 7.3.0 and beside a second hub without a lock, the documents areaffectedbefore and after the command, with the code and the reason.vex --no-bazel, three hubs of which nothing is said, an rc file that names--noenable_bzlmod, aWORKSPACEfile beside no named release and Bazel 6 give what the checkout gives without Bazel.maven::upstreamfor each case of the decisions, a purl with qualifiers,m2localand an isolated usage;built::unbuilton disk for a committed copy and a project below the root.What was run, and what was not
Run on macOS arm64 at the final commit:
e2e_bazel_buildtarget with-D warnings;cargo check --workspace --all-targets --all-features.socket-patch-coreunit suite (8547 passed) and the CLI unit suite (1065 passed).e2e_bazel_build(without Bazel),e2e_bazel_maven_beside,cli, the six VEX targets, the fourcli_parse_*ones, the five JVM ones (vendor_jvm_cliamong them),apply,scan,vendor,rollback,repairand the threein_process_*ones.scripts/loc-budget.py(thebazelgroup: 4006 on the base, 4084 now),actionlintand the tool-pin check on the Maven workflow.maven::flows on 9.3.2 and 7.7.2, behind a logging proxy that refuses public Maven repositories; it refused no request.Not run: Linux and Windows; Bazel 8.8.2 and 7.4.0; on real Bazel, a command that declines, a second hub, an rc file and a
WORKSPACEfile;scan --mode hosted --vexbeside a hub that declines; the warning on a terminal at 80, 100 and 120 columns; the test targets that need real package managers, Docker or a public registry; a coverage build.One harness helper changed in the first round:
Cell::patches_outsidecompares the installed file as bytes (a jar is no text). Its Cargo and NuGet callers are unchanged.🤖 Generated with Claude Code