安装并运行未固定版本的最新工具会引入可变的供应链执行风险
原文依据:4 处安装说明和项目工具示例使用 `@latest`,随后指示通过 `go tool` 或 PATH 执行下载的程序。相同操作在不同日期可能取得不同代码,不能仅凭仓库中的固定版本审查来预测。
如果上游版本、模块分发路径或账号在安装时被破坏,恶意或有缺陷的可执行代码可能以代理的文件和环境权限运行。
该技能主动声明安装 `govulncheck@latest`,并允许代理执行该程序;工具固定示例也先以 `@latest` 修改模块,再通过 `go tool` 运行。首次解析的版本会随时间变化,因此用户可能在审查具体版本前下载并执行外部代码。用户可要求作者使用明确版本,并在执行前展示来源、版本及 go.mod/go.sum 差异。
- govulncheck install: - kind: go package: golang.org/x/vuln/cmd/govulncheck@latest bins: [govulncheck]allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(govulncheck:*) AskUserQuestion查看另外 3 个位置
```bash# Add tools to the current module.go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latestgo get -tool golang.org/x/vuln/cmd/govulncheck@latestgo get -tool golang.org/x/perf/cmd/benchstat@latest# Run pinned tools reproducibly.go tool golangci-lint run ./...go tool govulncheck ./...go tool benchstat old.txt new.txt bins: [govulncheck]allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(govulncheck:*) AskUserQuestion---```bash# Add tools to the current module.go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latestgo get -tool golang.org/x/vuln/cmd/govulncheck@latestgo get -tool golang.org/x/perf/cmd/benchstat@latest# Run pinned tools reproducibly.go tool golangci-lint run ./...go tool govulncheck ./...go tool benchstat old.txt new.txt