系统学习 DevOps 学习路径:从版本控制到可观测与供应链

semgrep

多语言代码安全扫描

补充说明

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/

易错点与排错

相关命令

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. 离线环境中使用 --config auto 会有什么问题?
  2. 使用 --autofix 前应该做什么?
  3. semgrep 扫描通过是否代表代码安全?
答案
  1. --config auto 会联网拉取规则,离线环境要提前准备规则文件。
  2. 先提交或审查 diff,因为 --autofix 会直接改代码。
  3. 不代表。逻辑漏洞和配置问题仍需人工评审。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令