Repository navigation
fix: require approval for host-mutating tools when AUTO_APPLY is disabled (#89, #70) - #103
Conversation
OkiriGabriel
left a comment
There was a problem hiding this comment.
Thanks @Nitjsefnie, this is a careful fix for #89 and #70. Replaying the whole helper (validation, rollback, nginx -t gate) after approval, instead of approving its individual shell commands, is the right design. The bounded single-use reference keeps Slack's 2,000-character limit safe. The tests that check every name in MUTATING_AGENT_TOOLS is gated mean the next mutating tool can't slip through. Thanks also for filing #102.
Blocking: the approved operation runs with whatever python3 is on PATH
_execute_host_mutation builds python3 -c '<script>', and SafeExecutor._exec runs it through the shell. The documented systemd deployment (BUILD_AND_USAGE.md) uses ExecStart=/opt/devops-ai-agent/venv/bin/devops-agent serve, so the venv isn't on PATH. There, python3 is the system interpreter without httpx/structlog, and every approved nginx, cleanup, cert or security-update action fails with ModuleNotFoundError. It fails safely, but approval never works in that setup.
Fix: use the agent's own interpreter:
f"{shlex.quote(sys.executable)} -c {shlex.quote(script)}"The from tools.… import … in the script also relies on the subprocess's working directory being the repo root (or the package being installed). It's fine for both documented setups, but adding cwd handling or a comment would make that assumption explicit.
Non-blocking
apply_nginx_confighas nodry_run, so withAUTO_APPLY=falseit always needs approval. That's correct; I'm just noting it for anyone reading the PR.- The checklist says the docs weren't updated. One line in
SECURITY_GUARANTEES.mdsaying these six tools now require approval whenAUTO_APPLY=falsewould help operators.
With the interpreter fix I'll approve and merge. CI is green, and the rest looks good.
…pen-devops-agent#89) Gate complete host operations before running their helpers, preserve dry runs and enabled auto apply, and cover all mutating agent tools under emergency stop. Co-Authored-By: GPT-6.1 Sol <[email protected]>
Keep exact operations in org-scoped storage, resolve approval references before execution, and preserve failed helper exit status. Cover Slack transport limits, rollback failures, binding, and strict dry-run command checks. Co-Authored-By: GPT-6.1 Sol <[email protected]>
Expire host approvals after one hour, reclaim executed payloads, and bound admission state by window and record size. Use atomic backend claims without unsafe S3 fallbacks and cover concurrent reuse, expiry, and reclamation. Co-Authored-By: GPT-6.1 Sol <[email protected]>
Require locked memory consumption or a conditional cloud object transition before granting execution. Reject stale readers after cleanup regardless of their clock, and test revocation at the conditional write boundary. Co-Authored-By: GPT-6.1 Sol <[email protected]>
Co-Authored-By: GPT-6.1 Sol <[email protected]>
Co-Authored-By: GPT-6.1 Sol <[email protected]>
Co-Authored-By: GPT-6.1 Sol <[email protected]>
63ac08d to
95a9ae1
Compare
|
All three asks are in: the approved operation now runs with the agent's own shell-quoted interpreter ( |
OkiriGabriel
left a comment
There was a problem hiding this comment.
Thanks @Nitjsefnie, all addressed: the replay runs under the shell-quoted sys.executable (with a test pinning the quoting), the cwd/import assumption is documented at the script construction, and SECURITY_GUARANTEES.md notes the approval requirement. Good catch on cleanup reporting success after a failed command; the replay exit code now reflects real success. CI is green. Approving and merging.
With AUTO_APPLY=false and dry_run=false, apply_manifest ran the live `kubectl apply` first and only then returned requires_approval (open-devops-agent#102). The approval it sent was also unusable: it pointed at the temp manifest file, which was deleted before anyone could approve it. Now, without AUTO_APPLY, only `kubectl apply --dry-run=client` runs. If validation fails, no approval is requested. Otherwise the live command carries the manifest as base64 piped into `kubectl apply -f -` and is retained as a single-use approval reference (CommandApprovalStore, from open-devops-agent#103), so it fits in a Slack button and can be executed once approved. Namespace and paths are shell-quoted. Fixes open-devops-agent#102 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Description
With
AUTO_APPLY=false, six host-mutating tools could be driven live by the model's owndry_run=falseinput (and nginx apply/restart had no gate at all), because their dispatches bypassed the approval flow used by other gated tools. This gates the six host-mutating tools behind the repository's existing approval-response contract, adds the agent-level emergency-stop regression #70 asked for, and adds a bounded, single-use approval-reference store so the approved operation stays deliverable and safe after approval. Approved replays run with the agent's own interpreter, and the replay exit code reflects operation success rather than attempted application.Related Issues
Fixes #89
Closes #70
Type of Change
Platform/Component
Testing
tests/test_host_mutation_approval.py(131 cases): withAUTO_APPLY=false, the six host-mutating tools return the existingrequires_approvalresponse with zero commands executed (recording runner, forbid-all);AUTO_APPLY=truebehavior unchanged; dispatch/registration reconciliation so a future mutating tool missing fromMUTATING_AGENT_TOOLSfails; emergency stop blocks all 28 mutating names atexecute_toolfor both AUTO_APPLY values ([BUG] AGENT_EMERGENCY_STOP does not block several mutating tools #70 regression); approved replays run with the agent's own shell-quoted interpreter (quoting pinned against a shell-sensitive interpreter path); approved cleanup replays exit nonzero when a journal-vacuum or delete command fails, while protected/skipped paths stay a distinct non-error success.tests/test_approval_lifecycle.py(75 cases): bounded approval references (Slack button ≤2000 chars), TTL fail-closed, atomic single-use consumption, stale-reader/clock-skew fencing, per-backend (memory/S3/MinIO/GCS/Azure) reclamation and bounded admission; production-only revert proofs retained per fix.95a9ae1a46d4fdeb0336c6eb73398edb323ba485(10/10 jobs, Security Scan included); the same SHA is green on upstream CI (all jobs success;deployskipped by design). No full suite or build was run locally.Checklist
Breaking Changes
None at the API level. By design (the requested fix), with
AUTO_APPLY=falsethe six host-mutating tools now returnrequires_approvalinstead of executing live;AUTO_APPLY=truebehavior is unchanged.Additional Notes
Design summary: dispatch routes the six host mutations through a shared operation gate; with approval required it returns
SafeExecutor.run_safe's existing response keys with a boundedagent-approval:reference (stored via the selectedStorageProvider, TTL 1h, ≤256/org/hour, ≤256 KiB, single-use with atomic consumption and stale-reader fencing) instead of an oversized inline command. Approved consumption fences on a conditional transition of the stored payload itself, so a stale reader cannot recreate execution authority.restart_cloud_resource/scale_cloud_serviceare intentionally untouched (gated by emergency stop per #70's scope).Bugs Discovered:
Generated by GLM-5.3-Flash (brief, review), GPT-6.1 Sol (implementation, testing), GPT-6 Astra (review, testing)