Skip to content

feat(sandbox): add util to QuickJS module registry - #10374

Open
kwburns-kong wants to merge 3 commits into
developfrom
feat/QuickJS-module-util
Open

feat(sandbox): add util to QuickJS module registry#10374
kwburns-kong wants to merge 3 commits into
developfrom
feat/QuickJS-module-util

Conversation

@kwburns-kong

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

Copy link
Copy Markdown
Contributor

Ports format, promisify, and types.is* from node:util as a pure-JS reimplementation in the QuickJS plugin sandbox, per the module-porting plan's reduced-scope entry for util.

  • format: verified against real node:util across all specifiers (%s %d %i %f %j %o %O %c %%), including the -0/bigint/symbol coercion quirks and the quote-character selection used for inspected strings.
  • promisify: error/multi-value/Symbol.for("nodejs.util.promisify.custom") override semantics verified against real node:util.
  • types.is*: implemented via instanceof (immune to Symbol.toStringTag spoofing) rather than Object.prototype.toString.call, except isAsyncFunction/isGeneratorFunction (documented in PERMISSIONS.md).
  • Explicit, documented exclusions: util.inspect/inherits/deprecate are not implemented; %o is aliased to %O's bounded-depth behavior rather than replicating real Node's showHidden/depth-4/proxy inspection.

Independent security review found no capability leaks or sandbox-escape paths; one documentation gap (isAsyncFunction/isGeneratorFunction's toStringTag-spoofability wasn't noted in PERMISSIONS.md) was fixed inline.

Ports node:util's format/promisify/types.is* as a pure-JS reimplementation, verified for parity against real node:util (including format's -0/bigint/symbol coercion quirks and quote-selection). util.inspect/inherits/deprecate and %o's showHidden/depth-4 behavior are explicitly out of scope — documented in PERMISSIONS.md.
Comment thread packages/insomnia/src/templating/sandbox/util.regression.test.ts Fixed
Comment thread packages/insomnia/src/templating/sandbox/util.regression.test.ts Fixed
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-08-11T14:21:39.088Z
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.

…-spoofability in PERMISSIONS.md

Found by the independent security review: unlike the rest of types.is*, these two use
Object.prototype.toString.call (no instanceof target exists for either), so a value with a forged
Symbol.toStringTag can produce a wrong boolean — a correctness gap, not a capability leak.
@kwburns-kong
kwburns-kong marked this pull request as ready for review August 11, 2026 14:09
Removes eval() from the format() parity test's literal-value comparisons (Semgrep
javascript.browser.security.eval-detected) by building the real node:util comparison value directly
instead of eval'ing the same source text used for the sandboxed side. Documents and suppresses the
CodeQL js/bad-code-sanitization finding on runBody's plugin-source construction — body is always a
fixed literal from within this file (never external input) and is expected to contain arbitrary JS
syntax, including quote/backtick characters that a generic sanitizer would corrupt.
// disposable, isolated QuickJS sandbox this whole file is testing, never on the host.
const runBody = (body: string) =>
runTagInSandbox({
pluginSource: `module.exports.templateTags = [{ name: 'r', run: function () { ${body} } }];`, // lgtm[js/bad-code-sanitization]
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.

2 participants