fix: Mark kill related commands as dangerous (#242)

This commit is contained in:
Jarrod Sibbison
2024-11-13 11:51:04 +11:00
committed by GitHub
parent 2c0c18f2f8
commit 70660258e9
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -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)
]
+2
View File
@@ -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):