fix(supply-chain): detect indirect CommonJS loaders - #290
Draft
seonghobae wants to merge 23 commits into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #289.
Problem
The packed-bundle authority verifier uses a TypeScript AST to reject executable module lookup/loading authority without raw-text false positives. Its statically recognizable CommonJS coverage was incomplete across indirect loaders, resolver authority,
require.main.require(...),.call(...),.apply(...), built-inReflect.apply(...), and standardFunction.prototype.bind(...)compositions. Any missed form can leave runtime dependency lookup/loading authority in an artifact expected to be self-contained.Exact TDD lineage
Indirect CommonJS loaders
2d6cee41ecb7eb5bce9574eff96de7060886cfdf: exposed(0, require)(...),require.call(...), andmodule.require(...)misses.f616d0d776f4a186b4ecd52784fc142189e71690: bounded syntax-only recognition for those loader forms.Direct CommonJS resolver authority
dc3d47b1bb818ec0592619c5c6ee73e8da09a8c6: exposedrequire.resolve(...)/require['resolve'](...)misses while preserving ordinary-object negative controls.7a13161d3afc4dade60854f067d8b5c758b053bf: recognizes resolver access rooted at the CommonJS loader.Indirect CommonJS resolver authority
a4152db03576f2e886b4b14613800a4ce430f4b4: exposed comma- and.call-indirected resolver forms. Exact-head CI31766755958reached the intended package-verifier failure after setup/typecheck/tests/100% owned-production coverage/library build; Security Scan31766755977and SAST Semgrep31766755945succeeded.2193959432099d418e471d9b02683fff9e7112d6: syntax-only parentheses/comma-RHS/static.callhandling without alias or receiver evaluation.require.mainCommonJS loader authority1a78422433df7f2329ac6dc5ad2eb34b380b2aac: exposedrequire.main.require(...), element access,.call, and computed-specifier forms. Exact-head CI31768669536reached the intended package-verifier failure after setup/typecheck/tests/100% owned-production coverage/library build; Security Scan31768669375and SAST Semgrep31768669549succeeded.d2b52eca59f8b11def3e8714b8841538da6a8419: recognizes statically namedmainrooted at a recognized CommonJS loader while leaving ordinaryobject.main.require(...)benign.CommonJS
.applyauthority0f3f1d06a2ad0961f2bc7b4e7293c8d9c854d04a: addedrequire.apply(...),module['require']['apply'](...),require.main.require.apply(...), resolver.apply, computed payload controls, and ordinary-object negative controls. Exact-head CI31782543705passed immutable setup, typecheck, 143 test files / 827 tests, 100% aggregate owned-production statement/branch/function/line coverage, and library build before packed-package verification failed at the new regression.9dc017e787e6d4e3d49416141a39937325a3129d: recognizes statically named.apply/['apply']only when its receiver is already a recognized CommonJS loader or resolver. Static array payloads expose only the first package argument; unknown/computed/missing payloads remain authority withspecifier: undefined.Built-in
Reflect.applyCommonJS authorityb5a18634b2ee88a7798d82d228cdf4f88cf04ef7: addedReflect.apply(require, ...), element-accessReflect['apply'],module.require,require.main.require,require.resolve, computed payload controls, and ordinary-object negative controls. Exact-head CI31788362835passed immutable setup, typecheck, repository 100% coverage and library build before failing at packed-package verification.ff3459f48a5884e4894d742a949336d6b3ebce36: recognizes only statically writtenReflect.apply/Reflect['apply']whose target is already a recognized CommonJS loader/resolver; it does not resolve aliases, arbitrary receivers, computed member names, or executable values.Composed bound CommonJS authority
b7be216922681c33765a18696b36da2998880faa: addedrequire.bind(...).call(...), boundmodule.requirethrough.apply, boundrequire.main.requirethroughReflect.apply, resolver equivalents, computed-package evidence, and ordinary-object negative controls. Exact-head CI31881118310reached the intended packed-package failure after immutable install, typecheck, 144 test files / 828 tests, repository 100% statement/branch/function/line coverage, and library build; the new authority test expected five findings and observed none.da16556a0e4d85d2ca8998f8b4527f58c1d7bc78: recognizes a statically written.bindonly when its target is already recognized loader/resolver authority, preserves an explicitly prebound package argument ahead of later call/apply payloads, and composes that bounded syntax through.call,.apply, andReflect.apply. Computed prebound arguments remainspecifier: undefined; no alias, receiver, property, or caller code is evaluated.8f907dbb91da22ce47e39bf9346b8e494fb65db9: addsdocs/doctoring/commonjs-runtime-authority.md, explicitly labeled active-PR evidence, grounded in current Node.js CommonJS documentation and ECMA-262 2026 semantics for bound functions and reflective application.Current scanner contract
The verifier reports static imports/re-exports, dynamic
import(...), bare/parenthesized/comma-indirectedrequire, recognized CommonJS loader/resolver authority under direct invocation,.call,.apply, built-inReflect.apply,module.require,require.main.require,require.resolve, and statically composed.bindforms whose bound target is already recognized authority. Literal package specifiers remain actionable; computed or missing specifiers remainundefinedrather than receiving invented meaning. Comments, strings, template text, ordinary object methods merely namedrequire/resolve, arbitrary aliases, arbitrary receivers, and computed member names remain non-findings. Invalid emitted JavaScript fails closed.Exact-head evidence
Current exact head:
8f907dbb91da22ce47e39bf9346b8e494fb65db9.31881479808: completed / success on this exact head. Build-and-test passed immutable installation, typecheck, repository 100% coverage, library build, packed-package consumers, and demo build. Cross-engine Playwright and Office Python 3.11–3.14 also completed successfully on the same run.31881479815: queued / non-passing at the latest exact-head refresh.31881479830: queued / non-passing at the latest exact-head refresh.0.0.The independently refetched protected base remains exact
main@e8109ec2a17de8bd6594487aa12c8c8a93cb2c03; exact ancestry is 19 commits ahead / 0 behind with that SHA as merge base. Any head/base movement invalidates this evidence generation.Integration boundary
Keep this PR Draft and unmerged while #118 owns exact
v0.6.0publication from unchanged protected main and while live review/required-workflow policy remains unsatisfied. Live organization policy requires one qualifying independent approval, approval after the last push by another actor, resolved review threads, and the applicable central required workflows. This change hardens deterministic package/release evidence only; it adds no runtime module loader, filesystem, network, credential, persistence, deployment, model, or release authority.