* fix(errors): refuse malformed target bytes as a target, not invalid input parseFailureAnalysisError is the shared owner that turns a byte-format parser's ParseFailure into a public refusal. It mapped malformed and truncated bytes to an AnalysisInputError on the path field. The envelope then reported invalid_request, with inspect_input_contract recovery and "correct the listed fields". The arguments were valid; the target bytes were the problem. Readers that wrap the ParseFailureError in an ArtifactReaderFailure, and ArtifactOperationError reason=malformed, were classified the same way. Add AnalysisMalformedTargetError. It keeps the parser's kind, format, detail, offset and field, and projects as unsupported_target with details.format_failure. Its recovery is to choose another operation or a well-formed copy of the target. Route both parser entry points through it and reclassify ArtifactOperationError reason=malformed. Argument and selection errors (missing files, directories, symlinks, JSON arguments) stay invalid_request. Fixes #14170 * docs(maven): describe duplicate variant names as malformed metadata Duplicate Gradle variant names go through malformedInput, which now reports unsupported_target with details.format_failure: malformed. Point the earlier statement at that section instead of the old invalid_format code. * test(errors): expect malformed-target refusals from CLI byte-format readers Truncated IPS, ELF, PE and shortcut bytes now project as unsupported_target with format_failure=malformed. Update the CLI acceptance cases that still expected invalid_request. * fix(errors): keep a cancelled read a cancellation whatever its abort reason projectOwnedArtifactInputFailure read the reader failure's cause without checking the reader's own reason. A cancelled read carries the caller's opaque abort reason as that cause, so aborting with a ParseFailureError turned the cancellation into a non-retryable malformed-target refusal before the shared cancellation projection ran. Only a reader whose own reason is malformed or truncated now yields a malformed target. The ELF dependency checkpoint cancellation test now also aborts with a parser failure as the reason, through the public provider read. * test(pe): expect malformed-target refusals from the PE filesystem boundaries Short non-PE bytes now refuse the target rather than the request field. The missing-file, directory, symlink and child-path controls keep their caller-input expectations. * fix(elf): refuse malformed ELF note bytes as a target, not invalid input inspect_elf_notes shared this PR's root cause: its parser reported structural violations as a reader "format" failure, which the shared stable-artifact projection treats as a request-field error, so truncated or non-ELF bytes still returned invalid_request. The parser now raises malformed or truncated ParseFailureErrors, which the shared projection reports as a malformed target with format_failure and format facts. Consumers that interpreted the old reader reason now use the parser's facts: debug-link build-id observation keys on ParseFailureError kinds, and binary hardening drops its rewrap of note-parser format failures into BinaryFormatFailure, which the parser's own failure supersedes. * test(errors): own the byte readers' malformed-target projection in one CLI table The PR repeated the same malformed -> unsupported_target mapping in a dedicated CLI test per command and again in each provider's filesystem boundary test. The stable-artifact parser-failure CLI table now owns it: every byte reader it covers (now including ELF dependencies, debug link, unwind ranges and native initializers) refuses a truncated ELF header as a malformed target with operation, path, format_failure, retained file identity and no argument recovery. Removed as redundant with that table: the truncated or non-ELF/non-PE CLI tests for ELF debug link, dependencies, unwind ranges and notes, native initializers, and PE imports and certificates; and the malformed-file blocks in thirteen filesystem boundary tests, which keep their directory, symlink, missing-file and child-path controls. Format specific refusals (a truncated IPS body, a wrong shortcut CLSID, DWARF units) keep their own tests, as do the owner tests in parseFailureAnalysisError and ArtifactOperationFailure. * test(errors): expect malformed target bytes as unsupported_target in acceptance tests The first full acceptance run of this PR found five expectations still asserting invalid_request for target-byte failures: the timing test's truncated ELF, a truncated DTB, duplicate Rust dependency JSON, and PE32 and PE64 load-config images without an MZ header. Assert the unsupported_target code, with format_failure malformed where the non-MZ PE path matches the already-updated PE imports test.
7.0 KiB
Maven POM and Gradle module metadata
inspect_maven_gradle_metadata / inspect-maven-gradle-metadata reports the
coordinates, dependency declarations, BOM or platform notes, and unresolved
property or parent references written in one selected local Maven pom.xml or
Gradle .module file. It reads the file without running Maven or Gradle,
resolving a dependency tree, or contacting a repository.
rea inspect-maven-gradle-metadata /absolute/path/to/pom.xml --json
rea inspect-maven-gradle-metadata /absolute/path/to/demo-1.2.3.module --json
The CLI resolves relative paths against the caller's working directory. MCP requires an absolute filesystem path and preserves that exact selection:
{
"name": "inspect_maven_gradle_metadata",
"arguments": { "path": "/artifacts/pom.xml" }
}
REA classifies files by their content. A Maven <project> uses the Maven POM
namespace or legacy unqualified elements. REA reads structural declarations
in the project's namespace. A Gradle metadata object starts with formatVersion.
Version 1.1 can omit component and variants. For other revisions, REA
also requires a component object or variants array as format evidence.
Gradle Module Metadata 1.1 specification
Observations
The inline Evidence result contains the artifact path, SHA-256, and byte length.
Its parameters retain caller-selected controls. An omitted max_file_bytes
uses the default for execution and stays out of the parameters; an explicitly
selected default remains recorded.
coordinates holds group_id, artifact_id, version, and packaging as
spelled. Missing project coordinates stay null. A ${property} spelling is
kept as written and listed in unresolved; this reader does not interpolate
properties or inherit parent or BOM values. POM text goes through XML
end-of-line handling, as Maven's reader applies it: CRLF and lone CR read as LF.
POM coordinates, parent fields, dependency fields, and property values use
Maven's trimming rules, retaining non-ASCII characters at their edges.
Coordinate, parent, dependency and property values can contain text and CDATA.
REA reports nested elements inside those values as malformed input.
When a parent is declared, omitted project group/version fields point to the
parent as possible sources. An omitted project artifactId is a missing child
coordinate: only group/version coordinates may be inherited.
For a POM, parent records the declared parent coordinates and relative_path
when present. relative_path_declared distinguishes an empty <relativePath/>,
which disables Maven's local parent lookup, from an omitted tag. properties
lists each child of <properties> as its written qualified name and value.
Prefixes remain part of the key: a:revision and b:revision stay distinct
even when both prefixes bind to the same XML namespace URI, and match the
spelling kept in ${a:revision} and ${b:revision} references. URL userinfo
credentials in a property value are removed and value_credentials_redacted
is true; when the credential span cannot be located, value is null.
dependencies comes from the project's <dependencies> list.
dependency_management comes from <dependencyManagement>. A managed
dependency with type pom and scope import is a BOM import
(bom_import: true). Each row keeps scope, type, optional, classifier, and
exclusions as present. optional is the interpreted boolean and
optional_spelling keeps the text as written, so a ${property} value stays
visible and is listed in unresolved with field optional. version_kind
is literal, range, dynamic, property, or missing; dynamic is
Gradle's + prefix (1.+) or a latest.<status> selector
(latest.release).
For Gradle module metadata, gradle records format_version,
created_by_gradle, and each variant's name, org.gradle.category,
org.gradle.usage, available-at coordinates as spelled, and declared
dependency and constraint counts. Nonempty variant names retain their exact
spelling and identify their dependency and constraint rows. Duplicate names
fail as malformed metadata (see below). Variant dependencies are origin
variant-dependencies; dependencyConstraints are origin
variant-constraints. Rich versions keep requires, prefers, strictly,
and rejects. A variant whose category is platform or enforced-platform
marks its constraints platform: true. available-at is not fetched. URL
userinfo credentials in available_at.url are removed and
url_credentials_redacted is true; when the credential span cannot be
located, url is null.
For unfamiliar Gradle format versions with a recognizable metadata structure, REA interprets familiar fields using the 1.1 rules and reports the limitation. Complete byte coverage means the whole file was examined. Declarations specific to an unfamiliar format version may still be unreported.
unresolved names every property reference in the coordinates, packaging, and
each dependency's scope, type, classifier, and optional, plus missing
coordinates that a parent would normally supply and other missing coordinates. These are explicit
unknowns, not guesses.
Limits and failures
The selected file is limited to 1 MiB by default (16 MiB maximum). Exceeding
the budget fails without partial success. Malformed XML or JSON is also
unsupported_target, with details.format_failure set to malformed. A
well-formed document that is not a Maven project or Gradle module metadata file
is unsupported_target without that field. Document type declarations are
unsupported. External entities are not resolved.
A POM is counted as a stream before its document tree is built, and one with
more than 1,048,576 XML nodes (elements, attributes, text, CDATA, comments and
processing instructions) is refused as a resource limit, as is a report above
65,536 dependency and constraint rows, 4,096 Gradle variants, or 65,536
dependency exclusions summed over every row. Each collection is counted before
its report records are built.
Unresolved property-reference and coordinate-gap records share a 65,536-record
allowance. Repeated references within one field are deduplicated in source
order; the same spelling in different fields or rows remains separate evidence.
Variant names repeated across dependency and constraint rows are also limited
to 4,194,304 UTF-16 code units. These fixed parser and report allowances are
separate from the selected file-read budget; raising max_file_bytes does not
raise them.
POM profiles, when present, stay unread and unactivated. Declared repositories
stay unread and are not contacted. Packaging is not defaulted to jar when
omitted. Gradle variant attributes other than category and usage are not
decoded.
Complete coverage means the selected document was read. It does not establish a resolved dependency tree, a repository fetch, or that Maven or Gradle would select the same versions.