Skip to content

A hosted scan suffixes a build plugin's dependency, or writes the Socket repository into a profile, when a plugin's configuration holds a <build> or <profiles> element: applied, then the Maven build fails #2513

Backlog

Description

[agent] Filed by the scheduled architecture refactor routine. Found by running the hosted Maven reader on poms that configure two widely used plugins, with real Maven 3.9.11 and a stand-in patch API. main at cd7c5c5.

Problem

scan --mode hosted reads pom.xml with a flat scanner that closes every element at the next close tag of its name. Its own comment says "none of the elements scanned here nest in themselves". A plugin's <configuration> is free-form XML, and two common plugins use the names the scanner relies on:

  • fabric8's docker-maven-plugin and Eclipse JKube configure an image with <images><image><build>…</build></image></images>, inside the pom's <build>;
  • spring-boot-maven-plugin takes the Spring profiles to run with as <profiles><profile>dev</profile></profiles>, which sits inside the pom's <profiles> when a Maven profile configures the plugin.

The pom's <build> (or <profiles>) then ends, for the scanner, at the plugin's inner close tag. Everything after it is read as live project markup: the <dependencies> of later plugins, and the <repositories> and <dependencyManagement> of later profiles.

The scan exits 0 with status: success, applied: 1 and no warning about it. Then:

  • the build fails, because a plugin dependency was given the -socket.<hex8> version (plugin dependencies resolve from plugin repositories, where the Socket repository is not), or because the Socket <repository> was written inside a profile that is not active;
  • or the project keeps the unpatched jar: when the plugin's entry is the only declaration of the artifact, the scan suffixes it and adds no <dependencyManagement> pin, so the project's transitive copy stays upstream, and vex --no-verify still writes not_affected.

These are the outcomes of #259 (p1, a v5 blocker), cases b and c. Its fix (009dca3, #1327) made the hosted rewriter skip <build>, <reporting>, <pluginRepositories>, <distributionManagement> and <profiles>, and found those sections with this scanner.

Evidence on main

One project, org.slf4j:slf4j-api:1.7.36 patched by a stand-in patch API (the reference grant of e2e_redirect_maven_build: a maven2 override, suffixed version 1.7.36-socket.4d5e6f70). Each control is the same pom without the inner element. mvn validate runs maven-antrun-plugin (bound to validate), which resolves the plugin and the project's dependencies; it succeeded in every project before the scan. After the scan Maven runs with a settings mirror that sends the Socket repository to the stand-in, as the suite does.

socket-patch scan --mode hosted --json --yes --api-url http://127.0.0.1:<port> --org test-org --api-token fake
mvn -B -s settings-socket.xml -Dmaven.repo.local=<m2> validate
Pom The plugin configuration Scan What the scan wrote mvn validate after
direct dependency; maven-antrun-plugin declares the same artifact as a plugin dependency docker plugin, an image with <alias> (control) exit 0, applied: 1 the project's <version>, the <repository> BUILD SUCCESS, the patched jar
the same docker plugin, an image with <build> exit 0, applied: 1 the project's <version>, the plugin dependency's <version>, the <repository> BUILD FAILURE
slf4j-simple brings the artifact in; the plugin dependency is its only declaration control exit 0, applied: 1, redirect_maven_dep_management_added a <dependencyManagement> pin, the <repository> BUILD SUCCESS; dependency:tree shows slf4j-api:jar:1.7.36-socket.4d5e6f70
the same an image with <build> exit 0, applied: 1 the plugin dependency's <version> only, the <repository> BUILD FAILURE; dependency:tree shows slf4j-api:jar:1.7.36
direct dependency; a dev profile configures spring-boot-maven-plugin, a later staging profile has <repositories> <jvmArguments> (control) exit 0, applied: 1 the <version>, a new top-level <repositories> BUILD SUCCESS
the same <profiles><profile>dev</profile></profiles> exit 0, applied: 1 the <version>, the <repository> inside the staging profile BUILD FAILURE (BUILD SUCCESS with -Pstaging)
the first pom, both declarations at ${slf4j.version} control exit 0, applied: 1 the project's <version> as a suffixed literal with its marker comment, the <repository> BUILD SUCCESS
the same an image with <build> exit 0, skipped: 1, redirect_unattributable nothing BUILD SUCCESS, unpatched

