npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

isolated-eval

v0.0.3

Published

Eval js but in an isolated environment

Downloads

87

Readme

Isolated-eval

Based on the great module isolated-vm.

This module attempts to mimic the eval function with the following objectives:

  • [x] Isolate the execution
  • [x] Timeout long running scripts
  • [x] Resolve promises (only in async)
  • [x] Restrain the context (no access to globalThis, process)

These should make the execution much more secure with arbitrary input scripts coming from the user.

Install

npm i isolated-eval

Usage

Synchronous

import { isolatedEvalSync } from 'isolated-eval'; // typescript
const { isolatedEvalSync } = require('isolated-eval'); // nodejs

const context = { data: 1 }

const evaluated = isolatedEvalSync(
  "data + 1",
  context
)
console.log(evaluated); // 2

Asynchronous

import { isolatedEval } from 'isolated-eval'; // typescript
const { isolatedEval } = require('isolated-eval'); // nodejs

const context = { data: 1 }

const evaluated = await isolatedEval(
  "Promise.resolve(1 + data)",
  context
)
console.log(evaluated); // 2

Security Notice

This module deals with probably the most sensitive part of javascript because it opens a lot of possibilities. You should always be aware of the risks of using it, past has proven that no use of this kind of module can be made bullet proof for a very long time (see eval, safe-eval, safer-eval, they all have vulnerabilities).

When using this module, you should always make sure to apply the following principles :

  • Never give the user the ability to set the context unless you have very strict validation
  • When giving the user the ability to set the code (for a lambda for example), make sure a timeout is set to mitigate possibilities of DOS

Any security issue should be reported in the security tab, I will do my best to mitigate them as much as possible.

Roadmap

  • Fuzzy testing
  • Unifying async and sync interfaces