Skip to content

fix(javascript): omit self-referential static references with disclosure - #1157

Merged
N0zoM1z0 merged 2 commits into
mainfrom
fix/javascript-self-referential-static-references
Oct 9, 2026
Merged

N0zoM1z0 merged 2 commits into
mainfrom
fix/javascript-self-referential-static-references

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1152 (#1146), as described in the comment on #1152.

Problem

#1152 made analyze_javascript_application survive a chunk requesting its own chunk ID. The same invariant ("Application graph edges cannot be self-referential") can still be reached through the static-reference composer, addReference in JavaScriptArtifactGraphFindings.ts. A bundled module that requires its own key resolves back to its own module node:

"use strict";(self.webpackChunkdemo=self.webpackChunkdemo||[]).push([[5],{50(e,t,r){r(50)}}]);

On main (after #1152), rea analyze-javascript-application <dir> --json returns:

{"code":"unreadable_output","details":{"operation":"analyze_javascript_application","reason":"Result schema rejected 1 issue at /edges/1 (custom)"}}

Change

Other self-reference shapes don't produce self-edges and are unchanged, because they resolve to distinct nodes:

Verification

  • tests/boundary/cli/javascriptBundlerSelfReferences.test.ts gains a compiled-CLI case. A module requiring itself and a sibling: no self-edges, one disclosed omission, and the sibling require edge kept. It fails on main.
  • All 39 test files that cover the JavaScript artifact graph, bundler registrations or analyze_javascript_application: 276 passed.
  • npm run check:fast, npm run jscpd

No real Hopper or Ghidra verification was run, because this change does not touch those providers.

🤖 Generated with Claude Code

A bundled module that requires its own key (`r(50)` inside webpack
module 50) resolved, through the static-reference composer, to its own
module node. The resulting self-referential imports edge failed result
validation and lost the entire analysis ("Result schema rejected 1
issue ... (custom)"). This is the same invariant as #1146; #1152 fixed
the bundler async-chunk composer, and this is the remaining adjacent
composer.

Skip a reference whose resolved target is its own source, count it, and
disclose the omission the way #1152 discloses async-chunk references.
Sibling requires are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T01:48:51.432754Z e04a673 PR opened
ℹ️ 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.

The self-import (#1130), async-chunk (#1152) and static-reference
disclosures repeated one sentence template in three composers, and the
new test repeated the analyze-and-check sequence of its neighbour. That
put jscpd at its 2.5% threshold. Share the template through
selfReferenceOmissions with identical wording, and share one test helper
for the graph-wide self-reference invariants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reproduced the self-require schema failure on the preceding fix, then independently passed 54 focused tests plus build/static checks here. The guard runs after worker projection, omits only an edge resolving to its own source, and discloses the count through both graph and result limitations. Sibling requires and original static observations remain available; the wording refactor preserves the existing import/chunk disclosures.

@N0zoM1z0
N0zoM1z0 merged commit b620e2a into main Oct 9, 2026
22 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/javascript-self-referential-static-references branch October 9, 2026 02:02
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…ure (morluto#1157)

* fix(javascript): omit self-referential static references with disclosure

A bundled module that requires its own key (`r(50)` inside webpack
module 50) resolved, through the static-reference composer, to its own
module node. The resulting self-referential imports edge failed result
validation and lost the entire analysis ("Result schema rejected 1
issue ... (custom)"). This is the same invariant as morluto#1146; morluto#1152 fixed
the bundler async-chunk composer, and this is the remaining adjacent
composer.

Skip a reference whose resolved target is its own source, count it, and
disclose the omission the way morluto#1152 discloses async-chunk references.
Sibling requires are kept.


* refactor(javascript): share the self-reference omission disclosure

The self-import (morluto#1130), async-chunk (morluto#1152) and static-reference
disclosures repeated one sentence template in three composers, and the
new test repeated the analyze-and-check sequence of its neighbour. That
put jscpd at its 2.5% threshold. Share the template through
selfReferenceOmissions with identical wording, and share one test helper
for the graph-wide self-reference invariants.


---------
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants