Skip to content

feat(artifacts)!: inventory and extract ISO 9660 disc images offline - #13290

Merged
morluto merged 1 commit into
morluto:mainfrom
mvanhorn:fix/iso9660-image-reader
Nov 24, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
mvanhorn:fix/iso9660-image-reader

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Installer, recovery and appliance media often ship as .iso files, and firmware bundles sometimes nest one inside another archive. REA does not recognize ISO 9660 today, so an analyst gets an unknown blob and has to mount the image or run 7z/xorriso outside REA before inspecting what is inside, losing Evidence provenance for every file.

This adds an offline iso9660 artifact format. inspect-artifact and extract-artifact (and the MCP inspect_artifact / extract_artifact tools) read the volume descriptors and one directory tree, list every file and directory as an occurrence, and extract stored file bytes without mounting the image or calling a host tool. No issue exists for this; it is a format-inspection and ordinary-extraction addition within the supported contribution scope.

Problem and expected behavior

Use case: given installer.iso, see its volume facts and file tree, find that bin/setup.exe is a PE file, and extract it for further REA analysis.

Observable outcome:

  • A file with the CD001 descriptor at sector 16 is recognized as iso9660 regardless of filename, including inside another archive and when named with a Hopper .hop suffix (selecting the database target kind keeps the database interpretation).
  • The root occurrence records primary volume descriptor facts (identifiers, block size, volume space and set, dates, El Torito boot catalog sector as declared) plus derived counts and name_source.
  • One tree is walked: the Joliet tree when an eligible Joliet descriptor exists, otherwise the primary tree. Coverage is complete only for a primary-only image; otherwise it is unknown with a limitation naming each tree that was not walked, because REA does not establish that the trees list the same files.
  • Extracted children are classified by content, so setup.exe inside the image reports pe.
  • Separated multi-extent and interleaved files are listed with hash_status: "unavailable" and a limitation, not silently skipped or partially read.

Change and scope

  • src/domain/iso9660/ owns parsing: iso9660VolumeDescriptors.ts (descriptor set, both-endian fields, Joliet eligibility, El Torito record), iso9660Structures.ts (directory records, extents, ./.. self-checks, volume sequence numbers), iso9660Members.ts (multi-extent grouping, name normalization and safe renames), iso9660Dates.ts.
  • src/artifacts/Iso9660ArtifactReader.ts reads through the shared positional reader. PositionalArtifactReader.ts now rechecks image identity before refusing an entry from cached facts; Godot PCK encrypted members get the same fix and a test.
  • Recognition in artifactFormatRecognition.ts, registration in artifactFormats.ts, classification and inventory graph wiring, and BinaryTargetResolver.ts content precedence over the .hop filename fallback. The whole-file UEFI probe (UefiFormatProbe.ts) now defers to any format the shared recognizer table identifies, so an ISO carrying a firmware volume keeps its file tree in both inventory and open_binary.
  • Fixed bounds: 64 volume descriptors, 64 directory levels, 262,144 directory records, 64 MiB of directory extents and 64 MiB of expanded paths. Declared file bytes share the existing artifact_limits.expanded_bytes budget. The walk yields and checks cancellation every 256 records or padded sectors.
  • Docs: new docs/guides/firmware/iso9660-images.md, sidebar, CLI reference, docs index and skill references.

