mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #3973] [MERGED] chore: migrate Node.js implementation for js-sandbox to isolated-vm #4620
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#4620
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/3973
Author: @jamesgeorge007
Created: 4/12/2024
Status: ✅ Merged
Merged: 4/19/2024
Merged by: @AndrewBastin
Base:
release/2024.3.1← Head:sandbox-vulnerability-remediation📝 Commits (10+)
5cc8716chore: migrate JS sandbox to isolated-vm23e959afix: pre-request script executionbac9743refactor: serialize test script API methods before sending to the isolatec2bd74achore: migrate test framework to vitestd75a76dchore: resolve build errors wrt wrt CJS interop with ESM318402drefactor: leverage Proxy to intercept scripting API calls023072erefactor: spawn child process to add no-node-snapshot flag when required0e2d2d0chore: bump jest timeout for test.spec.ts27d58c0fix: condition to spawn child process7eca5bachore: makeisolated-vma peer-dependency📊 Changes
52 files changed (+1029 additions, -286 deletions)
View changed files
📝
.github/workflows/tests.yml(+7 -8)📝
packages/hoppscotch-cli/bin/hopp.js(+26 -1)📝
packages/hoppscotch-cli/package.json(+2 -1)📝
packages/hoppscotch-cli/src/__tests__/commands/test.spec.ts(+1 -1)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v0.json(+53 -25)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v1-req-v1.json(+52 -3)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v2.json(+58 -3)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/coll-v2-req-v3.json(+58 -3)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/secret-envs-coll.json(+51 -21)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/secret-envs-persistence-coll.json(+13 -13)📝
packages/hoppscotch-cli/src/__tests__/samples/collections/secret-envs-persistence-scripting-coll.json(+2 -2)📝
packages/hoppscotch-cli/src/__tests__/samples/environments/secret-envs.json(+6 -1)📝
packages/hoppscotch-cli/src/__tests__/samples/environments/secret-supplied-values-envs.json(+6 -1)📝
packages/hoppscotch-cli/src/__tests__/utils.ts(+18 -11)📝
packages/hoppscotch-cli/src/index.ts(+2 -1)📝
packages/hoppscotch-cli/src/utils/mutators.ts(+36 -18)➖
packages/hoppscotch-js-sandbox/jest.config.js(+0 -10)➖
packages/hoppscotch-js-sandbox/jest.setup.ts(+0 -1)📝
packages/hoppscotch-js-sandbox/node.d.ts(+2 -2)📝
packages/hoppscotch-js-sandbox/package.json(+11 -3)...and 32 more files
📄 Description
Description
This PR aims at migrating the sandbox implementation for
Node.jsfrom node:vm to isolated-vm.Ref: https://github.com/hoppscotch/hoppscotch/security/advisories/GHSA-qmmm-73r2-f8xr
Closes HFE-475.
Changes
isolated-vmas a peer dependency (there were issues with not being able to requireisolated-vmwhen it was made a direct dependency) tojs-sandboxand mark it optional since it's specific to theNode.jsimplementation. Also, it is added as a direct dependency on the CLI.Jest(support for ESM is experimental) toVitestforjs-sandbox.js-sandbox.node,web) instead of the type of scripts (pre-request&test-runner) easily accommodating platform-specific utility functions.~/src/utils.tsat the root compiling utility functions reused across platform implementations is renamed to~/src/shared-utilsto differentiate between platform-specific utils~/src/node/utils.ts.testingdirectory from the test suite and enforce a naming convention for the directories based on the scripting API namespace objects (env,expect, etc).pw.expect(expectVal)is stringified with an additional propertyisStringifiedWithinIsolateif it's a non-primitive while transferring to the isolate context as required byisolated-vm. The value is parsed at thepw.expectmethod definition after checking for the above additional property to differentiate between stringification done while transferring to the isolate context and an original value. The newly introduced property is removed before consumption.Node.jsversion is20and above from the CLI supplying the--no-node-snapshotflag tonodeas required byisolated-vm, Ref and later proceed with the argument parsing phase.folderswithin collections while validating against the versioned entity schema and translating to the latest version. Follow up of #3912.200status code).Setup nodestep aboveSetup pnpm.Checks
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.