Skip to content

Commit

Permalink
fix: Mark kill related commands as dangerous (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsibbison-square authored Nov 13, 2024
1 parent 2c0c18f commit 7066025
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/goose/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/test_check_shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7066025

Please sign in to comment.