fix: use stateful mode for cloud-run and handle missing packages - #202
fix: use stateful mode for cloud-run and handle missing packages#202HeyGarrison wants to merge 2 commits into
Conversation
Contributor License AgreementAll contributors are covered by a CLA. |
Sandbox Benchmark ResultsSequential
Staggered
Burst
View full run · SVGs available as build artifacts |
Sandbox Dax Benchmark Results
|
6e4de59 to
ef25190
Compare
| --region "$REGION" \ | ||
| --project "$PROJECT_ID" \ | ||
| --sandbox-launcher \ | ||
| --allow-unauthenticated \ |
There was a problem hiding this comment.
P2: Cloud Run service deployed with --allow-unauthenticated allowing public unauthenticated access
Cloud Run deployed without IAM auth, allowing public access to sandbox gateway.
Remove --allow-unauthenticated and enforce Cloud Run IAM invocation permissions.
AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.
<file name="scripts/setup-cloud-run-gateway.sh">
<violation number="1" location="scripts/setup-cloud-run-gateway.sh:64">
<priority>P2</priority>
<title>Cloud Run service deployed with --allow-unauthenticated allowing public unauthenticated access</title>
<evidence>The gcloud beta run deploy command includes --allow-unauthenticated, which disables Cloud Run IAM authentication and allows any unauthenticated user to invoke the service. Combined with --sandbox-launcher (a beta feature providing arbitrary code execution) and a container containing build tools, this exposes the sandbox to internet-wide reconnaissance and potential exploitation if the application-level SANDBOX_SECRET is bypassed or the gateway has vulnerabilities.</evidence>
<recommendation>Remove --allow-unauthenticated and configure Cloud Run IAM to restrict invocation to authorized service accounts. If public access is architecturally required, add Cloud Armor for DDoS protection and IP allowlisting, and ensure the SANDBOX_SECRET is complemented with infrastructure-layer authentication.</recommendation>
</violation>
</file>
ef25190 to
6e4de59
Compare
| createCompute: () => cloudRun({ | ||
| sandboxUrl: process.env.CLOUD_RUN_SANDBOX_URL!, | ||
| sandboxSecret: process.env.CLOUD_RUN_SANDBOX_SECRET!, | ||
| executionMode: 'stateful', | ||
| write: true, | ||
| allowEgress: true, | ||
| }), |
There was a problem hiding this comment.
🔍 cloud-run provider options depend on unverified package types
The new executionMode: 'stateful', write: true, and allowEgress: true options passed to cloudRun(...) at src/sandbox/providers.ts:59-65 could not be validated against the @computesdk/cloud-run@^0.1.7 type definitions since node_modules is not installed in this checkout. If any of these keys are not part of the provider's options contract, TypeScript would flag it in CI (so this is not reported as a bug), but a reviewer should confirm the option names/values are accepted and actually honored by the installed cloud-run version.
Was this helpful? React with 👍 or 👎 to provide feedback.
Cloud Run's default ephemeral mode (sandbox do) creates a fresh sandbox for each command with no filesystem persistence. Switch to stateful mode (sandbox run/exec/delete) with write=true and allowEgress=true for persistent sessions that support the benchmark's clone+install+typecheck workload. Also fix the benchmark script to handle minimal package lists (e.g. cloud-run gVisor images that lack python3-setuptools and unzip): - Split apt/dnf install into required (must succeed) and optional (can fail) package groups - Add Python zipfile fallback for unpacking bun when unzip is unavailable
apt-get installs nothing when any argument is unknown, so filter unavailable optional packages instead of splitting them into a second install pass, and extract bun via a heredoc-quoted Python fallback when unzip is absent. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
6e4de59 to
e2330dd
Compare
Summary
Gets cloud-run past 2/7 phases in the dax benchmark. Two independent causes:
No filesystem persistence. The default
ephemeralmode runs each command viasandbox doin a fresh sandbox, so nothing the script writes survives.cloud-runnow usesexecutionMode: 'stateful'(sandbox run/exec/delete) pluswrite: trueandallowEgress: truefor the bun/node downloads andgit clone.apt-getis all-or-nothing. cloud-run's gVisor rootfs has nopython3-setuptoolsorunzip, and a single unknown argument makes apt install nothing — which is why the log showedcurl: command not foundafter the apt failure. The fix filters unavailable optionals out of one install invocation rather than adding a second (prepareis a timed phase):dnfinstalls the same two optionals one at a time with|| true(same all-or-nothing problem, but dnf providers are rare enough that the extra round trip doesn't matter).apkis unchanged — Alpine ships both.unpack_bun()falls back topython3+zipfilewhenunzipis absent, via a quoted heredoc with paths passed assys.argvso nothing is interpolated into the Python source. Verified locally against a synthetic zip withunzipremoved fromPATH: byte-identical output to theunzip -jpath.Note for reviewers
benchmarks/sandbox/providers.tsis shared by every sandbox mode (benchmarks/src/run.ts), so the stateful switch also affects cloud-run's sequential/staggered TTI numbers (currently 91.5, 10/10) —sandbox doandsandbox run/execare different code paths. Worth sanity-checking the benchmark comment on this PR for a TTI regression before merging.Rebased onto the post-#207 layout (
scripts/→benchmarks/scripts/,src/sandbox/→benchmarks/sandbox/); the previous merge conflict is gone.pnpm typecheckpasses.Link to Devin session: https://app.devin.ai/sessions/5bbf1eb8873f49b5b41a78351c86c70a
Requested by: @HeyGarrison