mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-25 10:04:26 +01:00
43 lines
1019 B
Python
43 lines
1019 B
Python
import pytest
|
|
from goose.utils.shell import is_dangerous_command
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"command",
|
|
[
|
|
"rm -rf /",
|
|
"git push origin master",
|
|
"sudo reboot",
|
|
"mv /etc/passwd /tmp/",
|
|
"chmod 777 /etc/passwd",
|
|
"chown root:root /etc/passwd",
|
|
"mkfs -t ext4 /dev/sda1",
|
|
"systemctl stop nginx",
|
|
"reboot",
|
|
"shutdown now",
|
|
"cat ~/.hello.txt",
|
|
"cat ~/.config/example.txt",
|
|
"pkill -f gradle",
|
|
"fuser -k -n tcp 80",
|
|
],
|
|
)
|
|
def test_dangerous_commands(command):
|
|
assert is_dangerous_command(command)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"command",
|
|
[
|
|
"ls -la",
|
|
'echo "Hello World"',
|
|
"cp ~/folder/file.txt /tmp/",
|
|
"echo hello > ~/toplevel/sublevel.txt",
|
|
"cat hello.txt",
|
|
"cat ~/config/example.txt",
|
|
"ls -la path/to/visible/file",
|
|
"echo 'file.with.dot.txt'",
|
|
],
|
|
)
|
|
def test_safe_commands(command):
|
|
assert not is_dangerous_command(command)
|