[Bug]: destructive_warning is silent for sudo rm -rf and other command prefixes
Summary
destructive_warning.get_warning() returns None for sudo rm -rf /.
The file-deletion patterns in tools/src/terminal_tools/common/destructive_warning.py anchor the verb to command position — (^|[;&|\n]\s*)rm\s+… — so any prefix that displaces rm silences the warning completely.
Reproduction
No hardware or device needed; this is pure catalog behaviour.
from terminal_tools.common.destructive_warning import get_warning
get_warning("rm -rf /") # 'may recursively force-remove files'
get_warning("sudo rm -rf /") # None <-- expected a warningMeasured against current main:
| Command | get_warning() |
|---|---|
rm -rf / |
may recursively force-remove files |
sudo rm -rf / |
None |
doas rm -rf / |
None |
sudo -E rm -rf /home |
None |
sudo -u root rm -rf /srv |
None |
nohup rm -rf /data |
None |
time rm -rf /data |
None |
env rm -rf /data |
None |
FOO=1 rm -rf /data |
None |
find . -name '*.pyc' | xargs rm -rf |
None |
make clean && sudo rm -rf build |
None |
Why this matters
The catalog is inconsistent about prefixes. The git, kubectl and terraform patterns use \b rather than a command anchor, so these already warn correctly today:
get_warning("sudo git reset --hard") # 'may discard uncommitted changes'
get_warning("sudo kubectl delete pod x") # 'may delete Kubernetes resources'Only the deletion class — the most destructive one, and the one most likely to be run under sudo — goes quiet. The practical effect is that an agent that reaches for sudo gets less safety feedback in the exec envelope than one that does not, which inverts the intent described in the module docstring.
Expected behaviour
A destructive deletion should produce the same warning whether or not the verb is displaced by sudo, doas, env, nohup, time, command, xargs, or a leading VAR=value assignment.
Quoted or unrelated text must stay silent, so the prefix handling must not become a wildcard — echo sudo rm -rf / and sudo apt update should both remain None.
Scope
destructive_warning.py only. This is the advisory catalog; nothing here changes blocking behaviour, which lives in command_guard.py and is scoped to browser/runtime processes.
Windows verbs need no change — there is no sudo equivalent displacing del/rd on that path.
I have a fix and regression tests ready and will open a PR referencing this issue.
Source: aden-hive/hive