You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@
7
7
8
8
Python sandbox runners for executing code in isolation aka snekbox.
9
9
10
+
Supports a memory [virtual read/write file system](#virtual-file-system) within the sandbox,
11
+
allowing text or binary files to be sent and returned.
12
+
10
13
A client sends Python code to a snekbox, the snekbox executes the code, and finally the results of the execution are returned to the client.
11
14
12
15
```mermaid
@@ -60,10 +63,26 @@ The main features of the default configuration are:
60
63
* Memory limit
61
64
* Process count limit
62
65
* No networking
63
-
* Restricted, read-only filesystem
66
+
* Restricted, read-only system filesystem
67
+
* Memory-based read-write filesystem mounted as working directory `/home`
64
68
65
69
NsJail is configured through [`snekbox.cfg`]. It contains the exact values for the items listed above. The configuration format is defined by a [protobuf file][7] which can be referred to for documentation. The command-line options of NsJail can also serve as documentation since they closely follow the config file format.
66
70
71
+
### Memory File System
72
+
73
+
On each execution, the host will mount an instance-specific `tmpfs` drive, this is used as a limited read-write folder for the sandboxed code. There is no access to other files or directories on the host container beyond the other read-only mounted system folders. Instance file systems are isolated; it is not possible for sandboxed code to access another instance's writeable directory.
74
+
75
+
The following options for the memory file system are configurable as options in [gunicorn.conf.py](config/gunicorn.conf.py)
76
+
77
+
*`memfs_instance_size` Size in bytes for the capacity of each instance file system.
78
+
*`memfs_home` Path to the home directory within the instance file system.
79
+
*`memfs_output` Path to the output directory within the instance file system.
80
+
*`files_limit` Maximum number of valid output files to parse.
81
+
*`files_timeout` Maximum time in seconds for output file parsing and encoding.
82
+
*`files_pattern` Glob pattern to match files within `output`.
83
+
84
+
The sandboxed code execution will start with a writeable working directory of `home`. By default, the output folder is also `home`. New files, and uploaded files with a newer last modified time, will be uploaded on completion.
85
+
67
86
### Gunicorn
68
87
69
88
[Gunicorn settings] can be found in [`gunicorn.conf.py`]. In the default configuration, the worker count, the bind address, and the WSGI app URI are likely the only things of any interest. Since it uses the default synchronous workers, the [worker count] effectively determines how many concurrent code evaluations can be performed.
0 commit comments