Repository navigation
fix(javascript): report Hermes bytecode bundles as unanalyzed application logic - #15135
lennartorlando wants to merge 2 commits into
Conversation
…tion logic analyze_javascript_application skipped a React Native main.jsbundle and still reported complete coverage. The lane selected files by source suffix only, so .jsbundle was neither read nor counted, and a Hermes bytecode bundle under any name was invisible to coverage. Recognize Hermes bytecode in the shared artifact format recognizer table by its eight-byte magic, so inventory records artifact_format hermes-bytecode under any file name. The JavaScript lane takes that inventory fact before the path suffix: the file becomes a hermes-bytecode relevant file whose bytes are verified but never decoded, its node evidence is partial, the graph coverage is partial, and a limitation names the file. REA does not decompile or disassemble Hermes bytecode. .jsbundle joins the JavaScript source suffixes with JavaScript grammar, so a plain-text React Native bundle is parsed like any other JS bundle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion projections Since inventory records Hermes bytecode as hermes-bytecode, the Apple, Android and Harmony projections, which each accepted only javascript-bundle, dropped a Hermes bundle from components.javascript. Apple also lost the JavaScript runtime family and the JavaScript/native bridge candidates. A Hermes file named main.js regressed against the parent, where its suffix had supplied javascript-bundle. Classify JavaScript application components through one shared domain predicate covering javascript-bundle and hermes-bytecode. Components keep their precise format; listing one claims no analysis of its logic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
[Medium impact] The changes affect JavaScript analysis and mobile application projections. Fix the FindingsFix with agent prompt### Issue 1
src/artifacts/javascript/JavaScriptArtifactFiles.ts:471
A filesystem Hermes bundle named `assets/main.asar` is now added to the expected files, but `visitReader` still follows the `.asar` suffix first. It skips the entry because its inventory format is not `asar`. `assertExpectedFilesWereVisited` then reports that the file disappeared, aborting the directory analysis instead of returning partial coverage.
Choose archive traversal from the inventory format, or let non-ASAR entries reach normal file reading. Add a misleading-suffix regression.
### Issue 2
src/domain/artifactFormatRecognition.test.ts:412-415
The recognition test builds its input from `HERMES_BYTECODE_MAGIC`, the same constant that `hasHermesBytecodeHeader` uses to match it. Both new boundary fixtures do this too. A wrong byte or byte order would keep every new test green while real bundles go unrecognized.
The repository's testing guide requires expectations independent of the implementation. Add at least one fixture with independently specified Hermes header bytes before merging.
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!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryRecognizes Hermes bundles from their header, retains them as unanalyzed application logic, and parses plain-text
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Artifact inventory] --> B{Hermes header?}
B -->|Yes| C[hermes-bytecode]
B -->|No, .jsbundle| D[JavaScript text]
C --> E[Verify bytes without decoding]
E --> F[Partial application coverage]
C --> G[Apple, Android, Harmony components]
D --> H[Static JavaScript analysis]
C --> I{Filesystem .asar name?}
I -->|Yes| J[Archive branch skips file]
J --> K[Expected-file check fails]
Reviews (1) · Last reviewed commit: "fix(mobile): keep Hermes bundles as Java..." · Reviewed by Greptile |
| occurrence.entry_kind === "file" && | ||
| occurrence.logical_path.toLowerCase().endsWith(".asar"); | ||
| const kind = relevantKind(occurrence.logical_path); | ||
| const kind = relevantOccurrenceKind(occurrence); |
There was a problem hiding this comment.
A filesystem Hermes bundle named assets/main.asar is now added to the expected files, but visitReader still follows the .asar suffix first. It skips the entry because its inventory format is not asar. assertExpectedFilesWereVisited then reports that the file disappeared, aborting the directory analysis instead of returning partial coverage.
Choose archive traversal from the inventory format, or let non-ASAR entries reach normal file reading. Add a misleading-suffix regression.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/artifacts/javascript/JavaScriptArtifactFiles.ts
Line: 471
Comment:
**`.asar` bundles abort analysis**
A filesystem Hermes bundle named `assets/main.asar` is now added to the expected files, but `visitReader` still follows the `.asar` suffix first. It skips the entry because its inventory format is not `asar`. `assertExpectedFilesWereVisited` then reports that the file disappeared, aborting the directory analysis instead of returning partial coverage.
Choose archive traversal from the inventory format, or let non-ASAR entries reach normal file reading. Add a misleading-suffix regression.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const hermes = Buffer.concat([ | ||
| HERMES_BYTECODE_MAGIC, | ||
| Buffer.from([0x60, 0, 0, 0]), | ||
| ]); |
There was a problem hiding this comment.
Tests reuse the production signature
The recognition test builds its input from HERMES_BYTECODE_MAGIC, the same constant that hasHermesBytecodeHeader uses to match it. Both new boundary fixtures do this too. A wrong byte or byte order would keep every new test green while real bundles go unrecognized.
The repository's testing guide requires expectations independent of the implementation. Add at least one fixture with independently specified Hermes header bytes before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/artifactFormatRecognition.test.ts
Line: 412-415
Comment:
**Tests reuse the production signature**
The recognition test builds its input from `HERMES_BYTECODE_MAGIC`, the same constant that `hasHermesBytecodeHeader` uses to match it. Both new boundary fixtures do this too. A wrong byte or byte order would keep every new test green while real bundles go unrecognized.
The repository's testing guide requires expectations independent of the implementation. Add at least one fixture with independently specified Hermes header bytes before merging.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
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!
Summary
analyze_javascript_applicationskipped a React Nativemain.jsbundleand still reported complete coverage; a Hermes bytecode bundle was invisible under any name. A follow-up keeps Hermes bundles as JavaScript components in the Apple, Android and Harmony application projections. No issue is linked: this was found while testing REA v6.10.1 against real macOS, iOS-on-Mac and Electron apps.Problem and expected behavior
Trigger: a React Native app whose bundle is
main.jsbundle(text or Hermes bytecode). The lane selected files by source suffix only, so the file was neither read nor counted. Expected: Hermes bytecode is recognized by its 8-byte magic and reported as unanalyzed application logic with partial coverage; a plain-text.jsbundleis parsed as JavaScript.Change and scope
hermes-bytecode(src/domain/artifactFormatRecognition.ts,src/domain/javascript/hermesBytecode.ts); the JavaScript lane takes that inventory fact before the path suffix. Bytes are digest-verified, never decoded; node Evidence and graph coverage are partial and a limitation names the file. REA does not decompile or disassemble Hermes bytecode..jsbundlejoins the JavaScript source suffixes.src/domain/javascript/javascriptApplicationFormats.ts) classifies JavaScript application components for the Apple, Android and Harmony projections, so a Hermes file no longer drops out ofcomponents.javascript(and Apple keeps the JavaScript runtime family and bridge candidates).Contribution scope: ordinary fix; no protection recovery or bytecode decoding added.
Contract and boundary impact
Semantic owner and earliest changed stage: the format recognizer table; the JavaScript lane and the three application projections consume its fact.
Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: new
artifact_formatvaluehermes-bytecode; coverage becomes partial where it was falsely complete.Provider, bridge, target-format, or platform compatibility: new target format vocabulary entry.
Evidence, artifact, provenance, or reconstruction contract: Hermes files are listed with digests and an explicit limitation; listing claims no analysis of their logic.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: generated catalog picks up the format value (validated by
docs:check).Read existing files or captured data.
Evidence and regression coverage
Tests added or updated:
tests/boundary/filesystem/javascriptHermesBytecodeCoverage.test.ts,tests/boundary/filesystem/hermesApplicationProjections.test.ts,src/domain/artifactFormatRecognition.test.ts,src/application/binary/TargetFormatVocabularies.test.ts.Base reproduction or other evidence: not reproduced at behavior level; the new boundary tests import the new
hermesBytecodehelper, so onorigin/mainthey fail at module load.User-visible CLI/MCP output:
rea analyze-javascript-application /Applications/Readwise.app/Wrapper/Readwise.app --json(Expo/React Native,main.jsbundlewith Hermes magic, version 96): before the fix application coverage wascompletewith no Hermes limitation; after it, coverage ispartialwith a limitation (also underunknowns) namingmain.jsbundleas Hermes bytecode that was not analyzed (about 1.3 s, 343 MB peak). Apple projection of the same app:components.javascriptgrows from the two extensionAction.jsfiles to also includemain.jsbundleashermes-bytecode, and bridge candidates grow from 22 to 33.Remaining proof gaps: Android and Harmony projections are covered by synthetic APK/HAP fixtures only.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run check:fast: passed.npm run test:local -- src/application/binary/TargetFormatVocabularies.test.ts src/domain/artifactFormatRecognition.test.ts src/domain/apple/appleApplication.test.ts src/application/javascript/JavaScriptArtifactGraphStructure.test.ts src/application/javascript/JavaScriptArtifactGraphAccumulator.test.ts src/domain/javascript/javascriptSourceParser.test.ts src/domain/javascript/javascriptSourceParserContext.test.ts: 7 files, 338 passed.npm run test:focused -- tests/boundary/filesystem/hermesApplicationProjections.test.ts tests/boundary/filesystem/javascriptHermesBytecodeCoverage.test.ts: 2 files, 5 passed.npm run docs:check: passed.Compatibility, safety, and release
Author readiness
Human owner: @lennartorlando
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.🤖 Generated with Claude Code