Add typed Docker command builders and a controlled executor seam - #45
Open
holladortun wants to merge 4 commits into
Open
Add typed Docker command builders and a controlled executor seam#45holladortun wants to merge 4 commits into
holladortun wants to merge 4 commits into
Conversation
Replace placeholder, injection-prone deployment command construction with a typed, injection-safe model and a pluggable executor that captures output. - libs/docker.rs: introduce RemoteCommand (Literal/Arg tokens). User-controlled values enter only as Arg and are POSIX single-quoted on render, so a service name, image reference, or path can never break out of its shell word. The image/compose/dockerfile builders now emit Vec<RemoteCommand> instead of interpolated strings. Add validate_service_name / validate_image_reference for defense-in-depth and clear rejection of unsafe input. - libs/deploy_executor.rs: add the DeployExecutor trait plus CommandOutcome / DeployRun capture types and secret-scrubbing output. PreviewExecutor renders commands without connecting, so deployment output is honest and injection-safe until the real SSH transport lands. - services/deployments.rs: DeploymentService runs commands through an injected executor (preview by default, mockable in tests) and records the captured run and status. No arbitrary-command endpoint is added. - Tests: builder injection tests prove malicious names/paths render as a single quoted word (round-trip), executor tests prove success/failure capture and redaction, and a service-level test proves a failing run surfaces as a failed deployment with the captured output. Real russh-backed SSH execution and the environment-to-server link are the immediate follow-up.
lordsarcastic
requested changes
Jun 17, 2026
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.
Part of #11 (controlled Docker executor). This is the security-critical, fully CI-verifiable core; the real SSH transport + environment→server link are an immediate follow-up.
Summary
format!("docker pull {image}"),cd {service_dir} && …) and stored the join asoutput— a shell-injection surface (name = "x; rm -rf /"), with nothing executed and status hardcoded.Scope
Included
RemoteCommandtyped builder (Literal/Arg tokens) with POSIX single-quote rendering;image/compose/dockerfilebuilders emitVec<RemoteCommand>.validate_service_name/validate_image_reference(defense-in-depth, clear errors).DeployExecutortrait +CommandOutcome/DeployRuncapture types + secret-scrubbing output;PreviewExecutordefault.DeploymentServiceruns commands through an injected executor (mockable) and records the captured run + status.Intentionally not included (immediate follow-up PR)
russh-backed SSH transport that executes for real.server_idonenvironments(the deploy-tier-aligned target) via migration, and env→server→SshTargetresolution intrigger_deploy.These satisfy #11's "typed builders", "injection impossible", "no arbitrary endpoint", and "failure output captured" criteria now; "executes over SSH" lands with the transport.
Changes
backend/src/libs/docker.rs—RemoteCommand/Token,shell_quote(POSIX single-quote:'→'\''),validate_*, builders returnVec<RemoteCommand>. User input enters only viaarg(...)and is always quoted on render.backend/src/libs/deploy_executor.rs(new) —DeployExecutortrait (async-trait, already a dep),CommandOutcome/DeployRun,to_output()+redact_secrets(),PreviewExecutor.backend/src/services/deployments.rs—Arc<dyn DeployExecutor>(preview default,with_executorfor tests);trigger_deploy/restart_servicebuild typed commands, run the executor, capture output + status (deploy_statusmaps preview→queued, real→succeeded/failed).backend/src/libs/mod.rs— register module.backend/tests/deployments_executor_tests.rs(new) — failing executor →status=failedwith captured stderr; executor only receives quoted commands.Tests
make backend-fmt— cleanmake backend-test— full suite green under CI env (WARA_TEST_DATABASE_URL+WARA_DB_PUSH_SCHEMA=true): lib 24/24 (incl. injection + executor), api 10, auth 7, deployments_executor 2, migrations/persistence all passcargo clippy --workspace --all-targets -- -D warnings→ 0 warningsmake frontend-build— not applicableInjection proof: each malicious payload (
web; rm -rf /,$(touch pwned), backticks, pipes, newlines, embedded quotes) is asserted to round-trip through quote/unquote, i.e. a shell parses the rendered arg as exactly the payload — no metacharacter escapes its word.Security Notes
DeployRun::to_outputalready scrubs a provided secret list (tested with sentinels) so captured output can't leak secrets when credential/env binding lands.Notes
Deliberate deviation: introduces a trait +
Arc<dyn>seam (the codebase otherwise avoids traits) — mandated by #11's "mocked SSH executor tests" requirement; it isolates the future SSH transport behind a testable boundary.