Skip to main content

Run untrusted code inside the Runno WebAssembly sandbox.

Project description

runno

Package for running code inside the Runno WebAssembly sandbox.

Quickstart

The run_code method allows you to run a snippet of code.

from runno import run_code

code = "print('Hello, World!')"
result = await run_code("python", code)

if result.result_type == "complete":
    print("OUTPUT:")
    print(result.tty)
else:
    print("ERROR")

Available runtimes are: python, quickjs, sqlite, clang, clangpp, ruby, and php-cgi.

Including Files

If you want to process files within your sandbox, you can include them in the file system by using the run_fs method.

from runno import run_fs, WASIFS, StringFile, WASITimestamps

fs: WASIFS = {
    "/program.py": StringFile(
        path="/program.py",
        timestamps=WASITimestamps(
            access=datetime.now(),
            modification=datetime.now(),
            change=datetime.now(),
        ),
        mode="string",
        content="""
print(open('data.csv'))
""",
    ),
    "/data.csv": StringFile(
        path="/data.csv",
        timestamps=WASITimestamps(
            access=datetime.now(),
            modification=datetime.now(),
            change=datetime.now(),
        ),
        mode="string",
        content="""
a,b,c
1,2,3
""",
    )
}

await run_fs(runtime, "/program", fs)

Including Dependencies

You can use the same technique to include pure python packages as dependencies. The interface for this is not super nice right now, but it's on the way.

Limiting Execution Time

You can limit how much time is allocated for execution using an optional timeout kwarg (measured in seconds). Like:

from runno import run_code

code = "while True: pass"
result = await run_code("python", code, timeout=5)

if result.result_type == "timeout":
    print("Timed out.")
else:
    print("Wow, it ran forever.")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

runno-0.2.1.tar.gz (47.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

runno-0.2.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (80.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

runno-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl (79.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

runno-0.2.1-cp313-cp313-macosx_15_0_x86_64.whl (76.5 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

runno-0.2.1-cp313-cp313-macosx_15_0_arm64.whl (76.1 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

File details

Details for the file runno-0.2.1.tar.gz.

File metadata

  • Download URL: runno-0.2.1.tar.gz
  • Upload date:
  • Size: 47.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for runno-0.2.1.tar.gz
Algorithm Hash digest
SHA256 753450c3692fd0c758145046cc65fe28c9097fd77de895f4aa60347c11c4bb38
MD5 db8c8914b9f53af3b97673f0bb8cd719
BLAKE2b-256 a0eed5326365f32167561f9d7c20da13b74cb3c817046beb92603092e5b6f279

See more details on using hashes here.

File details

Details for the file runno-0.2.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for runno-0.2.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14310f07bf30937262bd726150e64676279ce752eeb8fa4640b329a4aa536d44
MD5 4fca10139575e0c849af227adc1f7f97
BLAKE2b-256 46bb0cb6fa0034650328e43d7f5505f9071d90d737e4f9c67cd75f05df6eb58a

See more details on using hashes here.

File details

Details for the file runno-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for runno-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e59ca4e4bd69ae60e7e5d28320761814dd0eab16d21049d7caab15a6572fe645
MD5 fb6d551714d3809d90c1b1b48f99e391
BLAKE2b-256 1bd5656a83a6424c2165d8e4d906bb855c5c282aea3ed134678394f1d7283916

See more details on using hashes here.

File details

Details for the file runno-0.2.1-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for runno-0.2.1-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 8b7f8288253b34feef47fde6b5e392def94bc57cca5d56d7e070187c77205f7e
MD5 d157f0a0cb0bc4bbaa538d8ab753b084
BLAKE2b-256 dd638dac8c622287bda255423bb4346a2bd1291d22fdb3644ef42710efa98a43

See more details on using hashes here.

File details

Details for the file runno-0.2.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for runno-0.2.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9e662ba60896a40058521b1096965c2a6630a0d4d17058001864bc07f45e8c0c
MD5 d3aa5e10ce96d3280bc1e9298ee09507
BLAKE2b-256 17bb7e99a24b84312446d8d8c8986f8ec799268be990f6ad14aaa2d38ca6c2ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page