diff --git a/src/goose/utils/shell.py b/src/goose/utils/shell.py index d53bbb05..c1a078e2 100644 --- a/src/goose/utils/shell.py +++ b/src/goose/utils/shell.py @@ -34,6 +34,9 @@ def is_dangerous_command(command: str) -> bool: r"\bsystemctl\b", # systemctl command r"\breboot\b", # reboot command r"\bshutdown\b", # shutdown command + # Commands that kill processes + r"\b(kill|pkill|killall|xkill|skill)\b", + r"\bfuser\b\s*-[kK]", # fuser -k command # Target files that are unsafe r"\b~\/\.|\/\.\w+", # commands that point to files or dirs in home that start with a dot (dotfiles) ] diff --git a/tests/utils/test_check_shell_command.py b/tests/utils/test_check_shell_command.py index 2e1a8ae2..7484b193 100644 --- a/tests/utils/test_check_shell_command.py +++ b/tests/utils/test_check_shell_command.py @@ -17,6 +17,8 @@ "shutdown now", "cat ~/.hello.txt", "cat ~/.config/example.txt", + "pkill -f gradle", + "fuser -k -n tcp 80", ], ) def test_dangerous_commands(command):