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
Refactor to centralize AST security checks in security.py
- Moves shared AST blocklist logic to `security.py` for reuse across `preview_function` and `evaluation_function`.
- Updates `Dockerfile` to enable `nsjail`-based sandboxing for untrusted submissions.
- Adds unit tests for `check_code_safety` and integration tests for security gate in `evaluation_function`.
- Updates documentation to reflect the centralized security check, sandbox requirements, and testing changes.
-`evaluation_function/security_test.py` — unit tests for `check_code_safety` (the shared AST blocklist used by both `preview_function` and `evaluation_function`)
138
141
139
142
CI runs on Python 3.12 and uploads JUnit XML results (`.github/workflows/test-lint.yml`).
140
143
@@ -146,14 +149,18 @@ CI runs on Python 3.12 and uploads JUnit XML results (`.github/workflows/test-li
146
149
|`MPLBACKEND`|`Agg`| Set at subprocess runtime to suppress GUI |
Dependencies managed via Poetry; `.venv` is created in-project (`poetry.toml`).
154
161
155
162
## Deployment
156
163
157
164
- Push to `main` triggers GitHub Actions (`.github/workflows/`) which builds and deploys to Lambda Feedback automatically
158
165
- The function name is declared in `config.json` as `EvaluationFunctionName: "evaluatePython"` (lowerCamelCase)
159
-
- The base Docker image is `ghcr.io/lambda-feedback/evaluation-function-base/python:test-sandbox-3.12`
166
+
- The base Docker image is `ghcr.io/lambda-feedback/evaluation-function-base/python:3.12` (bundles shimmy + nsjail; sandboxing is enabled via the `SANDBOX_*` env vars in the Dockerfile, not by the base tag)
Copy file name to clipboardExpand all lines: README.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,13 @@ Push to `main` triggers GitHub Actions which automatically builds and deploys to
12
12
### Run the Docker Image
13
13
14
14
```bash
15
-
docker run -it --rm -p 8080:8080 ghcr.io/lambda-feedback/evaluatepython:latest
15
+
docker run -it --rm --privileged -p 8080:8080 ghcr.io/lambda-feedback/evaluatepython:latest
16
16
```
17
17
18
18
The image includes [Shimmy](https://github.com/lambda-feedback/shimmy), which listens for HTTP requests on port 8080 and forwards them to the evaluation function.
19
19
20
+
`--privileged` (or `--cap-add SYS_ADMIN`) is required: the image runs student code inside Shimmy's [nsjail](https://github.com/google/nsjail) sandbox (`SANDBOX_ENABLED=true`), and nsjail needs those privileges to create its namespaces. The sandbox runs the worker as `nobody` with a minimal bind-mounted filesystem and seccomp filtering; untrusted imports/builtins are additionally rejected before execution by the AST check in `evaluation_function/security.py`.
21
+
20
22
### Evaluation Modes
21
23
22
24
The function supports three modes, set via `params.mode`.
@@ -80,10 +82,12 @@ Add `"pep8_feedback": true` to any mode to append a style check to the feedback.
80
82
```
81
83
evaluation_function/main.py # IPC server entry point
82
84
evaluation_function/evaluation.py # core evaluation pipeline (all three modes)
docker run -it --rm --privileged -p 8080:8080 evaluatepython
148
152
```
149
153
154
+
`--privileged` is required for the nsjail sandbox (see [Run the Docker Image](#run-the-docker-image)). To run without it for local debugging, disable the sandbox: add `-e SANDBOX_ENABLED=false`.
155
+
150
156
## Deployment to Lambda Feedback
151
157
152
158
The function name is declared in [`config.json`](config.json) as `"evaluatePython"` (lowerCamelCase). Pushing to `main` triggers automated deployment via GitHub Actions.
0 commit comments