feat(web-security): add ast-grep to runtime for AST-based JS static a… - #108
Merged
Conversation
…nalysis Install ast-grep (tree-sitter based structural code matching) in the web-security runtime as a lightweight alternative to semgrep for JS/TS pattern matching. Update dom-vulnerability-static-analysis and jxscout-custom-analyzers skills with concrete ast-grep usage patterns and a jxscout script analyzer wrapper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…nalysis
Install ast-grep (tree-sitter based structural code matching) in the web-security runtime as a lightweight alternative to semgrep for JS/TS pattern matching. Update dom-vulnerability-static-analysis and jxscout-custom-analyzers skills with concrete ast-grep usage patterns and a jxscout script analyzer wrapper.
Summary
The web-security capability has a gap in AST-aware JavaScript analysis when jxscout (commercial) isn't available. The
dom-vulnerability-static-analysisskill references semgrep, CodeQL, and ESLint as AST tools, but none are installed in the runtime — leaving the agent with onlyrg(regex) for source/sink enumeration, which is fragile for code constructs.This PR adds ast-grep to the runtime as a lightweight, tree-sitter-based structural code matching tool for JS/TS/HTML.
Why ast-grep:
pip install ast-grep-cli— minimal image bloat$VARwildcards — natural for LLM agents to generate on the flyChanges:
ast-grep-clitoDockerfile.runtimeandinstall_tools.shast-grepcommands for all sink categories (innerHTML, eval, postMessage, location, React, jQuery) with--jsonguidance. Repositioned semgrep/CodeQL/ESLint as "Additional AST tools (if operator-installed)"ast_grep_to_jxscout.shwrapper script, settings.jsonc config example, multi-pattern guidance. Updated analyzer type selection guidance to default to ast-grepAnalysis stack (layered):
Test plan
ast-grep-clilocally and verified all documented patterns match correctly against test JS fileast_grep_to_jxscout.shwrapper produces correct jxscout match JSON (kind, value, 1-based line/column)[]ast-grep(not deprecatedsg)just validatepasses (20 ok, 6 warn — same pre-existing warnings, 0 failed)pre-commitpasses on all changed filesDockerfile.runtime(CI)