Fix sporadic nuclei test failures from stale template state / Nuclei Environment isolation - #3096
Conversation
shield the update subprocess from outer cancels, and if the resulting templates dir is empty (marker file lied), wipe both and retry once.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #3096 +/- ##
=====================================
- Coverage 90% 90% -0%
=====================================
Files 444 444
Lines 38338 38403 +65
=====================================
+ Hits 34284 34334 +50
- Misses 4054 4069 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📊 Performance Benchmark Report
📈 Detailed Results (All Benchmarks)
🎯 Performance Summary+ 1 improvement 🚀
25 unchanged ✅🔍 Significant Changes (>10%)
🐍 Python Version 3.11.15 |
redirect nuclei subprocess HOME (and AppData/LocalAppData) so its config, cache, and pdcp dirs all land under bbot's tools tree. lets self-heal wipe stale marker state without touching the user's own ~/.config/nuclei. drop the cross-platform path hunt + one-call helper.
os.environ.copy() forwarded PDCP_API_KEY, GITHUB_TOKEN, AWS_*, AZURE_*, XDG_CONFIG_HOME etc. into the pinned binary, silently changing its behavior (cloud upload to PDCP under the user's account, alternate template sources, XDG_CONFIG_HOME defeating the HOME redirect). Switch to a fixed allowlist (PATH/locale/proxy) and pin the config dir explicitly via NUCLEI_CONFIG_DIR so XDG state in the host env can't relocate it. Test poisons env with the leakable vars and asserts they don't reach the subprocess.
|
Pushed a follow-up after review feedback flagged that the
Fix is an allowlist ( New test |
When
nuclei -update-templatesis killed mid-extract (scan abort, test timeout, OOM), it can leave its version marker on disk while the templates directory is empty. The next invocation reads the marker, reportsNo new updates found, and runs against a directory that doesn't contain the requested template path, producing zero findings and silently failing everyTestNuclei*rerun.Shield the update subprocess from outer cancels so it can't be torn mid-extract, and after the update verify the templates dir actually contains
http/. If not, wipe both the marker (~/.config/nuclei/.templates-config.json) and the partial dir, then retry once before hard-failing setup.