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, RiskLevel |
| 7 | |
| 8 | |
| 9 | def test_curl_example_allow(config: GuardConfig) -> None: |
| 10 | r = evaluate_command("curl https://example.com", config) |
| 11 | assert r.decision == Decision.ALLOW |
| 12 | |
| 13 | |
| 14 | def test_curl_delete_production(config: GuardConfig) -> None: |
| 15 | r = evaluate_command( |
| 16 | "curl -X DELETE https://production.example.com/api/users/1", |
| 17 | config, |
| 18 | ) |
| 19 | assert r.decision == Decision.BLOCK |
| 20 | assert r.risk.rank >= RiskLevel.HIGH.rank |
| 21 | |
| 22 | |
| 23 | def test_ssh_production(config: GuardConfig) -> None: |
| 24 | r = evaluate_command("ssh production.example.com", config) |
| 25 | assert r.decision in {Decision.WARN, Decision.BLOCK} |