Skip to content

Stop attesting a Maven module whose own version range keeps the unpatched jar - #2393

Open
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
mainfrom
arch-refactor/2378-maven-hard-range-vex
Open

Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
mainfrom
arch-refactor/2378-maven-hard-range-vex

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code

Fixes #2378.

Problem

Maven reads the version a module declares for a dependency before any <dependencyManagement>. A pin therefore never reaches a module that declares the patched artifact with a version of its own. The reactor planner counted such a module as wired by the pin anyway. Who it hurts: anyone who ships the VEX document.

  • A module that requires the base version as the hard range [1.0]: vendor reports applied, vendor --check says "verified", and vex attests not_affected while the build keeps the upstream jar.
  • A module added under a pinned root after vendoring that declares [1.0] or an open range such as [1.0,2.0): same false statement.
  • The check is shared with hosted mode, so a hosted pin in a reactor was attested the same way.

Evidence on main (1b3f422)

The built binary over the reactor fixture of tests/vendor_jvm_cli.rs, then a real Maven 3.9.11 (dependency:build-classpath, offline) over the same directories.

Project vendor vendor --check vex What Maven builds
aggregator, a declares [1.0] applied, range note verified not_affected a: foo-1.0.jar
a [1.0], b 1.0 applied, range note verified not_affected a: foo-1.0.jar, b: patched
one pom, [1.0] applied, range note verified not_affected foo-1.0.jar
vendored with a 1.0; b [1.0] added after verified not_affected b: foo-1.0.jar
the same, b [1.0,2.0) verified not_affected b: foo-1.0.jar

main already refuses the same requirement when it is written in <dependencyManagement> with a version-less dependency:

$ socket-patch vendor            # exit 1
reason: nothing_wired: no pom of the reactor would build org.example:foo:1.0-socket.1d3c1fd2, so the patch for 1.0 is not applied (reason: range: pom.xml:4: org.example:foo version [1.0] is left as is, probably unpatched)

The five new unit tests fail with main's behavior at the three call sites, and the new CLI test fails against main's binary:

a_hard_requirement_on_the_base_version_is_not_attestable        left: (true, true)   right: (true, false)
hosted_pin_in_a_reactor_module_is_found_and_attested (vex)      left: 0              right: 1      # unattested notes
maven_reactor_declared_range_on_the_base_withholds_vex (CLI)    vendor exits 0 where it must refuse

Fix

One helper in core vendor/jvm/maven_reactor.rs, own_versions: the versions a module declares itself, from the nearest pom on its chain that declares the artifact. Three places ask it:

  1. covers (what vex asks, vendored and hosted): a declared range, the base version, or a version that cannot be read may be the base whatever the management says, so the selection is asked what the module resolves. A declared suffixed version wires the module; another plain version is wired as the management says, as before.
  2. rewrite_declarations: a <dependencies> entry that requires exactly the base version is recorded as a declaration that may still build the base, as an unresolved ${property} already is. vendor --check then warns vendor_jvm_unattested and vex withholds without reading a local repository.
  3. under (where pins go, both modes): a module that requires the base version itself has no say, since no pin reaches it. With nothing else to wire, no pom names the suffixed version, and the existing Vendored Maven reactor reports applied and VEX attests not_affected when a ${property} version is left unresolved, so the build keeps Central's unpatched jar (also triggered by Maven 4 <parent/> inference) #513 refusal applies.

With this branch, same projects:

Project vendor vendor --check vex
aggregator, a [1.0] refused nothing_wired (range reason), nothing written no statement
a [1.0], b 1.0 applied, range note verified, warns vendor_jvm_unattested naming a/pom.xml:6 withheld
one pom, [1.0] refused nothing_wired no statement
b [1.0] added after verified, warns naming b/pom.xml:6 withheld
b [1.0,2.0) added after verified withheld: "b/pom.xml may resolve it unpatched"

Unchanged: a plain 1.0, a module that requires another version ([2.0]), and a range at first vendoring (already withheld).

What was deleted

The old body of covers, which accepted a pin for any module and any suffixed declaration anywhere on the chain.

