How I score the health of a Node.js API in one command
说明与用途
通过一条命令评估 Node.js API 的安全性,检测缺失的身份验证守卫并跟踪数据流至关键点,提供可解释的分数。
问题
Code review catches logic bugs, but nobody reads every controller to check for a missing auth guard. Nobody traces every req.body to see whether it reaches a SQL string either.
结果
The tool provides a single-command health score, identifies missing auth guards, tracks taint flow to critical sinks, and offers an explainable score breakdown, improving security review efficiency.
工作流
- Run npx @sabahattink/codediag scan . to index files once, respecting .gitignore and skipping large/minified files.
- Parse files with ts-morph to build an AST shared by all analyzers.
- Track taint from request data through up to three assignments into shell, SQL, and eval sinks.
- Generate an explainable score where each lost point maps to a rule ID.
- Integrate into CI using the GitHub Action sabahattink/codediag@v0 with threshold and baseline settings.
证据
Code review catches logic bugs, but nobody reads every controller to check for a missing auth guard. Nobody traces every req.body to see whether it reaches a SQL string either.
npx @sabahattink/codediag scan .
Discovery once. Files are indexed a single time, .gitignore-aware, with minified and oversized files skipped.
AST, not regex. ts-morph parses each file once, and all analyzers share the result.
Taint tracking. Request data is followed through up to three assignments into shell, SQL, and eval sinks.
Explainable score. Every lost point maps to a rule ID in the score breakdown.
- uses: sabahattink/codediag@v0
with:
threshold: 80
baseline: .codediag-baseline.json
Path traversal, SSRF, and XSS rules are on the roadmap. Feedback on false positives is the most valuable contribution right now.
- 记录日期: 2026-10-04T21:56:09.950Z