多语言代码安全扫描
semgrep 用模式匹配规则检查代码中的安全问题、反模式和业务规则。它支持多种语言,可本地运行,也可接入 CI。
semgrep scan
semgrep --config auto
semgrep --config p/security-audit
semgrep --config p/secrets .
semgrep --severity ERROR --json -o report.json
semgrep ci
semgrep --config rules/ ./src
.semgrepignore:
vendor/
node_modules/
dist/
--config auto 会联网拉取规则;离线环境要提前准备规则文件。nosemgrep 注释或规则排除,并写原因。semgrep ci 需要 token/平台配置;本地扫描和 CI 结果可能不同。.semgrepignore 排除依赖和构建产物。--autofix 会改代码;先提交或审查 diff。gitleaks — 密钥扫描grype — 依赖与镜像漏洞pre-commit — 本地钩子