diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-03-21 17:08:17 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-03-21 17:17:22 +0900 |
| commit | bf8bd3c48d5d9420f6fde3331467c8dd41a26c6b (patch) | |
| tree | 4f505d4011b5ca2a6b49e2f9054f6513adb90730 /worker/php/exec.mjs | |
| parent | a4037c3bf5d66f1303ffa629f77ab7cdfd5f0eb6 (diff) | |
| download | phperkaigi-2026-albatross-main.tar.gz phperkaigi-2026-albatross-main.tar.zst phperkaigi-2026-albatross-main.zip | |
Add validation to reject PHP code containing eval() before execution.
Update the problem description to inform participants about this restriction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'worker/php/exec.mjs')
| -rw-r--r-- | worker/php/exec.mjs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/worker/php/exec.mjs b/worker/php/exec.mjs index f1cb361..650d4df 100644 --- a/worker/php/exec.mjs +++ b/worker/php/exec.mjs @@ -1,7 +1,22 @@ -import { buildResult, createIOCallbacks, preprocessCode } from "./lib.mjs"; +import { + buildResult, + createIOCallbacks, + preprocessCode, + validateCode, +} from "./lib.mjs"; import PHPWasm from "./php-wasm.js"; process.once("message", async ({ code: originalCode, input }) => { + const validationError = validateCode(originalCode); + if (validationError) { + process.send({ + status: "runtime_error", + stdout: "", + stderr: validationError, + }); + return; + } + const code = preprocessCode(originalCode); const io = createIOCallbacks(input); |
