Repository navigation
feat(sandbox): sandbox cron scripts and command deliveries under [sandbox.consumers] cron (#748) - #874
Merged
Conversation
…dbox.consumers] cron (#748) Third slice of #748. `[sandbox.consumers] cron` = off | optional | required runs a cron script job and a `command:` delivery in the same `command` profile as the other consumers, with the job's workdir as the workspace. A cron job is unattended, so optional counts as required and there is no unsandboxed fallback: a missing backend, a refused workdir or layout and a failing launcher refuse the run or delivery visibly, never pass. One launcher (cron/launch.rs) builds every process cron starts.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
…the fallback warning per consumer (#748) A writable bind of a workdir that holds TOLE_CRON_DIR (or is inside it) let a sandboxed script edit its own job ledger and run log. launch::prepare now refuses it for scripts and deliveries and fails closed when the cron dir cannot be resolved. warn_once keeps one bit per consumer so the new Cron consumer cannot index out of bounds. CHANGELOG and docs state both.
5 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Third slice of #748: cron script jobs and
command:deliveries can run in thecommandbubblewrap profile through a new consumer key[sandbox.consumers] cron=off(default) |optional|required(user config only).Why
tole cron run/tickandtole serve --cronrun owner-saved scripts and delivery commands unattended and unsandboxed;tole doctorsaid "cron scripts and deliveries are not sandboxed yet". Owner decision: samecommandprofile as every other consumer, new keycron, and because cron is unattendedoptionalhas no unsandboxed fallback (Consumer::always_unattended, likeverifyandturnend): if the sandbox is unavailable or the plan is refused, the job refuses visibly; a launcher failure is a refusal, never a pass.Changes
tole-coresandbox::command:Consumer::Cron(always unattended),Consumers.cron, newcommand_in_dir(consumer, workdir, program, args)(the existingcommand_preparedwith the launcher report, workspace given by the caller), doctor lines (the "not sandboxed yet" line is replaced; cron is listed with the others and an ERROR is raised foroptional/requiredwithout a backend).tole-clicron/launch.rs(new): the ONE launcher.tick::run_scriptanddeliver::run_commandboth calllaunch::prepareand nothing else insrc/cronbuilds aCommand(a test asserts it). It reusesprotect_plan/recheck_plan, the launcher status (bwrap --json-status-fd), rlimits, thecronsecret scrub and the user config thatcron run/tickalready load (security:tole cron runandtole cron tickrun agents and scripts without the owner's user config applied #863).cronkey parsed, shown byconfig check, user layer only;main.rsrefuses to startcron run/tickwithcronon when the sessions directory cannot be protected (security: a sessions directory inside the workspace but outside .tole is writable by a sandboxed command #866), like verify and the stop gates.workdir(the process cwd when it has none; unknown cwd refuses). A workdir that is gone, holds$HOMEor the data dir, or has a layout the plan refuses is a refusal. A workdir below a repository root binds that directory only (the parent.gitis not in the sandbox).network = "none"a webhook/SMTP delivery fails (setnetwork = "host", shared by all consumers);$HOMEand paths outside the workdir are not visible. Documented indocs/sandbox-design.md§9.5.TOLE_CRON_*variables, the 300 s / 60 s timeouts and cancel are unchanged. A timeout is anerrorrun, not a refusal.error(neverok) withusage.sandbox_refused = true, the reason inusage.errorand in the run log (socron runs,GET /cron/runsand delivery targets show it); a refused or failed delivery is afailedrecord with the reason or the command's own exit code and stderr.usage.sandboxedsays whether the run was wrapped.optionalhas no fallback warning), asserted in the tests.check_destructive_argvalready refuses path-qualified programs at save and at run time), so theruns_pathsexception of the stop gates is not extended to cron.docs/sandbox-design.md(§9.3 text, new §9.5, §15),docs/threat-model.md,docs/epics.md,CHANGELOG.md. The README status line has no sandbox-slice text, so it is not stale.ci.yml: theSandbox (bubblewrap)job's tole-cli step runs--test cron_sandboxand now expects 3 passing targets (was 2).Impact check (grep, not cora; the output is noisy on Rust so every caller was verified by grep):
Consumer::ALL/Consumer::name/Consumers::mode:sandbox/report.rs(doctor listing),command.rsdoctor_lines_for,launch_command.always_unattended:launch_command,doctor_lines_for,report.rs.Consumers { .. }literals:command_sandbox*.rs,stopgate_sandbox.rs,command_sandbox_none.rs(updated withcron: Mode::Off),report_tests.rs,command_tests.rs(use..Default),tole-cli/src/config/mod.rs.SandboxConsumersConfig/settings():config/mod.rs(render, provenance,consumers()),main.rs(set_consumers).tick::run_script,ScriptOutput: onlytick.rs.deliver::run_command: onlydeliver.rs.command_sandbox,command_sandbox_none,command_sandbox_sessions,command_sandbox_sessions_refused,stopgate_sandbox,sandbox_no_flag,sandbox_profile_flag(tole-core),sandbox_consumers,verify_sandbox,sessions_default_dir_e2e,cron_cli,cron_delivery,cron_control,cron_trust,cron_user_config_e2e,cron_sandbox(tole-cli), theconfig::andsandbox::commandunit tests.Testing
crates/tole-cli/tests/cron_sandbox.rs(real binary, scrubbed env, 14 tests): off unchanged (default and explicit);required/optionalwithout bwrap refuse visibly, script never runs, stderr empty; delivery refused and recorded; sandboxed script writes the workdir but not.git/.toleand cannot read the masked user config dir; own exit codes (3, 127) are not refusals; workdir below a repo root; gone workdir or one that holds the data dir; refused layout (uninitialized submodule); failing and unspawnable launcher (fake bwrap) are refusals; sandboxed delivery gets stdin and env and its failure is recorded; timeout kills a sandboxed script; noCommand::newoutside the one launcher.launch::prepareneutered by hand to a plainCommand, 9 of the 13 behaviour tests fail (the 4 that still pass are the off control, the two exit-code tests and the timeout, which are meant to be backend-independent); restored before the commit.sandbox/command_tests.rs(consumer list, always unattended with no fallback, profile identical torun_command, refused workdirs, doctor) andconfig/mod.rs;sandbox_consumers.rsdoctor/config-check tests updated.cron_sandboxis added to theSandbox (bubblewrap)job (honoursTOLE_REQUIRE_BWRAP=1, count 2 to 3); no newtole-coretarget, the new core tests are unit tests in an existing module.cargo fmt --all;cargo clippy --workspace --all-targets --all-features -- -D warnings; clippy--no-default-featuresand--no-default-features --features shell-toolsfor tole-core/tole-cli;cargo check -p tole-core --no-default-features --tests;cargo testin the default workspace,-p tole-cli --no-default-features,-p tole-cli --no-default-features --features shell-toolsand-p tole-core --no-default-features, all withTOLE_REQUIRE_BWRAP=1 --no-fail-fast: no failures.corais not installed in this environment, soscripts/review-local.shandcora review --stagedwere not run; the diff was self-reviewed adversarially instead (launcher failure vs command exit, timeout classification, no-workdir and failing cwd, Off mode byte-for-byte, env scrub order, bypass paths by grep). The CI Cora Review job is the gate.origin/develop..HEAD: nothing printed.