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

Golang Google Wire Skill 安全审计

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

Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind (interface→concrete), wire.Struct, wire.Value, wire.InterfaceValue, wire.FieldsOf, cleanup functions, //go:build wireinject injector files, and generated wire_gen.go. Apply when using or adopting google/wire, when the codebase imports `github.com/google/wire`, or when wiring an application graph at c

第三方安全检查结论

发现安全风险

已检查文件
5
发现的风险
3
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。发现 1 项风险
中风险

安装命令使用可变的 `@latest` 工具版本

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

Skill 指示安装并运行 `github.com/google/wire/cmd/wire@latest`,而不是经过审核的固定版本;同一文档还说明该项目已归档。以后解析到的“latest”内容可能与作者测试时不同。

为什么需要注意

执行安装后会从网络取得代码并在本机编译出随后用于改写项目源码的工具。上游发布变化、依赖变化或供应链受损会直接影响本地执行内容和生成结果。

安装说明和示例都使用 `@latest`,因此每次安装可能取得不同且未经该 Skill 固定验证的代码;项目已归档的说明并不能消除此供应链与可复现性风险。执行安装时会从外部取得并安装可执行程序。用户可要求作者指定经过测试的明确版本和校验方式,并限制自动安装或先审查解析到的版本。

SKILL.md:31来自说明文档打开原文件
- wire: `go install github.com/google/wire/cmd/wire@latest`
查看另外 3 个位置
SKILL.md:37来自说明文档打开原文件
Note: `google/wire` was archived in August 2025 (feature-complete; bug fixes still accepted).
SKILL.md:47来自说明文档打开原文件
```bashgo get -tool github.com/google/wire/cmd/wire@latestgo get github.com/google/wire```
SKILL.md:17来自说明文档打开原文件
        - wire    install:      - kind: go        package: github.com/google/wire/cmd/wire@latest        bins: [wire]    skill-library-version: "0.7.0"
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 1 项风险
中风险

模块级生成命令会覆盖并产生需提交的源码文件

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

Skill 要求在每次依赖图变化后运行 `wire ./...`,该命令覆盖模块内生成的 `wire_gen.go`;文档明确说明生成文件会被覆盖并要求提交。范围是整个模块,而非单个已确认的注入器。

为什么需要注意

现有生成文件中的本地内容会丢失,并可能产生跨多个包的大量持久变更。如果生成工具版本或构建标签选择不符合预期,这些变化可能进入提交和后续构建。

这是符合 Wire 用途的生成流程,但 `wire ./...` 明确针对整个模块的所有注入器,并会重写生成文件;文档还要求提交这些文件。因此,在含有未提交修改或多个注入器的仓库中运行时,可能产生广泛源码差异或覆盖对生成文件的手工修改。用户可要求先查看工作树和目标注入器、缩小命令范围,并在接受差异前不要提交。

SKILL.md:190来自说明文档打开原文件
```bashwire ./...           # regenerate all injectors in the modulewire check ./...     # validate graph without regenerating (fast CI check)```
查看另外 3 个位置
SKILL.md:194来自说明文档打开原文件
Run `wire ./...` after every constructor signature change. Add `//go:generate go run github.com/google/wire/cmd/wire` to injector files so `go generate ./...` also works. Commit `wire_gen.go` — it must stay in sync for CI builds.
SKILL.md:198来自说明文档打开原文件
1. Never edit `wire_gen.go` — it is overwritten on every `wire ./...` run. Treat it as a build artifact that happens to be committed; source of truth is the provider and injector files.2. Always add `//go:build wireinject` to injector files — omitting it causes duplicate-symbol compile errors because both the stub and the generated file define the same function.
SKILL.md:189来自说明文档打开原文件
```bashwire ./...           # regenerate all injectors in the modulewire check ./...     # validate graph without regenerating (fast CI check)```
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
中风险

声明的权限明显超过 Wire 配置工作所需范围

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

`allowed-tools` 允许任意文件读写、所有 `git:*`、代理调用和网页访问,而该 Skill 的核心任务主要需要修改相关 Go 文件并运行 Wire。`git:*` 并未限制为只读命令,因此权限范围也包括可能改变远程仓库或丢弃本地工作的 Git 操作。

为什么需要注意

如果宿主按此清单授权,错误指令或被引入的非可信内容可能导致无关文件被修改、Git 历史或远程仓库状态改变,或把项目内容发送给代理或外部网页工具。该证据只表明能力被授予,并不证明这些操作已经发生。

该 Skill 声明可读写文件,并允许不受子命令限制的 `git:*`、代理和网页访问;其中 Git 写操作和代理调用并非 Wire 代码生成本身的必要条件。仅凭声明不能证明这些能力会被使用,但启用 Skill 时可能扩大对本地工作、仓库远端及网络内容的影响面。用户可要求作者把 Git 限定为只读命令,并在运行时禁用 Agent、WebFetch 和非必要写权限。

SKILL.md:22来自说明文档打开原文件
    skill-library-version: "0.7.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(wire:*) Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 用 Google Wire 在编译前解析依赖图并生成普通 Go 构造代码;它不是运行时依赖注入容器。

