Skip to content

feat(sandbox): add buffer to QuickJS module registry - #10367

Open
kwburns-kong wants to merge 2 commits into
developfrom
feat/QuickJS-module-buffer
Open

feat(sandbox): add buffer to QuickJS module registry#10367
kwburns-kong wants to merge 2 commits into
developfrom
feat/QuickJS-module-buffer

Conversation

@kwburns-kong

@kwburns-kong kwburns-kong commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Extends the existing ambient Buffer shim (sandbox-globals.ts) with slice/subarray/indexOf/lastIndexOf/includes/compare/equals/fill, verified against real Node's Buffer. Adds require('buffer') as a thin re-export — Buffer itself 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 to findLeakedGatedReferences for this intentional require('buffer').Buffer === globalThis.Buffer alias (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 the findLeakedGatedReferences allowlist reasoning were all independently re-verified and hold. One correctness bug was found and fixed directly on this branch: indexOf()/includes() returned -1 instead of the real-Node-matching clamped this.length for an empty needle past the buffer's end; fixed with a new parity regression test. Full detail in packages/insomnia/src/templating/sandbox/SANDBOX-SECURITY-FINDINGS.md (local, uncommitted working doc — not part of this diff).

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.
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-08-10T18:58:20.056Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 9 9 0 (0.00%)
Click to view all circular references in PR (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

…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
kwburns-kong marked this pull request as ready for review August 10, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant