SitePoint19 min readtutorialintermediate
Securing AI Pull Requests: Building a Deterministic AST Audit Harness in GitHub Actions
Summary
A step‑by‑step tutorial for building a deterministic AST‑based security scanner that runs in GitHub Actions to catch prototype‑pollution, high‑entropy secrets, and unauthorized network egress in AI‑generated pull requests.
- Use @babel/parser + @babel/traverse to get a full‑fidelity TypeScript AST and run independent visitors for each threat class.
- Prototype‑pollution detection relies on scope‑aware analysis of computed property assignments (e.g., obj[key] = … where key may be "__proto__").
- Secret detection computes Shannon entropy on every StringLiteral/TemplateLiteral node to flag high‑entropy values, catching base64 or atob‑encoded tokens.
- Egress detection tracks fetch/axios/http calls and dynamic import() arguments against a configurable allow‑list, rejecting any outbound URL.
AI code generators can inject subtle, runtime‑only vulnerabilities that static linters miss. A deterministic, AST‑driven audit gives reproducible, language‑aware security checks that can be enforced automatically at merge time.
6/10




