feat(sandbox): add buffer to QuickJS module registry - #10367
Open
kwburns-kong wants to merge 2 commits into
Open
feat(sandbox): add buffer to QuickJS module registry#10367kwburns-kong wants to merge 2 commits into
kwburns-kong wants to merge 2 commits into
Conversation
Extends the existing ambient Buffer shim (sandbox-globals.ts) with
slice/subarray/indexOf/lastIndexOf/includes/compare/equals/fill, and adds
require('buffer') as a thin re-export matching real Node's
require('buffer').Buffer === global.Buffer identity. Buffer itself stays an
ungated ambient global, as before; the module grant adds no new restriction
(documented in PERMISSIONS.md). Adds a narrow, documented allowlist entry to
findLeakedGatedReferences for this intentional alias.
✅ Circular References ReportGenerated at: 2026-08-10T18:58:20.056Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
…mpty needle
buf.indexOf('', n) and buf.includes('', n) returned -1 for an offset past the
buffer's end instead of clamping to this.length, diverging from real Node
(lastIndexOf's equivalent branch already clamped correctly). Fixes the parity
gap and adds a regression test asserting both methods against real
node:Buffer for past-end, at-end, and negative offsets.
kwburns-kong
marked this pull request as ready for review
August 10, 2026 18:55
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.
Extends the existing ambient
Buffershim (sandbox-globals.ts) withslice/subarray/indexOf/lastIndexOf/includes/compare/equals/fill, verified against real Node'sBuffer. Addsrequire('buffer')as a thin re-export —Bufferitself stays an ungated ambient global (as before), so the module grant adds no new restriction; documented explicitly in PERMISSIONS.md rather than implied. Also adds a narrow, documented allowlist entry tofindLeakedGatedReferencesfor this intentionalrequire('buffer').Buffer === globalThis.Bufferalias (matches real Node's own identity).Part of the legacy-module porting plan (
packages/insomnia/src/templating/sandbox/plans/). Milestone 4a; security review (4b) is a separate pass.Security review (4b): completed.
Buffer's ambient/ungated status was confirmed to predate this PR (introduced in #10220's M2 pass, not widened here);slice()/subarray()'s shared-memory semantics,fill()'s throw-on-non-numeric behavior, and thefindLeakedGatedReferencesallowlist reasoning were all independently re-verified and hold. One correctness bug was found and fixed directly on this branch:indexOf()/includes()returned-1instead of the real-Node-matching clampedthis.lengthfor an empty needle past the buffer's end; fixed with a new parity regression test. Full detail inpackages/insomnia/src/templating/sandbox/SANDBOX-SECURITY-FINDINGS.md(local, uncommitted working doc — not part of this diff).