Commit 01d15d5
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
| |||
0 commit comments