跳转到正文
报告库
用途分类 / 内容写作

Golang Stretchr Testify Skill 安全审计

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

Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification, suite lifecycle, and advanced patterns like Eventually, JSONEq, and custom match

第三方安全检查结论

发现安全风险

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

自动安装未固定版本的第三方 Go 可执行文件

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

清单要求安装 `github.com/cweill/gotests/...@latest`。`latest` 会随时间变化,用户无法仅凭本次审查知道将下载和运行哪一版代码;而正文的 Testify 指南并未显示必须使用 gotests。

为什么需要注意

如果宿主自动处理依赖,未来发布或被接管的上游版本可能以开发环境权限执行,接触工作区文件及 Go 构建环境。这里没有证据表明当前版本已经恶意。

清单会在安装条件下获取 `github.com/cweill/gotests/...@latest`,版本未固定,未来解析到的代码可能变化。这是供应链与可复现性风险,并不证明该依赖恶意;正文所述用途是 Testify 测试指导,也未在可见内容中说明为何必须安装 gotests。用户可要求作者固定经审核的版本和校验信息,或禁用自动安装。

SKILL.md:13来自说明文档打开原文件
    homepage: https://github.com/samber/cc-skills-golang    requires:      bins:        - go        - gotests    install:      - kind: go        package: github.com/cweill/gotests/...@latest        bins: [gotests]    skill-library-version: "1.11.1"
查看另外 1 个位置
SKILL.md:3来自说明文档打开原文件
name: golang-stretchr-testifydescription: "Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification, suite lifecycle, and advanced patterns like Eventually, JSONEq, and custom matchers. Apply when the codebase imports github.com/stretchr/testify."user-invocable: true
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
低风险

声明的工具权限超过 Testify 指南的明显需要

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

该 Skill 除读写 Go 文件和运行测试工具外,还声明了所有匹配 `git:*` 的命令、网络抓取和 Agent 能力。正文没有给出需要修改 Git 远端、分支或历史的工作流。

为什么需要注意

如果宿主将该字段当作有效授权,受误导的代理可能执行推送、删除分支或其他 Git 状态变更,也能取得未审查的网络内容。该权限声明本身并不证明这些操作会发生。

该声明允许匹配全部 `git:*` 的命令,并提供 Agent、WebFetch 及文件写入能力;若宿主按此授权,Skill 被调用时就可能访问网络、改动仓库或委派任务。可见的写作与审查模式没有限定这些能力的具体用途。这不表示权限一定会被使用或会修改远端,但扩大了潜在影响面。用户可要求最小权限清单,并在宿主中禁止 Git 写操作、网络访问及代理委派,除非逐次批准。

SKILL.md:22来自说明文档打开原文件
    skill-library-version: "1.11.1"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(gotests:*) AskUserQuestion Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
查看另外 1 个位置
SKILL.md:29来自说明文档打开原文件
**Modes:**- **Write mode** — adding new tests or mocks to a codebase.- **Review mode** — auditing existing test code for testify misuse.
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。发现 1 项风险
中风险

错误地声称 Testify 的 Equal 对指针只比较地址

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

指南称 `is.Equal(ptr1, ptr2)` 比较地址,但 Testify 的 `Equal` 通常使用深度相等语义;两个不同地址、内容相同的指针可以相等。评测文件又要求模型重复这一说法,使错误更可能稳定出现在回答中。

为什么需要注意

用户可能误诊本来由字段差异、类型差异或其他原因造成的测试失败,并不必要地解引用指针或改用只比较导出字段的断言,从而改变或削弱测试含义。

这是活跃的技术指导,不是警告或反例:指南明确声称 `Equal` 比较指针地址,并让用户解引用或改用另一断言;评测又要求模型复述该结论。Testify 的 `Equal` 使用深度相等语义时,内容相同但地址不同的指针通常可判为相等,因此该指导可能误导用户诊断测试或改写本来正确的断言。用户可要求作者以对应 Testify 版本的实现或测试验证并更正此规则。

