summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/patterns.py
AgeCommit message (Collapse)Author
43 hourssecurity-guidance: state what the hooks report as usage datamhegazy/sg-usage-data-readmeClaude
The README says what the values in the hooks' metrics field are, that Claude Code can add them to its usage metrics, and how to turn that off. The deserialization warning describes the .pyc serializer instead of naming its module. A header test builds its made-up keys at run time. Co-authored-by: mhegazy <mhegazy@anthropic.com>
13 dayssecurity-guidance: fewer false edit warnings on ordinary JavaScriptmhegazy/sg-fewer-false-pattern-warningsClaude
Four edit rules matched their word without looking at what stands next to it: - eval: Playwright's and Puppeteer's page.$eval('selector', function) and $$eval got the eval() warning. They run the function they are given. Left out only when the selector is a plain string and the function is written out in the call. AngularJS scope.$eval(expr) and every other $eval( still warn. - new Function: the whole word is needed, so new FunctionRegistry() is quiet. - innerHTML and outerHTML: an assignment is needed, so == and === are quiet. Nothing warns that did not warn before. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-10security-guidance: read yaml, torch and numpy load calls across their argumentsmhegazy/sg-call-argument-scanClaude
Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-05-28security-guidance: gate XSS pattern rules to JS-family filesfix-xss-rules-non-js-false-positivesMohamed Hegazy
Closes #410, #2037, #2045, #1640, #1280, #1329, #1341, #255, anthropics/claude-code#46720 (partial closes on overlap with other rules). The plugin's substring-only XSS / browser-DOM rules (new_function_injection, react_dangerously_set_html, document_write_xss, innerHTML_xss, outerHTML_xss, insertAdjacentHTML_xss) fired on any file containing the trigger substring — including: * Markdown documentation explaining XSS sinks * Blog posts / READMEs that name browser APIs * Python tutorials referencing dangerouslySetInnerHTML * Plugin skill files with example HTML strings * .yaml / .json configs that happen to contain the literal string * .gitignore / Dockerfile / Makefile These constructs have no meaning outside JS/TS source. Add a path_filter: lambda p: p.endswith(_JS_EXTS) to each so they fire only on .js, .jsx, .ts, .tsx, .mjs, .cjs, .mts, .cts, .vue, .svelte. Cross-checked against the existing _JS_EXTS-gated rules (regex_exec_substring, child_process_exec, exec_substring) — same pattern, same constant, same intent. Uses the module-level _JS_EXTS tuple so future extension changes propagate to all 6 rules atomically. Verified locally on macOS Python 3.13: - py_compile clean. - 45-test existing smoke + extensibility suite still passes. - 151 new parametrized tests in test_xss_gate.py (added to internal test suite this PR doesn't ship): each gated rule x every JS-family extension accepts, x every non-JS path (.md / .py / .yaml / .json / .txt / .html / Dockerfile / Makefile / .gitignore / .sh / .go / .rs / .rb) rejects. 196 tests pass total. Doesn't address everything in the false-positive cluster — issues that require Python-rule gating (#1114 .env.schema exec), tighter substring scoping (#660 pickle in usernames), or hook-protocol changes (#1358 exit-2 vs warning, #1375 plain-text-vs-JSON output) need separate PRs. This PR covers the JS-substring subset cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26Update security-guidance pluginsecurity-guidance-updateMohamed Hegazy