查看原文
SKILL.md:35来自说明文档打开原文件
Code-generation DI toolkit. Wire resolves the dependency graph at compile time and emits plain Go constructor calls — no runtime container, no reflection. Errors appear when you run `wire ./...`, not at first request.

它指导用户把带 `wireinject` 构建标签的注入器存根排除在正常构建之外,并使用生成的 `wire_gen.go`。

查看原文
SKILL.md:101来自说明文档打开原文件
The injector file declares the initialization function. Wire generates its body into `wire_gen.go` and replaces the stub.
SKILL.md:117来自说明文档打开原文件
The `//go:build wireinject` tag prevents the stub from being compiled into the binary — only `wire_gen.go` (which has no such tag) makes it through `go build`. Without this tag, both files define the same function, causing a compile error.

其日常流程会在整个 Go 模块中重新生成注入器,并要求将生成文件提交到版本库。

查看原文
SKILL.md:189来自说明文档打开原文件
```bashwire ./...           # regenerate all injectors in the modulewire check ./...     # validate graph without regenerating (fast CI check)```
SKILL.md:194来自说明文档打开原文件
Run `wire ./...` after every constructor signature change. Add `//go:generate go run github.com/google/wire/cmd/wire` to injector files so `go generate ./...` also works. Commit `wire_gen.go` — it must stay in sync for CI builds.
从这里开始 · 工作说明SKILL.md
golang-google-wire
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 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:39来自说明文档打开原文件
**Official Resources:** [pkg.go.dev](https://pkg.go.dev/github.com/google/wire) · [github.com/google/wire](https://github.com/google/wire) · [User Guide](https://github.com/google/wire/blob/main/docs/guide.md) · [Best Practices](https://github.com/google/wire/blob/main/docs/best-practices.md)
SKILL.md:235来自说明文档打开原文件
If you encounter a bug or unexpected behavior in google/wire, open an issue at <https://github.com/google/wire/issues>.
运行命令
SKILL.md:22来自说明文档打开原文件
    skill-library-version: "0.7.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(wire:*) Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
SKILL.md:47来自说明文档打开原文件
```bashgo get -tool github.com/google/wire/cmd/wire@latest
SKILL.md:189来自说明文档打开原文件
```bashwire ./...           # regenerate all injectors in the module
读取文件
SKILL.md:70来自说明文档打开原文件
func NewConfig() *Config                          { return &Config{Addr: ":8080"} }func NewDB(cfg *Config) (*sql.DB, error)          { return sql.Open("postgres", cfg.DSN) }func NewRedis(cfg *Config) (*redis.Client, func(), error) { // cleanup chained in reverse order
references/advanced.md:24来自说明文档打开原文件
func NewDB(cfg *Config) (*sql.DB, func(), error) {    db, err := sql.Open("postgres", string(cfg.DSN))    if err != nil { return nil, nil, err }
references/recipes.md:63来自说明文档打开原文件
func NewDB(cfg *config.Config) (*sql.DB, func(), error) {    db, err := sql.Open("postgres", cfg.DSN)    if err != nil { return nil, nil, err }
读取密钥或账号配置
evals/evals.json:64来自说明文档打开原文件
    "description": "Tests the named-type pattern to disambiguate multiple values of the same underlying type",    "prompt": "I'm building a Go service with google/wire. I need to inject two database connection strings — one for the primary database and one for a read replica. I tried this:\n\n```go\nfunc NewPrimaryDSN() string { return os.Getenv(\"PRIMARY_DSN\") }\nfunc NewReplicaDSN() string { return os.Getenv(\"REPLICA_DSN\") }\n\nvar DBSet = wire.NewSet(NewPrimaryDSN, NewReplicaDSN, NewPrimaryDB, NewReplicaDB)\n```\n\nWire complains about multiple bindings for string. How should I structure this?",    "trap": "Without the skill, the model might suggest using wire.Value or provider arguments, or use a config struct — missing the idiomatic named-type wrapper pattern that wire's own docs recommend.",
evals/evals.json:206来自说明文档打开原文件
    "description": "Tests wire.FieldsOf to expose struct fields as individual graph nodes",    "prompt": "I have a single Config struct in my Go app with google/wire:\n\n```go\ntype Config struct {\n    DatabaseDSN  string\n    CacheAddress string\n    APIKey       string\n}\n\nfunc NewConfig() *Config { return loadFromEnv() }\n```\n\nNewDB needs a DatabaseDSN string, NewCache needs a CacheAddress string, NewExternalClient needs an APIKey string — but all three are plain strings. How do I make these available to the wire graph without creating three separate provider functions?",    "trap": "Without the skill, the model will suggest three named-type wrappers or three extraction functions, missing wire.FieldsOf which promotes struct fields directly.",
evals/evals.json:211来自说明文档打开原文件
        "id": "8.1",        "text": "Uses wire.FieldsOf(new(Config), \"DatabaseDSN\", \"CacheAddress\", \"APIKey\") or a subset"      },
读取了多少行
1,193
文件校验值(用于核对版本)
83e6fe593c76e123e05e7c76e2f71aa35d6c6ed4a9ec2cfb1bddc128b35130b3