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.0.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.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (81.2 MB view details)

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

runno-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl (79.7 MB view details)

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

runno-0.2.0-cp313-cp313-macosx_15_0_x86_64.whl (77.4 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

runno-0.2.0-cp313-cp313-macosx_15_0_arm64.whl (76.9 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

File details

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

File metadata

  • Download URL: runno-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 67baca40330f474dc43bb4a35b7df30bb39b774f4ff2304bc6443addfc9482e1
MD5 816441a8894cb1041cdbc74968f4e3c4
BLAKE2b-256 b8200e9b330d72c4752a345f905c2842ed89fbc044044b9bc992661dd27b66e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for runno-0.2.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab94e9b11e3df17b19d4e1729994639a597bb29a9f14f0580209c72036cdc215
MD5 9babf84b0fd0a09a8f9ce4a56b0cf3d2
BLAKE2b-256 6d9269f5d7f8a6783bc657ce672ea4316c30c63cd0affc63f1e27234fe0f4531

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for runno-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ec56ab8c3f6682eb550f4e36bd49bb701816c5c5f2c3677e9837269200b002f2
MD5 b84e67b084d3a08630a3361e3d647718
BLAKE2b-256 6e8d56d2b7d4416c4f36c869a5652eda23ec316ddd25a63c244bb0c3010451be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for runno-0.2.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 038a06597fce576095cb4a6cf6defd2879f35d931414e8187cbd4be366696814
MD5 4c98d3735987825e2cb32fec08bded38
BLAKE2b-256 5767524c73904fb938b0ee5d295c235ba694522e428d569d2ca646ca1f6144a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for runno-0.2.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 052038ccaec210d9ab68b9c96a218b94b95a7923563190ba965290b2d0c19f4b
MD5 5ccef2299335fa6e985330a9dbc21df0
BLAKE2b-256 e79fd0483f6a700bb7cdbd04853632491bdec47f362bd7d8bb9c08dde34ccb6d

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