Repository navigation
feat(artifacts): inspect Debian package control metadata and contents - #10689
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The latest changes appear safe to merge; the remaining counting finding is fixed. SummaryAdds local Debian package inspection through CLI and MCP, with control metadata, file inventory, bounded decompression, and typed refusals that retain partial facts.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["CLI / MCP"] --> B["Shared inspection service"]
B --> C["Stable local file read"]
C --> D["ar members"]
D --> E["Bounded tar decompression"]
E --> F["Control metadata and file inventory"]
F --> G["Evidence"]
E --> H["Typed refusal with partial facts"]
G --> I["Retained summary view"]
Reviews (60) · Last reviewed commit: "refactor(deb): avoid throwaway filter ar..." · Reviewed by Greptile |
…unts DebPackageFormatFailure now extends ParseFailureError, as the architecture guard requires of parser failure classes; its kind, partial and message are unchanged. The advertised-dialect baseline takes the counts the inspect_deb_package input schema adds ($schema in both profiles, and allOf, default, examples, the \/ escape, the unanchored path pattern and untyped nodes in the full profile).
|
44e6f9c addresses the two red CI lanes: |
dpkg-deb only reads the archive; installing with dpkg is what runs the maintainer scripts. Correct the spec so the safety rationale names the right tool.
The provider now maps DebPackageFormatFailure with the shared parseFailureAnalysisError instead of its own instanceof ladder, passing the partial ar/control/data observation as diagnostics. The helper takes that optional diagnostics argument. DebPackageCapacityFailure extends ParseFailureError<"limit"> with the resource and maximum as its limit, and the provider keeps its limit recovery.
Resolve parseFailureAnalysisError: keep main's field parameter and add the optional diagnostics argument after it; the deb provider passes "path".
|
eb62c98 merges current main. The one conflict was |
The CLI acceptance and MCP boundary tests now take the contract from DEB_PACKAGE_TOOL_CONTRACTS instead of the full catalog, as the testing guide asks of focused contract tests.
Coverage was complete with a missing or empty debian-binary, or a control.tar that held no control file. It now needs a known format version and the control file as well as the control and data members, and each gap adds a limitation.
dpkg lists every name of a hardlinked file in md5sums, while tar stores the later names as hardlink entries. The cross-check inventory now takes hardlink paths as well as regular files, so those names are no longer counted missing.
The sync @napi-rs/lzma decoder takes no output bound, so a member whose index could not be read was decoded with no limit and checked only after allocation. decodeXz now refuses such a member, as truncated when the footer is missing and malformed otherwise, before calling the decoder.
md5sums that is not UTF-8 counted as zero listed paths, and a package with no data.tar counted as an empty inventory. The cross-check is now computed only when both were read; otherwise it stays null and a limitation says which input was missing.
…rejects A Version with an empty upstream part or Debian revision (1:, 1:-1, 1.0-) and an Installed-Size past the safe integer range reached DebControl and failed the output schema, so the service lost the report. The parser now records a malformed field issue and leaves the value null.
Main now requires every top-level src unit in UNIT_LAYERS. src/deb is a provider like src/sqlite, and its two type imports of application ports are recorded in the upward-import baseline the same way. The xz spy binding now accepts the string or bytes input XzApi.compressSync takes.
Read ustar name, prefix and linkname fields, and GNU long names, as NUL-terminated UTF-8 without trimming or rewriting backslashes, and keep spaces in md5sums paths. A name that is not UTF-8 is shown with U+FFFD replacements and counted in a limitation, since it may not match md5sums.
Look up control, conffiles, md5sums and maintainer scripts by their normalized root path, so a nested subdir/control or subdir/postinst no longer stands in for the root file.
PAX record lengths count bytes, so walk the extended header bytes and decode each record on its own. A UTF-8 path no longer swallows part of the next record. A path or linkpath record that is not UTF-8 is counted in the same not-UTF-8 limitation as ustar names.
Accept hyphenated architecture qualifiers such as kfreebsd-amd64, and have parseDebianRelationshipField return the alternatives it cannot read. parseControl records each as a malformed issue on its field, so the package reports partial coverage instead of dropping a dependency.
A Debian package refusal now carries the bounded partial report as diagnostics.partial, so control facts, relationships, maintainer-script facts, ar member offsets and file rows read before the failure reach CLI and MCP callers, not just member names and a count.
GNU PAX sparse headers (GNU.sparse.*) rename the following entry to a synthetic GNUSparseFile path and store only mapped segments, so reading it as a regular file reported the wrong name and size and could miss md5sums cross-checks. Old GNU sparse (S) entries can also carry extension blocks their size field does not count. Refuse both as an unsupported format instead of reporting wrong file facts.
|
@mvanhorn thanks for the PR — this branch has merge conflicts with |
…data # Conflicts: # licenses/npm-runtime-notices.txt # src/domain/tarFormat.ts
|
Merged latest
Validation
|
# Conflicts: # tests/boundary/providers/native/artifactProvider.standaloneFormats.test.ts
…tion with partial facts
… arrays, and guard XZ close gate
# Conflicts: # scripts/lib/test-projects.mjs # src/domain/parseFailureAnalysisError.ts # src/server/offlineInspectionToolBindings.ts
Summary
Add
inspect-deb-package/inspect_deb_package: a local, read-only inspection of a Debian.debas typed Evidence. The reader parses the SysV ar container (debian-binary,control.tar.*,data.tar.*), reports control metadata and relationships, inventories data members, and cross-checksmd5sumspaths. It does not install the package or run maintainer scripts.This change adds the runtime dependency
@napi-rs/[email protected]socontrol.tar.xzanddata.tar.xzcan be decoded in-process. Current Debian/Ubuntu packages ship those members as xz; gzip and zstd already had in-tree decoders, and xz needs a native decoder to inspect those archives under the same size budgets.No tracking issue exists for this change.
Problem and expected behavior
Operators need to inspect a
.debthey already hold without installing it. The existing desktop Debian helper shells out todpkg-debfor capture work and is a different authority; it is not a typed inspect tool.Expected outcome: given a local path, the CLI and MCP tool return Evidence whose
normalized_resultincludes ar members, parsed control fields, relationship alternatives (operators and arch qualifiers), conffiles/md5sums presence, maintainer-script interpreter and byte length, a bounded data inventory, and an md5sums path cross-check. Gzip, zstd, xz, and uncompressed tars succeed. Bad ar magic, truncated members, tar checksum failures, truncated/corrupt/oversized xz, and oversize counts refuse with typed errors and partial observations rather than silent zeros. If the xz native binding cannot load, the refusal is typedunsupported_targetrather than a process crash. Missing optional control fields arenull, not empty strings.Change and scope
New dedicated inspect tool on the existing contract path: domain schema and Debian version/relationship parsers, ar/tar reader, xz decoder via
@napi-rs/lzma, provider, application port/service, composition, CLIregisterContractCommand, MCP evidence handler, analysis-view summary, docs, and catalog wording in authored skill references.The
@napi-rs/lzmapin is exact (1.5.3). License inventory, runtime notices, and the documented MIT-notice gap for that package and its same-release prebuilt family are updated withnpm run licenses:generate/licenses:check.Intentionally not included: bzip2 and lzma (legacy
.lzma) decompression, debsig/dpkg-sig verification, hashing file contents for md5sums, returning maintainer-script text, installing packages, or executing scripts.Contribution scope: this is a local shipped-artifact read. It does not execute the target, inject, mutate bytes, or recover protections. No additional maintainer execution/injection decision is required for that reason.
Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
src/deb/DebPackageParser.tsowns ar/tar/control/data facts.src/deb/xzDecoder.tsowns xz inflate, uncompressed-size pre-check, and native-binding load. Consumers (DebPackageProvider,DebPackageService, CLI, MCP,debPackageView) use those parsed fields; they do not re-parse raw ar/tar bytes or reinterpret xz errors. No superseded inspect path was removed. Desktopdpkg-debcapture remains a separate authority.inspect_deb_package, CLIinspect-deb-package, familyartifact, effectevidence. Input schema includespathplus the documented byte/member/entry limits. Catalog JSON is generated in CI; authored skill text names the command..debwithcontrol.tar/.gz/.zst/.xzand the same fordata.tar. bzip2 and lzma are typed unsupported targets. Requires Node zlib gzip and zstd (already in-tree) plus@napi-rs/lzmafor xz. A missing native addon isunsupported_target.createEvidence+completeProviderEvidence; subject digest is the selected file; locations include artifact path and byte range; limitations list the no-install, no-signature, no-script-text, and no-content-hash rules.partial/partial_observation.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): authored skill references and docs/index catalog wording updated; generated catalogs not committed. New runtime dependency@napi-rs/[email protected](MIT) plus its optional platform packages; third-party notices and the runtime fingerprint are updated.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
Parser, domain, service, filesystem, CLI, and MCP tests use in-code ar+tar fixtures, including xz control members (valid, truncated, oversized) and an unavailable native binding. Executed CLI on those fixtures plus two public
hellopackages (gzip success; xz success). Source-derived: Debian ar/tar/control field shapes. No Hopper/Ghidra/browser provider run.src/domain/deb/debPackage.test.ts,src/deb/DebPackageParser.test.ts,src/deb/xzDecoder.test.ts,src/application/deb/DebPackageService.test.ts,tests/acceptance/debPackageCli.test.ts,tests/boundary/mcp/debPackageMcp.test.ts,tests/boundary/filesystem/debPackage.test.ts, plus registrations in local-path admission, stable parser-failure CLI, local tool contracts, CLI integer arguments, and absolute local path MCP tests.rea inspect-deb-packagewas not a command. After, fixture inspect returns packagehello, epoch/upstream/revision, Depends alternatives with operators and arch restrictions, six maintainer scripts at 17 bytes/bin/sh, and a seven-entry data inventory. Truncated members and non-ar files exit 1 withinvalid_request/invalid_formatand a partial file snapshot. Publichello_2.10-3_amd64.deb(control.tar.xz/data.tar.xz) inspects with exit 0 and coverage complete.demo/deb-package-metadata(commands.log,out.mp4,preview.gif). Representative human and--jsonoutput for the gzip fixture; public gziphello_2.4-3_amd64.deb; truncated and non-ar refusals; successful xz inspect ofhello_2.10-3_amd64.deb.hellopackages that were actually run.Boundary regressions covered: malformed input (bad magic, truncated member, tar checksum, oversize limits), typed unsupported compression, truncated/corrupt/oversized xz, unavailable xz binding, permission/path admission via existing local-path tests, and identity preservation on parser failure (partial snapshot hash). Lifecycle regressions: not applicable (no owned child process or session cleanup).
For evidence-bearing changes:
Validation performed
npx vitest run src/deb/xzDecoder.test.ts src/deb/DebPackageParser.test.ts src/domain/deb/debPackage.test.ts src/application/deb/DebPackageService.test.ts tests/acceptance/debPackageCli.test.ts tests/boundary/mcp/debPackageMcp.test.ts tests/boundary/filesystem/debPackage.test.ts— 7 files, 40 passed.npm run test:focused --those files plustests/acceptance/localPathAdmissionCli.test.ts,tests/acceptance/stableArtifactParserFailureCli.test.ts,tests/acceptance/tools/localToolContracts.test.ts,tests/boundary/cli/cliIntegerArguments.test.ts,tests/boundary/mcp/absoluteLocalPathTools.test.ts— 12 files, 182 passed.npm run check:fast— typecheck and lint passed.npm run format:check— passed (8059 files).npm run metadata:check— passed.npm run docs:check— passed, includinglicenses:checkfingerprint0683afc489101481e2474d7f118bc734409cbcc22b8f62f4158190e82a8184c1.npm run test:changed -- --base upstream/main— 29917 passed, 3 failed, 21 skipped. Failures aresrc/artifacts/NodeSeaArtifactReader.test.ts(post-classification carrier mutation) andsrc/artifacts/pyinstaller/PyInstallerBoundaries.test.ts(cached carrier freshness). They fail in isolation on this tree and are not the Debian reader.npm run check:pr—test:run8 failed, 49798 passed, 295 skipped. Failures:nativeVerifierPreflightOwnership,advertisedDialect,packageCatalogVerification,NodeSeaArtifactReadermalformed-blob mutation,Uf2ArtifactReaderforged region,DenoStandaloneArtifactReadercarrier mutation,inesArtifactheader overwrite,mutationWorkflowempty stderr (PS1unbound). None are the Debian reader.node scripts/rea.mjs inspect-deb-packageon gzip/zstd/xz fixtures (exit 0), truncated and non-ar inputs (exit 1), publichello_2.4-3_amd64.debgzip (exit 0), publichello_2.10-3_amd64.debxz (exit 0). SHA-256 values are incommands.logondemo/deb-package-metadata.Compatibility, safety, and release
@napi-rs/[email protected].hellopackages were read as local files.docs/deb-package.md, catalog wording, authored skill references, lockfile, and third-party notices for@napi-rs/lzma. CI remains the owner of generated catalogs andskills/build output.max_control_bytes/max_data_bytesbefore inflate.Author readiness
Human owner: @mvanhorn
Before merge
type(scope): outcome.Demo