Not included: Rock Ridge, UDF, El Torito boot catalogs and boot images, path tables, extended attribute contents, multi-volume sets, and reading separated or interleaved files.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the src/domain/iso9660/ parsers produce facts; the reader, inventory graph and resolver consume them without reparsing raw bytes.
  • Contribution scope fit and linked maintainer decision: format inspection and ordinary extraction of a local file; not applicable (no target execution, injection, mutation, or protection recovery).
  • CLI and MCP/tool-catalog contract: no new tools or parameters. Existing artifact tools recognize one more format value, iso9660; open_binary reports format: "iso9660".
  • Provider, bridge, target-format, or platform compatibility: new target format iso9660. A .hop-named file whose content is ISO 9660 now resolves as ISO 9660 unless the database kind is selected.
  • Evidence, artifact, provenance, or reconstruction contract: new iso9660 and iso9660-entry metadata shapes; children carry stored ranges and SHA-256.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none committed; authored skill references updated under .agents/skills/reverse-engineer-anything/.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/domain/iso9660/iso9660Structures.test.ts (descriptors, both-endian disagreement, Joliet eligibility and tree coverage, dates, multi-extent grouping, version suffixes, ./.. rules, unsafe names), Iso9660ArtifactReader.test.ts and .boundaries.test.ts (limits, cycles, truncation versus malformed extents, volume references, cancellation inside long chains and padding runs, changed-image identity), tests/acceptance/iso9660Cli.test.ts, tests/boundary/mcp/iso9660Mcp.test.ts (including an ISO named installer.hop), plus format recognition, target diagnostics, inventory graph and Godot PCK tests. Fixtures are built in iso9660.fixture.ts.
  • Base reproduction or other evidence: executed. On the base revision the same file is not recognized and returns unsupported_target; the new boundary tests fail there.
  • User-visible CLI/MCP output (executed, rea inspect-artifact installer.iso --detail summary --evidence_output installer.evidence.json --json, excerpt of root_format_metadata on a generated Joliet image with an El Torito record):
{
  "kind": "iso9660",
  "system_identifier": "REA DEMO",
  "volume_identifier": "INSTALLER",
  "volume_space_size": 29,
  "logical_block_size": 2048,
  "root_directory_extent": 23,
  "creation_date": "2024-01-02T03:04:05.00+01:00",
  "volume_descriptor_count": 4,
  "el_torito_boot_record": true,
  "boot_catalog_sector": 28,
  "joliet_level": 3,
  "name_source": "joliet",
  "directory_count": 2,
  "file_count": 3
}

with limitations including "The primary directory tree (root extent at block 20) was not walked; files listed only there are not reported." extract-artifact on the same image wrote README.TXT, bin/setup.exe and docs/Release Notes.txt with containment_verified: true.

  • Also executed: a Joliet image made with macOS hdiutil makehybrid -iso -joliet listed the expected nested paths with Joliet names, and the 5,000-byte nested file's SHA-256 matched the source file.
  • Remaining proof gaps: images from mkisofs, xorriso and vendor installer media, and Rock Ridge or UDF hybrids, were not checked.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Demo

Rendered walkthrough of the CLI inspect and extract output above (simulated terminal, values taken from a real run on the generated fixture).

demo

Validation performed

  • npx --no-install vitest run over the changed test files (ISO structures, reader, reader boundaries, format recognition, target vocabularies, target diagnostics, inventory graph, Godot PCK, CLI acceptance, MCP boundary): passed
  • npm run format:check: all matched files use the correct format

Compatibility, safety, and release

  • Breaking changes or migration steps: BREAKING CHANGE: artifactReaderLimitsSchema now requires iso9660 (descriptor_count, directory_depth, record_count, directory_bytes, path_bytes), so saved Evidence records containing effective_limits from prior versions without iso9660 will fail parseInventoryPage validation and must be re-inspected. The only behavior change outside the new format is that ISO content now wins over a .hop filename, and a changed image is reported as a changed source before a cached refusal (ISO and Godot PCK).
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; offline parsing only, run on macOS.
  • Package or release metadata impact: one new format value.
  • Security, privacy, process, or containment review: reads a local file only and extracts through the existing contained extraction path. Identifiers and names are target-derived and untrusted; unsafe names are renamed. Descriptor, depth, record, directory byte and path byte counts are bounded before allocation, and declared file bytes share the expansion budget.

AI was used for assistance.

Author readiness

Human owner: @mvanhorn

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T21:22:04.404161Z
We couldn’t complete this review. Comment @codex review to try again.
ba75c73 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The code has no newly confirmed blocking defect, but the required issue discussion must be linked before merging.RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The changes reach ISO artifact inspection, extraction, and binary target routing.

The code has no newly confirmed blocking defect, but the required issue discussion must be linked before merging.

Findings

  1. P2 Required issue discussion is missing ▶
Fix with agent prompt
### Issue 1
src/domain/iso9660/iso9660Structures.ts:undefined-19
This PR adds ISO 9660 support, but its description says no issue exists for the addition. The repository requires an issue explaining the problem and proposed solution before submitting changes. Being within the supported contribution scope does not waive that requirement. Open or discuss the issue and link it here before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds offline ISO 9660 inspection and extraction through the existing CLI and MCP workflows.

  • REA can inspect and extract files from ISO 9660 images.
  • ISO content now takes precedence over filename and embedded-firmware guesses.
  • Changed archive images are reported before an unreadable member is refused.
  • Saved artifact records now include ISO reader limits.

morluto accepted the saved-Evidence compatibility break because the PR is explicitly marked as breaking. Older records containing effective_limits without iso9660 must be re-inspected.

