Skip to content

Commit 01d15d5

Browse files
chr6192cursoragent
andcommitted
fix(deps): pin nltk <3.10 to avoid CWD-import false positive breaking rouge/bleu
nltk>=3.10 ships a CWD-import-hijack guard (nltk/inisec.py, CWE-427 mitigation) whose check conflates "a package resolves from inside the current working directory" with "the current working directory itself holds a malicious same-name module". Any project using an in-project .venv (uv's default layout) triggers this unconditionally: `regex` lives under `<repo>/.venv/...`, which is textually inside cwd, so every `import nltk` run from the repo root raises `ImportError: Blocked import of regex from current working directory`. rouge-score and sacrebleu both import nltk transitively, so every ROUGE/BLEU-based grader test failed with "rouge_score not installed" even though the package was actually present and importable in isolation. Confirmed the module's own documented workarounds (`-P` / PYTHONSAFEPATH=1) do NOT fix this for an in-project .venv layout -- only NLTK_DISABLE_IMPORT_SECURITY=1 or avoiding the affected release does. Pinning to the last unaffected release is more portable than requiring every entry point (tests, cookbooks, downstream consumers) to remember an undocumented env var. Verified via `uv lock`: pins cleanly to nltk 3.9.4 (no inisec.py); all 17 previously-broken tests in tests/graders/text/similarity/ now pass, full suite is 869 passed / 157 skipped / 0 failed, and the repo's own `pre-commit run` (including its full-suite pytest hook) is green. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b5e593e commit 01d15d5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ dependencies = [
5050
"numpy>=1.22.0",
5151
"dashscope>=1.19.0",
5252
"tiktoken>=0.7.0",
53-
"nltk>=3.8.1",
53+
# nltk>=3.10 ships a CWD-import-hijack guard (nltk/inisec.py) that false-positives
54+
# whenever the venv resolving `regex` lives inside the current working directory --
55+
# exactly the layout `uv sync`'s default in-project `.venv` produces, which breaks
56+
# `import nltk` (and therefore rouge-score/sacrebleu) for any command run from the
57+
# repo root. Neither `-P` nor `PYTHONSAFEPATH=1` (its own documented workarounds)
58+
# avoid this for that layout; stay below 3.10 until upstream fixes the false positive.
59+
"nltk>=3.8.1,<3.10",
5460
"jieba>=0.42.1",
5561
"sacrebleu>=2.0.0",
5662
"rouge-score>=0.1.2",

0 commit comments

Comments
 (0)