mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: Mark kill related commands as dangerous (#242)
This commit is contained in:
@@ -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)
|
||||
]
|
||||
|
||||
@@ -17,6 +17,8 @@ from goose.utils.shell import is_dangerous_command
|
||||
"shutdown now",
|
||||
"cat ~/.hello.txt",
|
||||
"cat ~/.config/example.txt",
|
||||
"pkill -f gradle",
|
||||
"fuser -k -n tcp 80",
|
||||
],
|
||||
)
|
||||
def test_dangerous_commands(command):
|
||||
|
||||
Reference in New Issue
Block a user