CI / test (3.11) (push) Canceled after 0s
CI / test (3.12) (push) Canceled after 0s
CI / test (3.13) (push) Canceled after 0s
CI / test (3.14) (push) Canceled after 0s
CI / package (push) Canceled after 0s
CI / precommit-and-security (push) Canceled after 11s
CI / typecheck (push) Canceled after 11s
34 lines
961 B
Python
34 lines
961 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
SRC = Path(__file__).resolve().parents[2] / "src" / "schedls"
|
|
|
|
|
|
def test_no_shell_true_in_production_code() -> None:
|
|
offenders = []
|
|
for path in SRC.rglob("*.py"):
|
|
text = path.read_text()
|
|
if "subprocess" in text and "shell=True" in text:
|
|
offenders.append(str(path))
|
|
assert offenders == []
|
|
|
|
|
|
def test_subprocess_confined_to_runner() -> None:
|
|
offenders = []
|
|
for path in SRC.rglob("*.py"):
|
|
if "import subprocess" in path.read_text() and path.name != "runner.py":
|
|
offenders.append(str(path))
|
|
assert offenders == []
|
|
|
|
|
|
def test_runner_explicitly_disables_shell() -> None:
|
|
assert "shell=False" in (SRC / "runner.py").read_text()
|
|
|
|
|
|
def test_no_os_system_or_popen() -> None:
|
|
for path in SRC.rglob("*.py"):
|
|
text = path.read_text()
|
|
assert "os.system(" not in text, path
|
|
assert "os.popen(" not in text, path
|