Review used source checks; no tests were run. Whether another PR supersedes this one could not be checked because GitHub access was not authenticated.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Local image or archive member] --> B[Recognize ISO descriptor signature]
  B --> C[Read bounded volume descriptors]
  C --> D{Eligible Joliet tree?}
  D -->|Yes| E[Walk Joliet tree]
  D -->|No| F[Walk primary tree]
  E --> G[List entries and coverage limits]
  F --> G
  G --> H{Readable byte range?}
  H -->|Yes| I[Hash and classify content]
  H -->|No| J[List with unavailable hash]
  I --> K[Extract selected files through shared output checks]
Loading

Reviews (9) · Last reviewed commit: "feat(artifacts)!: inventory and extract ..." · Reviewed by Greptile

Comment thread src/artifacts/inventory/classify.ts Resolved
Comment thread docs/guides/firmware/iso9660-images.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8174ea259b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/iso9660/iso9660Structures.ts Resolved
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@mvanhorn thanks for the PR — there is 1 open review thread here:

Could you address or reply to this? Once it's resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto enabled auto-merge (rebase) November 24, 2026 15:23
Comment thread src/domain/iso9660/iso9660Structures.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

2 similar comments
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread src/domain/artifactReaderLimits.ts Resolved
@morluto morluto changed the title feat(artifacts): inventory and extract ISO 9660 disc images offline feat(artifacts)!: inventory and extract ISO 9660 disc images offline Nov 24, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto disabled auto-merge November 24, 2026 17:43
@morluto
morluto enabled auto-merge (rebase) November 24, 2026 17:43
auto-merge was automatically disabled November 24, 2026 17:44

Rebase failed

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Thanks for working through these. All review threads are resolved, including the zero-length extent one, and CI is green on the latest merge of main. Nothing else pending from me.

Add an offline iso9660 artifact format. inspect-artifact and
extract-artifact (and the MCP tools) read the volume descriptors and one
directory tree, list each file and directory as an occurrence, and
extract stored file bytes without mounting the image or calling a host
tool. Traversal limits are exposed via artifact_limits.iso9660.

BREAKING CHANGE: artifactReaderLimitsSchema now requires iso9660
(descriptor_count, directory_depth, record_count, directory_bytes,
path_bytes), so saved Evidence records containing effective_limits from
prior versions without iso9660 fail parseInventoryPage validation and
must be re-inspected.
@morluto
morluto force-pushed the fix/iso9660-image-reader branch from 8418b22 to ba75c73 Compare November 24, 2026 21:21
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto merged commit e896f60 into morluto:main Nov 24, 2026
51 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

@morluto thank you for landing ISO 9660 support, so disc images can be inspected and extracted offline without mounting them first.

* volume descriptor parser. Both-endian fields are decoded from both halves
* and must agree. Rock Ridge (SUSP) system-use fields are not decoded.
*/
export const ISO9660_FORMAT = "iso9660";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Required issue discussion is missing

This PR adds ISO 9660 support, but its description says no issue exists for the addition. The repository requires an issue explaining the problem and proposed solution before submitting changes. Being within the supported contribution scope does not waive that requirement. Open or discuss the issue and link it here before merging.

Rule Used: Before submitting changes, open or discuss an issue that explains the problem and proposed solution; group related changes into a focused PR rather than submitting many separate small PRs, especially one-line changes. (source)

Learned From
morluto/rea#9396
morluto/rea#9399
morluto/rea#9392
+2 more

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/iso9660/iso9660Structures.ts
Line: 19

Comment:
**Required issue discussion is missing**

This PR adds ISO 9660 support, but its description says no issue exists for the addition. The repository requires an issue explaining the problem and proposed solution before submitting changes. Being within the supported contribution scope does not waive that requirement. Open or discuss the issue and link it here before merging.

**Rule Used:** Before submitting changes, open or discuss an issue that explains the problem and proposed solution; group related changes into a focused PR rather than submitting many separate small PRs, especially one-line changes. ([source](https://app.greptile.com/-/switch-tenant?tenant=pre&next=%2Fmorluto%2Frea%2Fcustom-context%3Fmemory%3D521f5678-e034-42c8-ae87-2f566638aac6))

**Learned From**
[morluto/rea#9396](https://github.com/morluto/rea/pull/9396)
[morluto/rea#9399](https://github.com/morluto/rea/pull/9399)
[morluto/rea#9392](https://github.com/morluto/rea/pull/9392)
*+2 more*

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants