{"id":13527490,"url":"https://github.com/gf3/sandbox","last_synced_at":"2025-04-08T12:08:01.461Z","repository":{"id":39351137,"uuid":"478598","full_name":"gf3/sandbox","owner":"gf3","description":"A nifty JavaScript sandbox for Node.js","archived":false,"fork":false,"pushed_at":"2021-09-28T19:46:02.000Z","size":240,"stargazers_count":850,"open_issues_count":37,"forks_count":114,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-02T03:37:18.592Z","etag":null,"topics":["eval","javascript","nodejs","sandbox"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gf3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-01-19T07:10:01.000Z","updated_at":"2025-03-16T22:44:46.000Z","dependencies_parsed_at":"2022-07-20T02:33:04.418Z","dependency_job_id":null,"html_url":"https://github.com/gf3/sandbox","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gf3%2Fsandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gf3%2Fsandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gf3%2Fsandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gf3%2Fsandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gf3","download_url":"https://codeload.github.com/gf3/sandbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838444,"owners_count":21004580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eval","javascript","nodejs","sandbox"],"created_at":"2024-08-01T06:01:49.208Z","updated_at":"2025-04-08T12:08:01.438Z","avatar_url":"https://github.com/gf3.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003e:beach_umbrella: sandbox\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  A nifty JavaScript sandbox for Node.js.\n  \u003cbr /\u003e\n  \u003ca href=\"https://github.com/gf3/sandbox/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/gf3/sandbox\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/gf3/sandbox/actions\"\u003e\u003cimg src=\"https://github.com/gf3/sandbox/actions/workflows/tests.yml/badge.svg?branch=main\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## What is it?\n\n**It can...**\n\n- [x] Be used to execute untrusted code\n- [ ] Timeout long-running code and infinite loops\n- [x] Handle errors gracefully\n- [x] Run restricted code\n- [x] Pass rich data structures back\n- [ ] Capture console output\n\n```js\nconst s = new Sandbox();\n\ns.eval(\"const o = { answer: 4.2 }; o\", function(err, res) {\n  console.log(\"The answer is: %d\", res.answer * 10); // The answer is: 42\n});\n```\n\n## Installation\n\n```sh\nnpm install --save sandbox\n```\n\nBy default the package will attempt to download the corresponding binary release\nfor your platform. If you wish to skip this action you can set the\n`SANDBOX_SKIP_DOWNLOAD` environment variable:\n\n```sh\nenv SANDBOX_SKIP_DOWNLOAD=1 npm install --save sandbox\n```\n\n## Usage\n\n**NOTE**: As it stands, only values that can be serialized to JSON may be\nreturned.\n\n## About\n\n`sandbox` is a tool to allow safe local execution of JavaScript.\n\nThe previous version of `sandbox` attempted to accomplish this by spawning a\nchild process and running the untrusted code in a new Node.js context with known\nexploits patched. Unfortunately this didn't work well from a security standpoint\nand it became increasingly difficult to keep up with the whack-a-mole of\nsecurity vulnerabilities. In fact, the previous version still has unaddressed\nvulnerabilities that are impossible to patch with that architecture.\n\nThe current version of `sandbox` takes a new approach—it embeds a JavaScript\ninterpreter in the library which executes code in a separate context in another\nthread. This is made possible with the help of two incredible projects:\n\n- [Boa][doc-boa] - a JavaScript interpreter written in [Rust][doc-rust]\n- [Neon][doc-neon] - a library for interfacing with [Node-API][node-napi]\n\nThe major drawback to this approach is that it either requires the user to build\nthe `sandbox` locally from source (which requires the user to have the rust\nbuild tools onhand) or provide pre-built binaries for every platform would need\nto be provided. In order to make things a little more seamless for users, we've\nopted to provided pre-built binaries for the following platforms:\n\n- Linux x86_64\n- MacOS arm64\n- MacOS x86_64\n- Windows x86_64\n\nGiven these targets we should be able to meet the needs of most users.\n\n## Building\n\nFirst, if you don't already have the rust toolchain installed you can follow the\ninstructions for installing rustup:\n\n[Install rust][rust-install].\n\nNext, running `npm run build` will attempt to build the project with\n[cargo][doc-cargo] and move the compiled binary to `./index.node`.\n\nAt this point you should be able to work with `sandbox` and run the tests: `npm\ntest`.\n\n## Learn More\n\nTo learn more about Neon, see the [Neon documentation][doc-neon].\n\nTo learn more about Rust, see the [Rust documentation][doc-rust].\n\nTo learn more about Node, see the [Node documentation][doc-node].\n\n[doc-boa]: https://github.com/boa-dev/boa\n[doc-cargo]: https://doc.rust-lang.org/stable/cargo/\n[doc-neon]: https://neon-bindings.com\n[doc-node]: https://nodejs.org\n[doc-rust]: https://www.rust-lang.org\n[node-napi]: https://nodejs.org/dist/latest-v14.x/docs/api/n-api.html#n_api_node_api\n[rust-install]: https://www.rust-lang.org/tools/install\n","funding_links":[],"categories":["Repository"],"sub_categories":["Sandbox"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgf3%2Fsandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgf3%2Fsandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgf3%2Fsandbox/lists"}