gosec
$ gosec 基金会 低风险gosec 检查 Go 源码 AST 与 SSA 表示以发现常见安全漏洞(SQL 注入、弱加密、命令注入、不安全文件权限等)。它完全离线运行,原生支持 -fmt=json / -fmt=sarif、-severity 与 -exclude 过滤以及 -no-fail,非常适合无头 Agent 流水线。
brew install gosec gosec -fmt=json 直接调用本地 Go 工具链进行类型检查,零网络或 MCP 开销。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
原生支持 -fmt=json / -fmt=sarif、-severity、-confidence、-exclude、-quiet 与 -no-fail,流水线集成极其顺畅。
- Native
-fmt=json,-fmt=sarif,-quiet, and-no-fail
严格只读的 Go AST/SSA 静态分析器,无网络请求或代码执行;仅在指定 -out 时写入文件。
- Purely local read-only AST inspection
可通过 brew install gosec、go install 与 GitHub Releases 在 macOS、Linux、Windows 安装(需配合 Go 工具链)。
- Multi-OS releases and standard
go install
高速且感知类型的 Go 安全扫描器,支持精确的规则 ID(G101–G602)与 #nosec 抑制。
- Granular rule selection with
-include/-exclude
SecureGo 组织维护的事实标准 Go 安全检查工具。
- Long-running SecureGo project on GitHub
securego.io 提供详尽的规则目录与 CLI 参数文档。
- Official docs at securego.io/docs/usage/
安全边界、鉴权与放权指南
无需凭据;完全离线分析本地 Go 代码包。
100% 免费、离线、开源(Apache-2.0)。
# gosec Agent Rules - Always pass `-fmt=json -quiet` (and `-no-fail` when capturing JSON in pipelines) so progress logs do not pollute stdout. - Ensure Go module dependencies are already fetched (`go mod download`) before running `gosec` offline.
Agent 高频安全命令配方
只读查询(安全推荐)
gosec -fmt=json -no-fail -quiet ./...
检查 ./... 下的所有 Go 包,通过 -quiet 抑制横幅噪音,并通过 -no-fail 以退出码 0 向 stdout 输出 JSON。
gosec -fmt=sarif -severity=high -out=gosec.sarif ./...
仅筛选 high 严重等级规则并将 SARIF 报告写入 gosec.sarif。
核心优势
- + 极佳的
-fmt=json -quiet -no-fail流水线体验,支持按规则、-severity与-exclude精准过滤。 - + 基于 Go 类型信息的 AST/SSA 分析可在本地发现真实污点与加密缺陷。
注意事项与踩坑点
- ! 需要可用的
go工具链及已解析的模块缓存以完成包类型检查。 - ! 不加
-quiet时 stderr 进度日志可能干扰终端输出。