Repository navigation
feat(labview): inspect RSRC containers and embedded VI trees - #13337
Conversation
Add inspect_labview_artifact, a static reader for LabVIEW RSRC containers in .vi/.ctl/.llb files and in LabVIEW-built PE resources. It reports the container header, the recorded LabVIEW version, the complete block inventory with each section's coding, and whether the block-diagram and front-panel heaps are present, without starting LabVIEW or any process. Only zlib-coded sections are decoded, for their byte count; no payload is returned. An absent block-diagram heap is reported as a limitation rather than reconstructed.
Describe the inspect_labview_artifact contract, section codings, and the block-diagram limitation, and list the target in the supported-targets table and the documentation index.
[Medium impact] The PR appears safe to merge; the previous page-copy issue is fixed and no new actionable issue was found. SummaryAdds static LabVIEW RSRC inspection for direct files and PE resources, with shared CLI/MCP delivery.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Selected local file] --> B[Stable read and file identity]
B --> C{Direct RSRC?}
C -->|Yes| E[Parse RSRC container]
C -->|No| D[Find PE RCDATA containers]
D --> F[Select largest container]
F --> E
E --> G[Complete Evidence]
G --> H[Complete inline result]
G --> I[Summary or requested page]
I --> J[Reuse cached section index]
Reviews (30) · Last reviewed commit: "perf(labview): build view rows only for ..." · Reviewed by Greptile |
Add the provider-admission coverage the repository requires for a new provider, without changing the reader: - Move the synthetic RSRC container builder into a shared test fixture so the unit and boundary tests build the same bytes once. - Add a CLI and stdio MCP boundary test for inspect_labview_artifact. - Register `rea-labview-rsrc` lifecycle coverage for operation and cancel. - Declare the `labviewArtifact` conformance case. - Regenerate the advertised catalog summary for inspect_labview_artifact.
`inspect_labview_artifact` admitted a relative `path`, while every other caller-path contract requires an absolute one. The CLI/contract parity check caught it: the CLI resolves a relative argument before admission, so the contract must hold the absolute rule alone. Use `absoluteLocalPathStringSchema`, the schema the other caller-path contracts already use.
Address the review findings on the RSRC reader: - Bound the PE resource walk with a visited set, a total visit budget, directory-entry and container allowances, and a typed limit failure instead of a silently partial scan. - Check the resource directory and its data against the declared resource range rather than the whole file. - Cap zlib inflation at its declared length, add a total decoded-work budget, and recognise any valid zlib header instead of three byte pairs. - Check nested RSRC records against their declared data/info sections and cap the total section count across blocks. - Read the artifact through readStableArtifact so identity, bounds and cancellation bind to the bytes actually inspected. - Carry parse failures as ParseFailureError facts: malformed input keeps its kind/offset/field, and a limit becomes a typed fixed-allowance refusal instead of invalid_format. - Report heap presence as `unknown` when an embedded program tree or an unexamined container could still hold it, not as `absent`. - Cover cancellation that arrives after the read starts. - Move the analyst guide under docs/guides/native/.
|
All twelve findings are addressed in
The two inline P1s are also resolved: Validation on |
- Own the artifact resource scope and run each read through it, so a retained failed close is retried before later work and reported at shutdown. - Translate the read failure as recorded instead of replacing it with the signal's current state; the stable read owns its cancellation facts. - State the 256 MiB input ceiling as a fixed allowance so an oversized artifact keeps its structured maximum and recovery. - Match the guide to the decoded-byte behavior: a section over the budget is reported `unknown` and the inventory continues.
|
The four second-pass findings are addressed in
Validation on |
- Replace the unbounded `\d+\.\d+` scan with a bounded single-pass search over the first 64 KiB of each vers section; a digit-only section no longer drives quadratic matching work in the shared server. - Classify read failures through the shared provider classifier with a LabVIEW dialect, so the size ceiling is restated as a fixed allowance and the read's cleanup, partial observation and cancellation facts survive the refusal. - Cover both with regressions.
|
Both third-pass findings are addressed in
Validation on |
…pection # Conflicts: # src/server/serviceToolBindings.ts
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f763270c5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Walk PE resources through readPeResourceLayout, so RVA lookup is indexed, a payload may map through any admitted section, and the home-grown section scan is gone. Add a total entry budget. - Charge every attempted inflation against the container's decode budget, including failed and length-mismatched attempts. - Bound block records by the list's declared extent, clamped to the container because real LabVIEW-built PEs declare more than the resource payload holds. - Reject a named section whose name leaves the list instead of reporting it as unnamed. - Pass the selected container to the parser without copying it. - Cover the PE path and the over-declared list extent with regressions.
|
All six findings are addressed in
Re-verified after the refactor against the same locally supplied LabVIEW-built PE (name and digest withheld): one embedded container, Validation on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 479a87ccfe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Charge compressed input bytes as well as declared output, and memoize the decoding of one stored section, so records that share a stream do not repeat its work. - Keep a zlib-coded `vers` section's decoded bytes for the version scan. - Cap list records by both the declared extent and the info section. - Report PE walk coverage, and keep heap presence `unknown` for a `.llb` archive or an unreadable PE resource branch.
|
All five findings are addressed in
Re-verified after these changes against the same locally supplied LabVIEW-built PE (name and digest withheld): one embedded container, Validation on |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
A file that does not declare `MZ` is not a PE, so it must not be reported as a malformed PE resource tree. The scan reports whether the file was admitted as a PE separately from whether the walk was complete.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bafc4acfea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…bles A two-byte MZ check treated plain DOS MZ and NE/LE/LX images as declared PEs, so an ordinary non-LabVIEW file was reported as an unreadable PE resource tree. PE identity now comes from observeMzWindowsHeader: only a PE signature at e_lfanew declares a PE. The unused admitted field is removed. A section-start offset inside the count word or block-header rows was accepted and could fabricate an inventory from block metadata. Tables must start at or after the end of every block header; blocks may still share a later table. The refusal tests now assert the error type unconditionally.
|
A short coordination note so we do not step on each other on this branch. I verified I will hold pushes while you are iterating. One of your commits already landed ahead of mine and I dropped the duplicate rather than reconcile two versions of the same fix, so the branch is currently at your head. If you want any thread taken, name it and I will handle it; otherwise I will keep verifying each new head and report anything that fails. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56ba7d8d9a
ℹ️ 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".
A malformed RSRC embedded in a PE failed with container-relative offsets, but the refusal names the selected executable and carries no container.file_offset, so callers could not locate the failure. The parser now takes the container origin and moves a failure offset into the selected file's coordinates; successful results keep container-relative ranges with container.file_offset.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce838579fc
ℹ️ 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".
# Conflicts: # src/domain/native/peOverlay.ts
A damaged container declaring an impossible block or section count was refused as a capacity limit before its table extent was checked, so a truncated target surfaced as resource_constraint. Each table is now framed first; a fully framed table over its allowance is still a capacity refusal.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd19b92ae9
ℹ️ 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".
…absence A nonzero resource RVA whose file-backed run cannot hold one directory header returned complete coverage without reading anything, so the file was reported as carrying no embedded RSRC. Only a zero RVA is observed absence now; a short declared root is an unread tree. Directory rows were checked against the entry allowances before their extent, so a damaged directory declaring impossible counts surfaced as resource_constraint. Rows are framed first; a fully framed directory over its allowance is still a capacity refusal.
# Conflicts: # scripts/lib/test-projects.mjs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3af535ea4
ℹ️ 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".
A data offset inside the 32-byte RSRC header let a section's stored-length word be read from header fields, returning a fabricated empty section as a successful inventory. A data offset below the header is now malformed.
# Conflicts: # docs/reference/supported-targets.md # src/application/binary/TargetFormatVocabularies.test.ts # src/artifacts/artifactFormats.ts # src/domain/artifactFormatRecognition.ts # src/domain/artifactGraph.ts # src/domain/artifactInspection.ts # src/domain/native/peOverlay.ts # src/domain/targetFormats.ts
… RSRC magic once The allowance test froze the delivered sentence. It now checks the parser's decodeOmissions fact and the effective allowance, and compares the public limitation with the provider's own formatter output. The RSRC magic was declared again in artifact recognition; it now has one owner in the LabVIEW domain contract, used by recognition, the parser, the PE scan and the provider.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c4176964c
ℹ️ 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".
…idence inspect_labview_artifact returned every block and section inline, so an admitted container with 4096 named sections could exceed a megabyte and bypass the agent result budget. The tool now takes detail: complete keeps the inline inventory; summary, or omitted detail over the budget, returns container, version and heap facts with block and section counts, and the complete inventory is paged with inspect_analysis_view kind labview-artifact (blocks, sections, optional block filter) or read with evidence-json. The CLI delivers the same way. RSRC data and info ranges that intersect are refused as malformed rather than reading list metadata as section data.
The advertised output now admits complete or summary detail, so the test parses the complete report schema explicitly.
Each view call copied every section before reading the request, so a summary or one-row page did work proportional to the whole inventory. A section index (block and section position, and positions per block) is built once per immutable retained report and reused; summaries read counts from it, and section pages build objects only for selected rows.
Summary
REA has no reader for LabVIEW artifacts. A
.vi,.ctl, or.llbfile and a LabVIEW-built executable all store their program tree in an RSRC container: a 32-byte header, a data section, and a block-info list. Sections are stored with different codings (none, zlib, XOR), and a built executable commonly keeps only aFLAGblock and oneLVzpblock (the embedded program tree).This adds
inspect_labview_artifact(MCP) andinspect-labview-artifact(CLI): a static, bounded inventory of one selected file. It reports the container header, the LabVIEW version recorded by theversblock, every block and section with its coding and decoded byte count, and whether the block-diagram heap (BDH*) and front-panel heap (FPH*) are present. It reads the file without running it and requires no LabVIEW installation.Problem and expected behavior
Without this, an agent can only guess at a LabVIEW binary's structure from raw bytes. The expected outcome is an evidence-bearing inventory that names what is stored and, just as importantly, what is not: when a build removed the block diagram, the tool must say so rather than imply that a diagram exists.
Smallest use: select a
.viand ask which blocks and codings it contains. On a LabVIEW-built PE, select the executable and ask which embedded RSRC container it carries.Change and scope
src/labview/LabviewRsrc.tsparses the RSRC header, block-info list, block headers, section starts, and section data withBinaryReaderbounds checks. A truncated or non-RSRC container fails with a reason; it does not return a partial inventory.src/labview/LabviewPeContainer.tswalks the PE resource directory (bounded depth and entry counts) and returns embedded payloads that begin withRSRC\r\n. It does not extract or interpret other resources.none,zlib(four-byte big-endian length followed by a zlib stream),xor(LVzp), orunknown. zlib sections are decoded only to verify and report the decoded byte count; no payload is returned.readPeResourceLayoutowner, visits each directory once, and has total entry and container allowances; RSRC block and total-section counts are capped; each zlib attempt is charged against a container-wide decoded-byte budget. Exceeding one is a typedresource_constraint, not a malformed input.labview-rsrc, andinspect_artifacton that file reports the format with anext_probenaminginspect_labview_artifact, so a dedicated reader's formats no longer look unsupported.container.file_offset, so the container-relative header offsets map onto the selected file.versrecord, withversion_coveragedistinguishing a read version, a container with noversrecord, and a record that could not be decoded. A PE payload is accepted only from the RT_RCDATA (type 10) resource type, matching thepe-rcdata-rsrckind.unknownunless a heap block is present: its content does not establish whether it is a VI, a control, or an archive of member VIs, and the caller's spelling is not evidence of format. A PE-embedded application container, which the walk fully examines, can still reportabsent. Block facts are derived in one pass, and aliased directories and payload ranges are counted once.src/domain/labview/labviewArtifact.ts,src/ports/labview/LabviewArtifactPort.ts,src/application/labview/LabviewArtifactService.ts,src/contracts/labview/labviewToolContracts.ts,src/composition/labview.ts, andsrc/cli/labviewCommands.tsfollow the existing static-format module shape (Go, Rust, IL2CPP, PE resources).scripts/lib/module-layers.mjsandscripts/lib/test-projects.mjs; the contract joins the artifact tool family.Intentionally not included in this PR: section payload extraction, a member list for
.llbfiles, and any reconstruction of a block diagram from compiled code. Those are separate increments if the direction is useful.Scope fit: static format inspection, which
CONTRIBUTING.mdlists as supported. This does not involve target execution, injection, mutation, or protection recovery, so no maintainer scope decision is required; the draft is opened for direction. No issue is linked: this adds a capability rather than fixing a reported defect.main@880a2d5d5(6.10.1, 464 commits). That release extracted the offline inspection bindings out ofsrc/server/serviceToolBindings.ts, so theinspect_labview_artifactbinding is declared insrc/server/offlineInspectionToolBindings.ts, and the CLIinspectWithServicerunner moved tosrc/cli/contractCommandRunners.ts.main@a156d2051(411 commits) followed: the CLI registrar expressions becamecliRegistrar(...),translateArtifactFailuregained the selected path, and the repository began requiring every fixed ceiling inscripts/verify/fixed-ceiling-registry.json. The LabVIEW input and structural allowances are registered there under tracking issue [Feature] Give native readers' fixed structural, text and inventory allowances a control or a stated fixed reason #14235.main@192177f0c(111 commits) kept the branch mergeable; the fixed-ceiling registry conflict was resolved by keeping both the upstream and LabVIEW entries.d8e288d03) records why each recognized zlib section stays undecoded (preset dictionary, either decode allowance, or failed inflation) and stops describing an unreadable PE tree as an absent container. On top of it,bafc4acfekeeps PE admission separate from an unreadable tree, so a non-PE file is not called malformed.pr-13337branch (4eb487a93), which kept the RCDATA constant in the shared PE owner and narrowed the version check to the reported fields; this branch continues on top of that merge.main@412f92736(136 commits) followed. Upstream added thedebformat at the same points this branch addedlabview-rsrc, so every conflict kept both entries in the shared format table, reader routing, and target-format map.Contract and boundary impact
src/labview/LabviewRsrc.tsowns container parsing andsrc/labview/LabviewPeContainer.tsowns PE resource location. The service consumes those parsed facts; the contract does not reinterpret raw bytes.inspect_labview_artifact(inspect-labview-artifact). Input is{ "path": "<absolute path>" }; output is Evidence whosenormalized_resultis the inventory. The generated catalog and CLI command list are produced by the build.Expected effects:
Evidence and regression coverage
src/labview/LabviewRsrc.test.tsbuilds synthetic RSRC containers and covers block/section inventory, zlib and raw codings,LVzpXOR coding, presence reporting (includingunknownwhen an embedded program tree leaves content unexamined), truncated and non-RSRC rejection, provider identity binding, cancellation that arrives after the read starts, the bounded version scan over a digit-only section, a size refusal that also carries a failed close, and the input refusal for a non-LabVIEW file.tests/boundary/cli/labviewRsrcCli.test.tsdrives the same reader through the public CLI and a stdio MCP session and asserts the evidence from both. Synthetic fixtures are used because the repository does not commit binaries..viand a LabVIEW-built PE. The.vireportsLVIN/LBVW, version11.0, 33 blocks includingLIvi,VICD,VCTP, andFPHb, with the block diagram absent. The PE reports one embedded container withFLAGandLVzp. Those artifacts are not committed.bafc4acfeagainst one locally supplied LabVIEW-built PE, which is not committed and whose name and digest are withheld: one embedded container,LVAR/LBVW, format version 3, blocksFLAGandLVzp, versionnull, and both heap factsunknownbecause the embedded program tree was not decoded. An independent big-endian parse of the container header matched every reported range, and a non-RSRC DLL beside it was refused as not an RSRC container..llbmember listing, and no decoded content for XOR-coded blocks. The zero-mask coding is not implemented; a zlib section that does not decode to its declared length, or one the decode budget did not attempt, is reported asunknown.For evidence-bearing changes:
Validation performed
Run on
bafc4acfewith Node.js 24.22.1, the version.nvmrcpins.npm run check:fast— passed (typecheck, lint, architecture guards).npm run build:cached— 3 successful.npx oxfmt --check .— clean over 8625 files.npm run docs:check— passed (8 conformance tests).npm run verify:advertised-schemas— exit 0.npm run test:focused -- src/labview/LabviewRsrc.test.ts tests/boundary/cli/labviewRsrcCli.test.ts tests/evaluation/providerLifecycleCoverage.test.ts tests/conformance/providerCapabilityConformance.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/mcp/advertisedCatalogSummary.test.ts tests/boundary/mcp/advertisedDialect.test.ts— 1198 passed, including the new CLI/stdio-MCP case.node scripts/rea.mjs inspect-labview-artifact <a local LabVIEW-built PE> --json— exit 0, with the identity and container facts above cross-checked against an independent parse; a non-RSRC DLL beside it was refused asinvalid_request.Not run:
npm run check:pr(fulltest:run, Python tests,jscpd,scan:todos). No real LabVIEW artifact is committed or exercised in CI; the reader's real-artifact observation is the one recorded under Evidence and regression coverage.Compatibility, safety, and release
Author readiness
Human owner: @Antruly
Before merge
type(scope): outcome.