Repository navigation
feat(artifacts): make ASAR header admission configurable - #6209
Conversation
ASAR header/index admission was a fixed 16 MiB with no override, so operators with large Electron indexes could only extract the archive. REA_ASAR_MAX_HEADER_BYTES now sets it (default 16777216, maximum 268435456). One owner resolves the effective admission for the classification probe, inventory, ASAR reader and Electron file scope, including the Electron header cache budget. Startup and doctor validate the setting; admission refuses an invalid value instead of falling back. Recovery and error details name the effective value and its source. Fixes #6176 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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 PR appears safe to merge; the previous finding is fixed and no new actionable issues remain. SummaryAdds
Tests were inspected but not run. Supersession status could not be verified because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
E[Selected environment] --> V[Shared setting checks]
V --> A[Effective admission]
A --> I[Artifact inventory and extraction]
A --> J[JavaScript application analysis]
A --> O[Electron and Inspector providers]
I --> P[Header probes and readers]
J --> P
O --> C[Header read or cache check]
P --> R[Admit or report effective limit]
C --> R
Reviews (2) · Last reviewed commit: "fix(artifacts): resolve ASAR header admi..." · Reviewed by Greptile |
…onment The admission read process.env, so composition roots that select their own environment (createDirectAnalysis, createServer, CLI, optional observation factories) could not raise or lower it, and an ambient value leaked into callers that left it unset. Nothing reads process.env now. ArtifactProvider and extraction resolve the admission from their environment; JavaScript analysis parses it from the environment its server or CLI caller passes and refuses an invalid value; the Electron and V8 providers receive it from their factories. Inventory, nested ASAR readers, classification probes and Electron page authorization carry that one value. A header cached by Electron under a larger admission is refused for a smaller one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Fixes #6176 (P0 ASAR item; the regex matching deadline is left for a separate PR).
Before:
MAX_ASAR_HEADER_BYTESwas a module constant shared by four consumers, and recovery text said the release had no override. After: operators can raise (up to 256 MiB) or lower the admission with one environment setting. The default stays the same.Problem and expected behavior
An app whose ASAR header exceeds 16 MiB is refused by
inspect_artifact,inventory_artifact,analyze_javascript_application,extract_artifactand Electron page resolution. Raisingmax_heap_mbor host memory does not help, and the only workaround was extracting the archive. Expected, per the issue: a named setting whose default equals today's constant, a documented maximum, recovery that names the effective value, and no change when unset.Change and scope
src/config/asarHeaderAdmission.tsowns the setting: schema, default, maximum and constraint text.REA_ASAR_MAX_HEADER_BYTESjoins the runtime environment schema, so MCP startup,rea doctorand setup/registration validation reject invalid values.AsarHeader.tsreplaces the constant withresolveAsarHeaderAdmission(environment). Nothing readsprocess.env; helpers without an environment use the default. The signature probe carries its admission and reports it with alimitobservation, so inventory raises the failure for the same admission the probe used.ArtifactProvider(inventory/inspection) and extraction resolve it intoArtifactInventoryOptions.asarHeaderAdmission. That reaches the root classification probe, root and nestedAsarArtifactReaders, and the per-entry hashing probes.environmentpassed by its server (ServerToolContext.environment) or CLI caller.CdpElectronProviderandV8InspectorProviderreceive it fromcreateOptionalObservationFactories(selectedEnvironment)and the CLI contexts, and forward it to everyauthorizedElectronFilecall.ConfigurationError, whichtranslateArtifactFailurenow passes through as typed (before, it became a generic I/O failure), and JS analysis returns it as aResult.ArtifactAdmissionLimitgainssource; error details addmaximum_header_bytes_sourceandsetting.Contract and boundary impact
src/config/asarHeaderAdmission.ts(value) andsrc/artifacts/AsarHeader.ts(admission, before any header allocation).maximum_header_bytes_sourceandsetting; recovery text now names the setting instead of "no runtime override".Expected effects:
Evidence and regression coverage
Tests added or updated (
tests/boundary/filesystem/asarHeaderAdmission.test.ts):"1",createDirectAnalysis({REA_ASAR_MAX_HEADER_BYTES: header-1})refuses a real@electron/asararchive forinventory_artifactandinspect_artifact, naming the setting, andcreateDirectAnalysis({})admits it. JS analysis refuses atheader-1and admits at the exact header size;"",0,-1, leading zero, units, exponent, whitespace, max+1) are refused by both the parser andparseEnvironment. At each owner an invalid value surfaces asconfiguration_invalid, not a default fallback;electronFileScope.test.ts: a header cached under a larger admission is not reused for a smaller one.clientConfigurationEnvironment.test.tsgains a setup/doctor refusal row; existing default-boundary tests were updated to the new owner.Real-app evidence, executed on this Mac (Node 26.5.0) with
rea inspect-artifact /Applications/Signal.app/Contents/Resources/app.asar --integrity-policy record-and-continue --detail summary --evidence_output …. Signal's archive is 43 MB with a 400,496-byte header. Baseline = merge-baseorigin/mainbuild; 3 runs each:7cf24efd802cd2527cf24efd802cd252=4004967cf24efd802cd252=2684354567cf24efd802cd252=400495truncated=0configuration_invalidUnset output is identical to baseline, and time and memory are within run-to-run noise. Token cost of successful results is unchanged.
analyze-javascript-applicationon Obsidian'sapp.asar(6,984-byte header) is refused at=6983and admitted at=6984, where it then reaches Obsidian's own unrelated unpacked-integrity mismatch. WithREA_ASAR_MAX_HEADER_BYTES=0,rea doctorreportsruntime-configuration:REA_ASAR_MAX_HEADER_BYTESasconfig_drift.User-visible output at
=400495:Remaining proof gaps: no real application with a header above 16 MiB was available, so the raise path is covered by the sparse-file boundary test rather than a real app. Windows and Linux were not run locally (CI).
For evidence-bearing changes:
Validation performed
npm run test:focused -- <78 ASAR/Electron/V8/CLI/optional-provider test files>— 77 files passed. 1564 tests passed, 10 skipped, 1 failed:src/inspector/JavaScriptRuntimeScope.cancellation.test.ts › stops Inspector target authorization after the current stat settles, which fails identically on unmodifiedorigin/mainon this macOS host (pre-existing, not changed here).npm run test:focused -- tests/boundary/filesystem/clientConfigurationEnvironment.test.ts tests/boundary/filesystem/electronFileScope.test.ts src/browser/ElectronFileScope.cleanup.test.ts tests/boundary/mcp/asarListingAdmissionMcp.test.ts— 39 passed, 10 skipped.npm run check:fast— passed.npm run format:check— passed.npm run docs:check— passed.npm run build:cachedon both trees).Compatibility, safety, and release
MAX_ASAR_HEADER_BYTESis replaced byDEFAULT_ASAR_MAX_HEADER_BYTES(config) andresolveAsarHeaderAdmission().Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code