SKILL.md:192来自说明文档打开原文件
- **Missing `suite.Run()`** — without the launcher function, zero tests execute silently- **Comparing pointers** — `is.Equal(ptr1, ptr2)` compares addresses. Dereference or use `EqualExportedValues`
查看另外 2 个位置
evals/evals.json:113来自说明文档打开原文件
    "name": "pointer-comparison-trap",    "description": "Tests awareness that is.Equal(ptr1, ptr2) compares addresses, not values",    "prompt": "I have two *User pointers pointing to different structs with the same field values. My test `assert.Equal(t, user1, user2)` is failing. Both users have Name='Alice' and Age=30. What's wrong?",    "trap": "Model may suggest various debugging approaches without identifying the core issue: Equal on pointers compares addresses",    "assertions": [      {"id": "9.1", "text": "Identifies that assert.Equal on pointers compares memory addresses, not struct values"},      {"id": "9.2", "text": "Recommends dereferencing the pointers (e.g., assert.Equal(t, *user1, *user2)) or using EqualExportedValues"},      {"id": "9.3", "text": "Mentions EqualExportedValues as an alternative for comparing only exported fields"}    ]
evals/evals.json:112来自说明文档打开原文件
    "id": 9,    "name": "pointer-comparison-trap",    "description": "Tests awareness that is.Equal(ptr1, ptr2) compares addresses, not values",    "prompt": "I have two *User pointers pointing to different structs with the same field values. My test `assert.Equal(t, user1, user2)` is failing. Both users have Name='Alice' and Age=30. What's wrong?",    "trap": "Model may suggest various debugging approaches without identifying the core issue: Equal on pointers compares addresses",    "assertions": [      {"id": "9.1", "text": "Identifies that assert.Equal on pointers compares memory addresses, not struct values"},      {"id": "9.2", "text": "Recommends dereferencing the pointers (e.g., assert.Equal(t, *user1, *user2)) or using EqualExportedValues"},      {"id": "9.3", "text": "Mentions EqualExportedValues as an alternative for comparing only exported fields"}    ]
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 的实际内容是一份 Testify 使用指南,提供“编写”和“审查”两种模式,并可能在编写模式下向用户代码库添加测试或 mock。

查看原文
SKILL.md:29来自说明文档打开原文件
**Modes:**- **Write mode** — adding new tests or mocks to a codebase.- **Review mode** — auditing existing test code for testify misuse.

它引导代理使用外部 Go 文档工具,优先查询另一个技能,并将 Context7 作为后备来源;因此部分回答可能依赖运行时取得的外部内容。

查看原文
SKILL.md:38来自说明文档打开原文件
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.
从这里开始 · 工作说明SKILL.md
golang-stretchr-testify
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

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

检查范围与遗漏

逐文件查看涉及的内容

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

  • SKILL.md已纳入全文
  • references/mock.md已纳入全文
  • evals/evals.json已纳入全文

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

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

代码和说明中提到的操作

连接外部网站
SKILL.md:12来自说明文档打开原文件
    emoji: "✅"    homepage: https://github.com/samber/cc-skills-golang    requires:
evals/evals.json:75来自说明文档打开原文件
    "description": "Tests knowledge of chaining .Once() calls to return different values per call for retry testing",    "prompt": "I need to test that my Go HTTP client retries on failure. The client calls Fetcher.Fetch(url string) ([]byte, error). First call should return a timeout error, second call should succeed with some data. How do I set up this mock?",    "trap": "Model may not know how to return different values per call and instead use a single Return() that applies to all calls",
运行命令
SKILL.md:22来自说明文档打开原文件
    skill-library-version: "1.11.1"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(gotests:*) AskUserQuestion Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*paths:
读取了多少行
451
文件校验值(用于核对版本)
2cdfe3151a8172f637f9ad646202b738e382352f705f573ace9f082b7c5ad2e8