Behavior change

  • vex withholds the statement for the shapes above, in vendored mode and for a hosted pin in a reactor.
  • vendor --check adds a vendor_jvm_unattested warning for a hard requirement on the base. It still exits 0.
  • vendor (and scan / get --mode vendored) exits 1 with nothing_wired where it exited 0 over a pin nothing reads. That only happens when no module can be wired at all, and it is the refusal main already gives the same range in <dependencyManagement>.
  • A project main already vendored that way keeps its pin: a re-run exits 0 and writes nothing, the check warns, vex withholds, and vendor --revert restores the poms (run with both binaries).
  • Hosted mode writes no root pin for a module that requires the base itself. Alone, such a reactor is left as it is with the range warning, as a single pom already is. A hosted re-scan can now add the selection_undetermined warning for an open-range module under an existing pin (read from the code, not run).

Risk

  • The planner is shared by vendored and hosted Maven. Hosted mode was first run through unit tests only (the planner and VEX discovery). A later run of this routine (2026-12-01, 07:10Z) ran it end to end: the benchmark harness's hosted Maven project against its stand-in patch API, reshaped into each reactor below, with main's binary (1b3f422) and this branch's (24df7b5). vex ran with --no-verify, because the stand-in's packages are on no registry for a real Maven to install.

    Reactor (v is the patched version) main: hosted scan main: vex This branch: hosted scan This branch: vex
    a requires [v] applied: a pin in the root not_affected skipped (redirect_unconfirmed), no pin nothing to attest (exit 2)
    a requires [v], b declares v applied: b rewritten, a pin in the root not_affected applied: b rewritten, no pin withheld (exit 1), names a/pom.xml:11
    a declares [3.0,4.0), b declares v applied: b rewritten withheld the same the same
    a declares v; b added after the scan with [v] applied: a rewritten withheld the same withheld, names b/pom.xml:11
    the same, b with [3.0,4.0) applied: a rewritten withheld the same the same
    one pom that requires [v] skipped, no pin nothing to attest the same the same

    A tree main scanned into the first two rows keeps its root pin under this branch: vex withholds, and a re-scan exits 0, writes nothing and still counts the package as patched ("1 package is already on hosted patches") beside the range warning, as main does. Not changed here.

  • The real-Maven suites were not run here. This PR's CI ran e2e_redirect_maven_build and e2e_vendor_maven_build on Maven 3.9.16 and passed; the Maven version matrix of e2e_vendor_jvm_build (3.6.3 to 4.0.0-rc-7, Windows) is not in a PR's scope. No cfg(windows) or cfg(unix) code changed.

  • Verified here on the final commit: CI's clippy command; core lib (8669 passed); the CLI suites vendor_jvm_cli, cli, in_process_vendor, hosted_memory_engine; and on the commit before it also maven_sidecar_cli, in_process_scan, in_process_get_hosted_ecosystems.

Review

CI passed on 24df7b5 (126 checks) and Cursor Bugbot found no issues. Three passes of /code-review high. The first two each found a real defect in the new helper, both fixed and tested: a version-less entry replaces the one a module would inherit and does read the pin (checked against Maven 3.9.11), and a plain other version under a pin must stay wired when the selection cannot be read. The third found no defect. Left as they are:

  • A module with an open range of its own still has a say in where pins go (it reads as undetermined and holds the poms above it). Pre-existing, placement only, and the contract describes that outcome.
  • [1.0,1.0] is not read as [1.0]. That belongs in the shared range parser, which the selection also reads. The outcome is safe: vex withholds and nothing is pinned.
  • vendor --check does not name a [1.0] that only an inheriting module's property produces, or one in a module's own <dependencyManagement>. vex withholds both through the selection, which the check does not read by design.
  • A hard-range module beside a module whose selection cannot be told yet is refused, not skipped. An unresolved property does the same on main: a declaration passed over for a reason of its own is not "selection alone".
  • The hosted note still advises re-running scan, which cannot clear a declared version. It says the same for the reasons it already carried.

