AI coding agents can edit files, run shell commands, and touch infrastructure. One bad rm -rf, force-push, or docker compose down -v can wipe hours of work or production data.
| 1 | # SPDX-License-Identifier: MIT |
| 2 | from __future__ import annotations |
| 3 | |
| 4 | from agent_guard.config import GuardConfig |
| 5 | from agent_guard.evaluator import evaluate_command |
| 6 | from agent_guard.models import Decision |
| 7 | |
| 8 | |
| 9 | def test_chain_still_detects_rm(config: GuardConfig) -> None: |
| 10 | r = evaluate_command("rm -rf ./src && npm install", config) |
| 11 | assert r.decision == Decision.BLOCK |
| 12 | |
| 13 | |
| 14 | def test_pipe_signal(config: GuardConfig) -> None: |
| 15 | r = evaluate_command("cat file | grep x", config) |
| 16 | # Pipe alone is a signal, not necessarily block |
| 17 | assert r.decision in {Decision.ALLOW, Decision.WARN} |