Skip to content

fix(javascript): decline NUL source-map matching paths - #7729

Closed
HeadmasterEggy wants to merge 1 commit into
morluto:mainfrom
HeadmasterEggy:codex/source-map-nul-path
Closed

HeadmasterEggy wants to merge 1 commit into
morluto:mainfrom
HeadmasterEggy:codex/source-map-nul-path

Conversation

@HeadmasterEggy

@HeadmasterEggy HeadmasterEggy commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Source-map declarations such as bad%00.ts currently become usable matching paths containing a NUL byte. These cannot name filesystem entries. Retain the declaration and content evidence, but mark that path interpretation unresolved.

 decode source-map URL pathname
+if decoded pathname contains NUL:
+  return unresolved with reason
 derive artifact-relative or suffix matching path

Change and scope

The shared source-map path producer owns the correction. URL identity resolution remains unchanged. Existing source comparison and feature-seed consumers already skip unresolved path facts; source-content digests remain available independently. No downstream repair or new abstraction is needed.

Ordinary local static-analysis fix; no new provider or execution capability, so a separate maintainer scope decision is not applicable. Tool/schema shapes, installation and generated outputs are unchanged. Effects: read selected local artifacts through existing CLI/MCP analysis; no additional execution, network or mutation authority.

Evidence

  • Before: on base 2b8fb387b, the new public CLI and stdio MCP regressions both failed: root%00/original.ts produced {kind:"artifact-relative", path:"root\u0000/original.ts"}.
    After: both return {kind:"unresolved", reason:"Source reference contains a NUL byte and cannot name a filesystem path."}.
  • The tests cover encoded and literal NUL, file/HTTP/Windows-style references, and NUL in sourceRoot. Controls preserve ordinary paths and decode literal%2500.ts exactly once to the valid literal spelling literal%00.ts.
  • Raw source names, source roots, map SHA-256 and original-content SHA-256 remain intact. Valid sibling declarations and complete declaration coverage survive.

Executed on macOS with Node 24.22.1 / npm 11.16.0:

  • npm run test:focused -- tests/acceptance/applications/sourceMapPrefixCli.test.ts src/domain/javascript/sourceToBundleComparison.test.ts: 39 passed.
  • npm run check:fast: passed, including a fresh pre-push run.
  • Changed-file Oxfmt and git diff --check: passed.

This establishes incorrect path facts and their correction, not a crash or exploitable filesystem operation. Fixtures are generated source maps; no real browser capture, native Windows IO or Hopper/Ghidra execution was run. Existing consumer behavior was inspected in source; no new end-to-end comparison-performance claim is made.

Remote verification for head 47dd004fe00fe194cf947e4ec143f0a34a36b81e: CI run 40652752493 passed, including all eight portable test shards, source tests, static checks, build, documentation, real JavaScript recovery, and the Linux x64 native package baseline. Greptile reported no blocking findings. Unselected provider/platform lanes were skipped; this does not establish native Windows execution or real browser source-map capture. Draft author-readiness checks do not attest to human review.

Merge Danger

Door: two-way

Blast Radius: narrow

Only decoded NUL source-map path interpretations change. Original declaration identities and content evidence remain admitted.

Author readiness

Human owner: @HeadmasterEggy

  • 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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR marks decoded source-map paths containing NUL as unresolved without discarding the declarations or their content evidence.

  • Source-map paths with decoded NUL bytes stay out of matching.

Reviews (1) · Last reviewed commit: "fix(javascript): decline NUL source-map ..." · Reviewed by Greptile

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the test file for this fix on three Node versions, and all 14 tests pass at the head. With the old javascriptSourceMapPaths.ts swapped back in, 2 tests fail on all three versions, so those tests fail without the fix. I did not try a real bundle or a merge with current main.

I ran tests/acceptance/applications/sourceMapPrefixCli.test.ts.

Run Node 22.23.4 Node 24.22.1 Node 26.12.1
Head 47dd004 pass: 1 file, 14 tests pass: 1 file, 14 tests pass: 1 file, 14 tests
Red run (old src/domain/javascript/javascriptSourceMapPaths.ts from 2b8fb38) fail: 2 failed, 12 passed fail: 2 failed, 12 passed fail: 2 failed, 12 passed
  • The two failures in the red run are retains source-map declarations without admitting NUL filesystem paths through CLI and ... through stdio MCP.
  • The old code returns { kind: "artifact-relative", path: ... }. The tests expect { kind: "unresolved", reason: "Source reference contains a NUL byte and cannot name a filesystem path." }.
  • Both tests fail without the fix and pass with it.
  • CI on 47dd004: all 23 check runs that ran passed, including CI required and javascript_recovery. The PR readiness check passed, but its commit status is pending, and GitHub's merge state is unstable.
  • The head is 685 commits behind main b81da90. GitHub says the PR is mergeable.

Not run

  • A real bundle whose source map names a path with a NUL byte.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 47dd004 / 2b8fb38 (merge base with main)
  • Red run: 47dd004 with src/domain/javascript/javascriptSourceMapPaths.ts from 2b8fb38
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/acceptance/applications/sourceMapPrefixCli.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 19, 2026

Copy link
Copy Markdown
Owner

The shared source-map path reader now marks NUL-bearing matching paths unresolved while retaining the source declaration and content. This landed in #12161. Thanks for the original regression coverage.

@morluto morluto closed this Nov 19, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 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