The two failures, as Maven prints them:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run (say) on project app: Execution say of goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:3.1.0 or one of its dependencies could not be resolved:
[ERROR] 	Could not find artifact org.slf4j:slf4j-api:jar:1.7.36-socket.4d5e6f70 in central (https://repo.maven.apache.org/maven2)
[ERROR] Failed to execute goal on project app: Could not resolve dependencies for project com.example:app:jar:1.0.0
[ERROR] 	Could not find artifact org.slf4j:slf4j-api:jar:1.7.36-socket.4d5e6f70 in central (https://repo.maven.apache.org/maven2)

The last row is a patch that cannot be applied at all, with a reason and a remedy that fit nothing in the project: "lockfile discovery (what vex, list, rollback and vendor read) cannot attribute that pin to one package version (pom.xml: repository socket-patch-4d5e6f70-… is tied to no dependency (no carries the -socket.4d5e6f70 suffix; a same-GAV repository cannot be attributed to an artifact)), so nothing was changed for it; reconcile the project's lockfiles and re-run". The plan and the check that reads it back disagree about the pom, and the check wins, which is the safe side.

In the fourth row vex --no-verify --product pkg:maven/com.example/app@1.0.0 exits 0 and writes one not_affected statement for pkg:maven/org.slf4j/slf4j-api@1.7.36 ("Patched via Socket patch … (redirected); not verified on disk"), while the project resolves the upstream jar. A verified vex was not run to a conclusion: the stand-in's record did not verify in the control either.

socket-patch rollback exits 0 and returns the pom byte for byte in all three rows whose build fails, so that is the way out today.

The shape is in published poms. io.debezium:debezium-connector-mysql:2.5.4.Final configures five docker images with a <build> each and debezium-connector-postgres:2.5.4.Final one, all inside the pom's <build>; for the scanner that section ends at line 264 of 625 and at line 221 of 346. Neither pom has a <dependency>, <repositories> or <properties> in the part left over, so neither is harmed; a plugin dependency declared after the docker plugin is what it takes.

In the suite. The golden fixture maven/pom/plugin-dependency (the #259 case) with the docker plugin added before maven-antrun-plugin, in input/pom.xml and expected/pom.xml alike:

      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.45.1</version>
        <configuration>
          <images>
            <image>
              <name>example/app</name>
              <build>
                <from>eclipse-temurin:21-jre</from>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>
$ cargo test -p socket-patch-core --test redirect_golden
thread 'redirect_golden_fixtures_match' panicked at crates/socket-patch-core/tests/redirect_golden.rs:127:13:
assertion `left == right` failed: maven/pom/<the new case>: pom.xml byte-mismatch
test result: FAILED. 0 passed; 1 failed

The rewriter suffixes the plugin dependency the fixture expects it to leave alone. The suite passes without the new case.

Where

  • The pairing rule: formats/xml.rs#L95-L127 (elements: "each closed by the next </name>").
  • The sections found with it: formats/maven/mod.rs#L287-L294 (ignored, profiles).
  • What reads through them: the hosted rewriter's index ([patch/redirect/maven_index.rs#L163-L221](https://github.com/SocketDev/socket-patch/blob/cd7c5c56e3e0049a5c06260c354a597b8f07658b/crates/socket-patch-core/src/patch/redirect/maven_index.rs#L163-L221): every <dependency>, the live <repositories> and <dependencyManagement>), the upstream restore, and VEX discovery (parse_pom_with).
  • The reactor planner reads a pom as a tree, with a stack of open elements (Doc::parse in vendor/jvm/maven_reactor.rs), so a nested name cannot end its parent there. Run: the pom of the second row as the one module of a two-pom reactor, scanned from the root: exit 0, applied: 1, the module's <version> suffixed, the plugin dependency left alone, the <repository> in the root pom, and mvn validate is BUILD SUCCESS. So the two readers disagree about one file, and what is hit is a single-pom project with literal versions (a ${property} version goes to the planner too). Vendored mode was not run on these poms.

Why it is in the charter

Planned fix

In formats::xml::elements, pair an open tag with its own close tag by counting the open tags of the same name in between, so a section runs to the close tag an XML parser would give it. About 15 production lines in one function; every reader above takes it. Tests: the pairing in xml.rs; the <build> and <profiles> shapes in formats/maven; the golden case above and one for the profile.

The hosted rewriter's golden fixtures are shared with Socket's backend, whose output must stay byte for byte the same, so the two new cases need a matching change (or a check) in Socket's backend.

Not opened as a PR now: three of this routine's PRs await review.

Not run

  • Vendored mode on these poms; Maven 3.6, 3.8 and 4.
  • A verified vex (above); apply --check has no part in hosted mode.
  • The other names a plugin configuration could repeat (reporting, dependencyManagement, properties, project). Surefire's <configuration><properties> after the inner </build> was run: the scan's result did not change.
  • Real builds of the docker and Spring Boot plugins themselves: neither is bound to a phase in the fixtures, so Maven never loads them.
The fixtures

The poms. com.example:app:1.0.0, jar, one dependency (org.slf4j:slf4j-api:1.7.36, or org.slf4j:slf4j-simple:1.7.36 for the transitive rows). <build><plugins> holds io.fabric8:docker-maven-plugin:0.45.1 with

<configuration><images><image>
  <name>example/app:${project.version}</name>
  <build>
    <from>eclipse-temurin:21-jre</from>
    <assembly><descriptorRef>artifact</descriptorRef></assembly>
    <cmd>java -jar /maven/app.jar</cmd>
  </build>
</image></images></configuration>

(the control has <alias>app</alias> in place of <build>), then maven-antrun-plugin:3.1.0 with an execution in validate (<target><echo message="antrun ran"/></target>) and the plugin dependency org.slf4j:slf4j-api:1.7.36.

The profile rows drop the docker plugin and the plugin dependency and add

<profiles>
  <profile>
    <id>dev</id>
    <build><plugins><plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>3.3.5</version>
      <configuration>
        <profiles><profile>dev</profile></profiles>
      </configuration>
    </plugin></plugins></build>
  </profile>
  <profile>
    <id>staging</id>
    <repositories><repository>
      <id>staging</id><url>https://repo.example.com/staging</url>
    </repository></repositories>
  </profile>
</profiles>

(the control has <jvmArguments>-Dspring.profiles.active=dev</jvmArguments> in place of the inner <profiles>).

The stand-in. A loopback HTTP server with the four routes hosted_maven_common::mount_api mounts (POST …/patches/batch, GET …/patches/by-package/<purl>, POST …/patches/package, GET …/patches/view/<uuid>) and the suffixed jar, pom and .sha1 files under /patch-registry/maven/<token>/<uuid>/maven2. The jar is the upstream one plus a marker member; the pom is the upstream one with <version>1.7.36-socket.4d5e6f70</version> added after </parent>.

The runs. The binary with env -i, PATH, an empty HOME, MAVEN_REPO_LOCAL=<m2>, MAVEN_ARGS="-s <empty settings> -gs <empty settings>", SOCKET_TELEMETRY_DISABLED=1 SOCKET_NO_CONFIG=1 SOCKET_NO_UPDATE_CHECK=1. Maven after the scan: a settings file with one mirror, <mirrorOf>socket-patch-<uuid></mirrorOf>, at the stand-in's repository URL. The profile row's build ran on a local repository without the suffixed copy.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Dec 4, 2026
  2. added a commit that references this issue on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditbugpriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions