跳转到正文
报告库
用途分类 / 开发辅助

Golang Uber Dig Skill 安全审计

作者说它能做什么(原文)

Implements dependency injection in Golang using uber-go/dig — reflection-based container, Provide/Invoke, dig.In/dig.Out parameter and result objects, named values, value groups, optional dependencies, scopes, and Decorate. Apply when using or adopting uber-go/dig, when the codebase imports `go.uber.org/dig`, or when wiring an application graph at startup. For higher-level lifecycle and modules, s

第三方安全检查结论

发现安全风险

已检查文件
5
发现的风险
5
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
中风险

示例把原始内部错误文本返回给 HTTP 客户端

原文依据:3 处
发现了什么

请求处理示例直接调用 `http.Error(w, err.Error(), 500)`。如果仓库采用该示例,底层数据库或服务错误会原样进入响应。

为什么需要注意

错误可能暴露数据库信息、内部服务名称、文件路径、查询细节或其他本应只写入服务端日志的诊断信息。

这是可复制的请求处理示例:作用域调用失败时,它把 `err.Error()` 直接作为 500 响应正文发送。若错误含数据库地址、查询细节、内部类型或配置内容,远程客户端可能看到这些信息。它不是自动运行的实现,但采用示例时风险成立。用户可要求对外返回固定消息,并只在服务端记录详细错误。

references/recipes.md:49来自说明文档打开原文件
func NewUserRoute(repo *UserRepo) RouteResult {    return RouteResult{Route: Route{        Pattern: "/users",        Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {            users, err := repo.List(r.Context())            if err != nil {                http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)                return            }            fmt.Fprintf(w, "%d users", len(users))        }),    }}
查看另外 2 个位置
references/recipes.md:187来自说明文档打开原文件
    err := scope.Invoke(func(h *Handler) error {        return h.Serve(w, req)    })    if err != nil {        http.Error(w, err.Error(), 500)    }}
references/recipes.md:177来自说明文档打开原文件
func handle(w http.ResponseWriter, req *http.Request) {    scope := root.Scope("request")    // Request-scoped values    must(scope.Provide(func() *http.Request { return req }))    must(scope.Provide(func() RequestID { return RequestID(req.Header.Get("X-Request-ID")) }))    must(scope.Decorate(func(l *zap.Logger) *zap.Logger {        return l.With(zap.String("request_id", req.Header.Get("X-Request-ID")))    }))    err := scope.Invoke(func(h *Handler) error {        return h.Serve(w, req)    })    if err != nil {        http.Error(w, err.Error(), 500)    }}```
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 2 项风险
低风险

可视化示例会截断已有的 graph.dot 文件

原文依据:3 处
发现了什么

示例使用 `os.Create("graph.dot")`。运行时,如果当前目录已经存在同名文件,该调用会将其截断后再写入依赖图;示例还忽略创建和写入错误。

为什么需要注意

用户已有的 `graph.dot` 内容可能被不可逆覆盖,失败也可能因为错误被忽略而不明显。

可视化示例调用 `os.Create("graph.dot")`;若在运行目录中已有同名文件,Go 会截断它,然后 `dig.Visualize` 写入新内容。示例还忽略创建和写入错误,可能造成旧文件丢失却没有清楚报告。该代码只是示例,不会因加载 Skill 自动执行。用户可要求先确认目标、使用唯一临时文件或安全地处理已存在文件和错误。

references/advanced.md:86来自说明文档打开原文件
```gof, _ := os.Create("graph.dot")_ = dig.Visualize(c, f)// then: dot -Tpng graph.dot -o graph.png```
查看另外 2 个位置
references/recipes.md:264来自说明文档打开原文件
```goerr := c.Invoke(run)if err != nil {    f, _ := os.Create("graph.dot")    defer f.Close()    _ = dig.Visualize(c, f, dig.VisualizeError(err))    log.Fatalf("wiring failed (graph in graph.dot): %v", err)}
references/advanced.md:84来自说明文档打开原文件
dig can emit the dependency graph in DOT format — useful when wiring becomes too tangled to reason about by reading code:```gof, _ := os.Create("graph.dot")_ = dig.Visualize(c, f)// then: dot -Tpng graph.dot -o graph.png```
低风险

安装命令会下载模块并改变 Go 项目的依赖记录

原文依据:4 处
发现了什么

指南直接展示 `go get go.uber.org/dig`,同时声明可运行 Go 命令。执行后通常会联系配置的 Go 模块来源,并更新当前项目的 `go.mod` 和可能的 `go.sum`。材料没有显示该命令会自动执行。

为什么需要注意

项目依赖和锁定校验记录会发生持久变化,并向所配置的模块代理或源码主机发出网络请求。

这段代码的正常用途

`go get go.uber.org/dig` 是标明为代码块的常规依赖安装步骤,与“采用 uber-go/dig”的声明用途直接一致;元数据中的自动安装列表还是空的。若用户或代理明确执行它,通常会访问所配置的 Go 模块来源并更新项目依赖文件,但材料没有指示加载 Skill 时自动执行。用户仍可要求先展示 `go.mod`/`go.sum` 变化,或在受限网络环境中执行。

这项判断针对展示的代码和适用条件,不表示风险已经实际发生。
SKILL.md:13来自说明文档打开原文件
    homepage: https://github.com/samber/cc-skills-golang    requires:      bins:        - go    install: []    skill-library-version: "1.19.0"allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
查看另外 3 个位置
SKILL.md:40来自说明文档打开原文件
```bashgo get go.uber.org/dig```
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.19.0"allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
SKILL.md:34来自说明文档打开原文件
This skill is not exhaustive — refer to library documentation and code examples for more information:- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber/cc-skills-golang@golang-pkg-go-dev` skill (`godig`), preferred over Context7 for Go package facts.- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber/cc-skills-golang@golang-gopls` skill (`gopls`).- Context7 remains a fallback for docs not indexed on pkg.go.dev.```bashgo get go.uber.org/dig```
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 2 项风险
中风险

声明了与依赖注入指导目的不相称的全部 git 命令权限

原文依据:2 处
发现了什么

该 Skill 的说明聚焦于 Go 依赖注入,但允许 `Bash(git:*)`,没有把 git 使用限制到只读操作。这一模式可能覆盖推送、强制重置、清理文件或删除分支等命令。材料没有证明这些命令会自动运行。

为什么需要注意

若代理在 Skill 激活期间误用或受项目内容诱导使用危险 git 子命令,可能改写本地历史、删除未提交文件,或把代码推送到远程账户。

该 Skill 的用途是指导 Go 依赖注入,但工具声明允许所有匹配 `git:*` 的 Bash 命令,正文没有说明只限查看状态或差异。因此,在宿主实际按此字段授予权限时,代理可能具备推送、强制重置、清理或删分支等超出所述任务所需的能力。材料未显示这些命令会自动执行。用户可要求作者移除 git 权限或仅允许明确的只读子命令。

SKILL.md:3来自说明文档打开原文件
name: golang-uber-digdescription: "Implements dependency injection in Golang using uber-go/dig — reflection-based container, Provide/Invoke, dig.In/dig.Out parameter and result objects, named values, value groups, optional dependencies, scopes, and Decorate. Apply when using or adopting uber-go/dig, when the codebase imports `go.uber.org/dig`, or when wiring an application graph at startup. For higher-level lifecycle and modules, see `samber/cc-skills-golang@golang-uber-fx` skill."user-invocable: true
查看另外 1 个位置
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.19.0"allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
中风险

HTTP 示例监听所有网络接口

原文依据:2 处
发现了什么

示例把服务器地址设为 `:8080` 并调用 `ListenAndServe`。在 Go 中,省略主机通常会监听所有可用接口,而不是只限本机。

为什么需要注意

若主机防火墙、容器端口或云网络允许访问,示例路由可能意外暴露给局域网或公网客户端。

完整 HTTP 示例将地址设置为 `:8080`,随后执行 `ListenAndServe()`。在通常的 Go 网络语义下,空主机名会绑定可用接口,因此采用该示例可能让同网段或外部网络访问服务,而不只是本机。材料没有显示 Skill 会自行启动服务。用户可要求示例明确选择 `127.0.0.1:8080`,或说明公网绑定必须配合防火墙、认证和用户授权。

references/recipes.md:69来自说明文档打开原文件
func NewServer(p ServerParams) *http.Server {    mux := http.NewServeMux()    for _, r := range p.Routes {        mux.Handle(r.Pattern, r.Handler)    }    return &http.Server{Addr: ":8080", Handler: mux}}
查看另外 1 个位置
references/recipes.md:86来自说明文档打开原文件
    err := c.Invoke(func(srv *http.Server) error {        log.Println("listening on", srv.Addr)        return srv.ListenAndServe()    })    if err != nil {
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 是面向 Go 项目的 uber-go/dig 使用指南,主要提供依赖注入的架构建议和示例;没有自动安装步骤。

查看原文
SKILL.md:16来自说明文档打开原文件
        - go    install: []    skill-library-version: "1.19.0"
SKILL.md:23来自说明文档打开原文件
**Persona:** You are a Go architect wiring an application graph with dig. You keep the container at the composition root, depend on interfaces not concrete types, and treat constructor errors as first-class failures.# Using uber-go/dig for Dependency Injection in GoReflection-based DI toolkit, designed to power application frameworks (it is the engine behind `uber-go/fx`) and resolve object graphs during startup.

Skill 声明可读写项目、运行 Go 与 git 命令、访问网络文档并调用其他代理;这些是权限声明,不代表本次材料证明它已经执行了这些操作。

查看原文
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.19.0"allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:  - "**/*.go"---

示例包含启动 HTTP 服务、创建依赖关系图文件以及在测试中以 DryRun 验证图结构;这些代码只有在代理写入项目或用户复制运行时才会生效。

查看原文
SKILL.md:178来自说明文档打开原文件
    err := c.Invoke(func(srv *http.Server) error {        return srv.ListenAndServe()    })    if err != nil {
references/advanced.md:86来自说明文档打开原文件
```gof, _ := os.Create("graph.dot")_ = dig.Visualize(c, f)// then: dot -Tpng graph.dot -o graph.png```
references/testing.md:71来自说明文档打开原文件
```gofunc TestProductionGraph(t *testing.T) {    c := dig.New(dig.DryRun(true))    // Replicate every Provide() from main()    require.NoError(t, registerAll(c))    // Invoke the same root the production binary does    require.NoError(t, c.Invoke(func(*http.Server, *Worker, *MetricsExporter) {}))}````DryRun(true)` skips constructor execution — the graph is validated structurally. This catches missing-provider and type-mismatch errors without spinning up real DB connections.
从这里开始 · 工作说明SKILL.md
golang-uber-dig
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 6 个章节,可在原文件中查看。

文件引用关系图

3 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录5 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/advanced.md已纳入全文
  • references/recipes.md已纳入全文
  • references/testing.md已纳入全文
  • evals/evals.json已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • evals/evals.json配套文件
  • references/advanced.md配套文件
  • references/recipes.md配套文件
  • references/testing.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:12来自说明文档打开原文件
    emoji: "⛏"    homepage: https://github.com/samber/cc-skills-golang    requires:
SKILL.md:31来自说明文档打开原文件
- [pkg.go.dev/go.uber.org/dig](https://pkg.go.dev/go.uber.org/dig)- [github.com/uber-go/dig](https://github.com/uber-go/dig)
SKILL.md:32来自说明文档打开原文件
- [pkg.go.dev/go.uber.org/dig](https://pkg.go.dev/go.uber.org/dig)- [github.com/uber-go/dig](https://github.com/uber-go/dig)
运行命令
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.19.0"allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
SKILL.md:40来自说明文档打开原文件
```bashgo get go.uber.org/dig
读取文件
SKILL.md:78来自说明文档打开原文件
err := c.Provide(func(cfg *Config) (*sql.DB, error) {    return sql.Open("postgres", cfg.DSN)})
references/recipes.md:112来自说明文档打开原文件
func NewDatabases(cfg *Config) (DBResult, error) {    rw, err := sql.Open("postgres", cfg.PrimaryDSN)    if err != nil {
references/recipes.md:116来自说明文档打开原文件
    }    ro, err := sql.Open("postgres", cfg.ReadOnlyDSN)    if err != nil {
读取密钥或账号配置
references/recipes.md:233来自说明文档打开原文件
        zap.String("service", cfg.ServiceName),        zap.String("env", cfg.Env),    )
读取了多少行
930
文件校验值(用于核对版本)
da2b5576204320e49a7e59af926194309cc583cc7a36152411244a5a495b52cf