CLI_CONTRACT.md lists the causes of vendor_jvm_unattested in two places and neither names a hard requirement. I left the file alone because two open agent PRs (#2390, #2392) change it; the phrase to add in both is "a hard requirement on the base version ([1.0])". docs/design/maven-vendoring.md has the rule.

For a maintainer, from the issue: [1.0] names one version, so it could instead be rewritten to [1.0-socket.<hex8>], which would patch the module. This PR does not need that answer.

Diff

5 files, +561 −32: production +90 −31 (one file), tests +461, docs +10 −1.

https://claude.ai/code/session_011f9aeQdEz2ykd1n9rvemSh


Generated by Claude Code

Refs #2378.

Assisted-by: Claude Code
@mikolalysenko Mikola Lysenko (mikolalysenko) added arch-refactor PR opened by the scheduled architecture refactor routine refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code labels Dec 1, 2026
Maven reads the version a module declares for a dependency before any
<dependencyManagement>, so a pin does not reach a module that declares
the patched artifact with a version of its own. The reactor planner
counted such a module as wired by the pin all the same. For a module
that requires the base version as the hard range [1.0], vendor reported
the patch applied, vendor --check verified it, and vex attested
not_affected while the build kept the upstream jar. A range added
under a pinned root after vendoring was attested the same way, in
vendored and in hosted mode.

One rule now, in the three places that asked:

- covers: the version a module declares, or inherits, decides whether
  the patch is wired there; the nearest management decides only when
  no entry carries a version. vex then asks the selection what such a
  module resolves, as for a module no pin reaches.
- A hard requirement on the base version is recorded as a declaration
  that may still build the base, as an unresolved property is: vex
  withholds the statement and vendor --check names the declaration.
- under: a module that requires the base version itself has no say in
  where a pin goes. With nothing else to wire the plan names the
  suffixed version nowhere, and vendor refuses it (nothing_wired) as
  it already refuses the same range written in <dependencyManagement>.
  Hosted mode leaves such a reactor alone, as it does a single pom.

A pin an earlier run wrote stays where it is.

Refs #2378.

Assisted-by: Claude Code
Five projects through vendor, vendor --check and vex: a module that
requires the base version as [1.0] alone and beside a rewritten
sibling, and a module added after vendoring that declares [1.0], the
open range [1.0,2.0) or another version. Against main's binary the
first case fails: vendor exits 0 where it must refuse.

Refs #2378.

Assisted-by: Claude Code
Review of the last two commits, checked against a real Maven 3.9.11:
a module that declares the artifact with no version replaces the entry
it would inherit, and reads the management. The helper walked past
that entry to the parent's versioned one, so such a module was counted
as unwired under a pin it does read, and as having no say in where a
pin goes. It now stops at the nearest pom that declares the artifact
at all.

The same review found a pin nothing reads one step further: a module
whose own <dependencyManagement> requires the base version as [1.0]
overrides any pin above it, yet the root was pinned for it and vendor
reported the patch applied. Such a module has no say either; with
nothing else to wire the plan is refused, as it is when the root's own
management carries that range.

Refs #2378.

Assisted-by: Claude Code
A second review found that the new reading of a module's own version
asked the selection too much: a module that declares another plain
version under an existing pin (1.11.0 beside a patch of 1.10.0) builds
that version, and vex attested the patch before. With the reading of
the last commits it asked what the module resolves, and withheld the
statement wherever that cannot be read: no Maven local repository, a
Maven 4 build, a project that is not on disk.

Such a module is wired as the management says again, as on main. Only
a version that may be the base is asked of the selection: a range, the
base version itself, or one that cannot be read.

Refs #2378.

Assisted-by: Claude Code
A third review pass found no defect in the change, and two loose ends.
A module that declares the suffixed version as a hard range by hand,
[1.10.0-socket.<hex8>], builds the vendored jar; the new reading took
it for a range that may be the base, where main counted the module
wired by its pin. It is wired by its own declaration.

The design note said vendor --check names "the declaration"; it names
a <dependencies> entry. A requirement in a module's own
<dependencyManagement> takes no pin, and vex withholds it by what the
module resolves.

Refs #2378.

Assisted-by: Claude Code
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Withhold VEX for a Maven dependency declared as the hard range [1.0] Stop attesting a Maven module whose own version range keeps the unpatched jar Dec 1, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review December 1, 2026 04:50
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Shared vendored/hosted Maven reactor logic changes when patches apply, checks warn, and VEX attests—security-relevant but narrowed to safer outcomes with broad test coverage.

Overview
Fixes #2378 by teaching the Maven reactor planner that declared dependency versions beat <dependencyManagement> pins, so modules that hard-require the base version (e.g. [1.0]) or declare their own range are no longer treated as wired by a root pin.

Core changes in maven_reactor.rs add own_versions, requires_base, and requires_exactly (via VersionRange). covers now defers to declared versions before management; under skips modules that require the base; declaration rewriting records hard [base] requirements as still building the unpatched jar.

Behavior: vendor may exit with nothing_wired when only such modules exist; vendor --check can emit vendor_jvm_unattested naming the offending declaration; vex withholds not_affected instead of false attestation (vendored, hosted reactor, and discovery). Tests and docs/design/maven-vendoring.md document the rule.

Reviewed by Cursor Bugbot for commit 24df7b5. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 24df7b5. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
Maven reads a version a module declares itself before any <dependencyManagement>. Until now, the Maven reactor planner counted a module that declared [1.0] (or a range it added later) as wired by the root pin. As a result, vendor reported "applied", vendor --check said "verified", and vex attested not_affected while the build kept the unpatched jar. With this PR, vex asks what such a module actually resolves, --check warns vendor_jvm_unattested, and a plan that leaves nothing else to wire is refused with nothing_wired.

Risk: medium. It is one production file (+90 −31), but the planner is shared by vendored and hosted Maven. vendor, scan and get --mode vendored now exit 1 where they used to exit 0 over a pin nothing reads. That is the refusal main already gives for the same range in <dependencyManagement>, and it replaces a false VEX claim. Projects that were already vendored keep their pin, and a re-run exits 0. Hosted mode was covered by unit tests only.

Look here

  • [covers](https://github.com/SocketDev/socket-patch/blob/24df7b551f6b61de301d10501200d02aa7b7214c/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L1659-L1675): the new rule for whether a module is wired: own version first, then management.
  • [own_versions](https://github.com/SocketDev/socket-patch/blob/24df7b551f6b61de301d10501200d02aa7b7214c/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L1683-L1703): the nearest pom on the chain that declares the artifact replaces inherited entries. Profiles and management sections are excluded.
  • [under skips requires_base modules](https://github.com/SocketDev/socket-patch/blob/24df7b551f6b61de301d10501200d02aa7b7214c/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L1557) and [requires_base](https://github.com/SocketDev/socket-patch/blob/24df7b551f6b61de301d10501200d02aa7b7214c/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L1708-L1717): where pins go.
  • [rewrite_declarations marks [base] uncertain](https://github.com/SocketDev/socket-patch/blob/24df7b551f6b61de301d10501200d02aa7b7214c/crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs#L3006).
  • CLI test: the end-to-end refusal and withholding.

Verified

  • I read the full diff against main (1b3f422). It has no conflict and leaves CHANGELOG.md untouched.
  • The new tests assert the old false outcomes, so they fail on main's behavior.
  • No cfg(windows) code changed and no paths are built from strings.
  • I ran cargo test -p socket-patch-core --lib -- maven_reactor:: vex::discover::maven:: on 24df7b5: 224 passed.
  • CI on 24df7b5: ci-ok and clippy are green. Cursor Bugbot found no issues, and there are no review threads.

Changes I made: none.

Open questions


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Dec 1, 2026
Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Dec 1, 2026
Three routine PRs are open, so this run verified the five leads
left to verify. L113 is confirmed and filed as #2401. L114 was
already #2337. L115 holds on main and is closed by #2393, whose
body now carries the hosted rows. L116 and L117 are true and
safe: out of charter.

Assisted-by: Claude Code:claude-fable-5-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

2 participants