3454a55636
cffconvert / validate (push) Has been cancelled
ci-workflow / pre-commit (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (macos-latest) (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (ubuntu-latest) (push) Has been cancelled
ci-workflow / Minimal NLTK Download Test (windows-latest) (push) Has been cancelled
ci-workflow / Python 3.10 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.11 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.12 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.13 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.14 on macos-latest (push) Has been cancelled
ci-workflow / Python 3.14t on macos-latest (push) Has been cancelled
ci-workflow / Python 3.10 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.11 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.12 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.13 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.14 on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.14t on ubuntu-latest (push) Has been cancelled
ci-workflow / Python 3.10 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.11 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.12 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.13 on windows-latest (push) Has been cancelled
ci-workflow / Python 3.14 on windows-latest (push) Has been cancelled
23 lines
708 B
Python
23 lines
708 B
Python
from nltk.sem.util import demo
|
|
|
|
|
|
def test_demo_model_injection_safeguard(tmp_path, monkeypatch):
|
|
"""
|
|
Ensure that passing a malicious payload with newlines to the --model flag
|
|
raises an appropriate error instead of executing arbitrary code.
|
|
"""
|
|
sentinel_file = tmp_path / "vulnerable_trigger.txt"
|
|
malicious_payload = f"os\nopen(r'{sentinel_file}', 'w').close()\nimport os"
|
|
|
|
monkeypatch.setattr("sys.argv", ["test", "-m", malicious_payload, "--no-eval"])
|
|
|
|
try:
|
|
demo()
|
|
except SystemExit:
|
|
pass
|
|
|
|
assert not sentinel_file.exists(), (
|
|
"CRITICAL SECURITY REGRESSION: Code injection vulnerability re-introduced "
|
|
"in nltk.sem.util.demo()"
|
|
)
|