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

code-execution-engine

v0.4.6

Published

A fast and secure Code-Execution-Engine in Javascript.

Downloads

85

Readme

Maintenance GitHub license npm GitHub last commit npm

Code-Execution-Engine

A fast and secure Code-Execution-Engine in Javascript.

❗This package is not secure by default. Visit Security for production projects.❗

Table of Contents

Installation

Use the package manager npm to install Code-Execution-Engine.

$ npm install code-execution-engine

Or use the yarn package manager.

$ yarn add code-execution-engine

Usage

const cee = require("code-execution-engine");

cee
  .execute("print('Hello World')", cee.languages.PYTHON3, [], "", {
    timeout: 5,
  })
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error);
  });

execute(input, language, [args], [stdin], [options]) → Promise<String>

Returns the result (stdout) of the executed code. If stderr is not empty, an exception will be thrown with the content of stderr.

input: string – The source code that should be executed.

language: cee.Language – Pass the language the code is written in, for example, cee.languages.PYTHON3. Supported Lanuages

args: string[] - Command-Line arguments that are passed to the script

stdin: string - Set the stdin for the script

options: IExecuteOptions

      timeout: number - Max execution time of the script. This option doesn't work on windows. Defaults to 5

Supported Languages

Get the supported languages on your platform by calling

cee.getSupportedLanguages();

| | Linux / MacOS | Windows | | :----------: | :-----------: | :-----: | | Python3 | ✔️ | ✔️ | | Python2 | ✔️ | ✔️ | | Javascript | ✔️ | ✔️ | | Ruby | ✔️ | ✔️ | | Go | ✔️ | ✔️ | | Batch | | ✔️ | | Bash | ✔️ | | | C | ✔️ | | | C++ | ✔️ | | | Java | ✔️ | |

More supported languages coming soon.

Security

IMPORTANT: There are no security modules available for windows!

const cee = require("code-execution-engine");

const executor = new cee.LXC("[NAME OF YOUR LXC-CONTAINER]");

// Run this function after the installation of the container
executor.init({
  runners: 150,
  // limitations per runner
  maxProcesses: 64,
  maxFiles: 2048,
});

executor
  .execute("echo 'Im in a secure environment!'", cee.languages.BASH)
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error);
  });

To use LXC, follow the instructions below to set up LXC.

LXC

LXC's are Linux containers, that run the code in a different and secure environment. To use them, you need to install them first. LXC's are only available on Linux-Systems.

To use this package with LXC, you need to install an unprivileged container.

Follow these instructions: linuxcontainers.org

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Credits

Inspired by: engineer-man/piston

License

MIT