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

Golang Samber Oops Skill 安全审计

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

Structured error handling in Golang with samber/oops — error builders, stack traces, error codes, error context, error wrapping, error attributes, user-facing vs developer messages, panic recovery, and logger integration. Apply when using or adopting samber/oops, or when the codebase already imports github.com/samber/oops.

第三方安全检查结论

发现安全风险

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

完整记录结构化错误可能泄露个人信息、查询内容和源代码

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

示例把用户邮箱和数据库查询写入错误对象,另一个配置示例启用源代码片段;随后又建议把整个错误进行 JSON 序列化或交给日志器。错误属性会沿调用栈传播,因此这些内容可能一起进入集中日志或错误跟踪系统。

为什么需要注意

日志读取者或第三方监控服务可能获得用户标识、邮箱、内部 SQL、业务数据或应用源代码。若请求/响应附件选择包含正文,风险还会扩大到令牌和提交内容。

这些是示例而非已经执行的操作,但若用户照搬,错误对象会包含邮箱、SQL 查询等数据,并可能被完整序列化到日志。高级配置还明确将源代码片段设为可见;若这类错误发送到集中日志或第三方错误跟踪服务,个人信息、查询结构及内部源码可能被披露。用户可要求作者默认隐藏源码,并在记录前对请求、查询和用户属性进行筛选或脱敏。

SKILL.md:100来自说明文档打开原文件
        return nil, oops.            In("user-repository").            Tags("database", "postgres").            With("query", query).            With("user_id", id).            Wrapf(err, "failed to fetch user from database")    }
查看另外 5 个位置
SKILL.md:139来自说明文档打开原文件
        Tags("orders", "checkout").        Tenant(req.TenantID, "plan", req.Plan).        User(req.UserID, "email", req.UserEmail)
references/advanced.md:24来自说明文档打开原文件
```gooops.StackTraceMaxDepth = 20          // adjust stack trace depthoops.SourceFragmentsHidden = false    // enable source code fragmentsloc, _ := time.LoadLocation("America/New_York")
SKILL.md:245来自说明文档打开原文件
```gofmt.Printf("%+v\n", err)       // verbose with stack tracebytes, _ := json.Marshal(err)  // JSON for loggingslog.Error(err.Error(), slog.Any("error", err))  // slog integration```
SKILL.md:54来自说明文档打开原文件
    Code("network_failure").       // machine-readable identifier    User("user-123", "email", "foo@bar.com").  // user context    With("query", query).          // custom attributes    Errorf("failed to fetch user: %s", "timeout")```
SKILL.md:96来自说明文档打开原文件
func (r *UserRepository) FetchUser(id string) (*User, error) {    query := "SELECT * FROM users WHERE id = $1"    row, err := r.db.Query(query, id)    if err != nil {        return nil, oops.            In("user-repository").            Tags("database", "postgres").            With("query", query).            With("user_id", id).            Wrapf(err, "failed to fetch user from database")    }
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
低风险

声明的工具权限超出结构化错误指导的核心需要

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

Skill 请求读写文件、任意 `git` 子命令、网络文档访问和 Agent 调用。Go 修改和检查与目的相关,但无限定的 Git、网络和代理能力扩大了可影响仓库、远程账户和可披露数据的范围;现有内容没有指示这些能力一定会被使用。

为什么需要注意

若宿主仅依据该声明授予权限,受 Skill 驱动的操作可能修改更多文件、执行提交或推送相关命令,或向外部服务发送查询内容。

这段证据能说明什么

元数据确实列出了文件写入、所有 git 子命令、网络文档访问和 Agent 能力,而 Skill 的目标主要是 Go 错误处理。不过,来源没有说明宿主是否实际授予这些权限,也没有命令要求使用 git、Agent 或写入远程账户;网络访问还有查阅库文档的合理用途。因此只能确认权限声明较宽,无法仅凭此证明会影响仓库、账户或披露数据。用户可在运行时限制为只读及必要的 Go 检查,并按需单独批准网络或 git 操作。

这项判断针对展示的代码和适用条件,不表示风险已经实际发生。
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.21.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:
查看另外 2 个位置
SKILL.md:3来自说明文档打开原文件
name: golang-samber-oopsdescription: "Structured error handling in Golang with samber/oops — error builders, stack traces, error codes, error context, error wrapping, error attributes, user-facing vs developer messages, panic recovery, and logger integration. Apply when using or adopting samber/oops, or when the codebase already imports github.com/samber/oops."user-invocable: true
SKILL.md:39来自说明文档打开原文件
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.
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 指导在 Go 错误中携带领域、标签、错误码、用户/租户信息和自定义属性,并让这些属性随错误沿调用栈传播。

查看原文
SKILL.md:27来自说明文档打开原文件
**samber/oops** is a drop-in replacement for Go's standard error handling that adds structured context, stack traces, error codes, public messages, and panic recovery. Variable data goes in `.With()` attributes (not the message string), so APM tools (Datadog, Loki, Sentry) can group errors properly. Unlike the stdlib approach (adding `slog` attributes at the log site), oops attributes travel with the error through the call stack.
SKILL.md:71来自说明文档打开原文件
| --- | --- || `.With("key", value)` | Add custom key-value attribute (lazy `func() any` values supported) || `.WithContext(ctx, "key1", "key2")` | Extract values from Go context into attributes (lazy values supported) || `.In("domain")` | Set the feature/service/domain || `.Tags("auth", "sql")` | Add categorization tags (query with `err.HasTag("tag")`) || `.Code("iam_authz_missing_permission")` | Set machine-readable error identifier/slug || `.Public("Could not fetch user.")` | Set user-safe message (separate from technical details) || `.Hint("Runbook: https://doc.acme.org/doc/abcd.md")` | Add debugging hint for developers || `.Owner("team/slack")` | Identify responsible team/owner || `.User(id, "k", "v")` | Add user identifier and attributes || `.Tenant(id, "k", "v")` | Add tenant/organization context and attributes || `.Trace(id)` | Add trace / correlation ID (default: ULID) || `.Span(id)` | Add span ID representing a unit of work/operation (default: ULID) || `.Time(t)` | Override error timestamp (default: `time.Now()`) || `.Since(t)` | Set duration based on time since `t` (exposed via `err.Duration()`) || `.Duration(d)` | Set explicit error duration || `.Request(req, includeBody)` | Attach `*http.Request` (optionally including body) || `.Response(res, includeBody)` | Attach `*http.Response` (optionally including body) || `oops.FromContext(ctx)` | Start from an `OopsErrorBuilder` stored in a Go context |

HTTP 示例将技术错误与公开消息分离,并在附加请求时明确不包含请求体。

查看原文
SKILL.md:118来自说明文档打开原文件
    if err != nil {        err = oops.            In("http-handler").            Tags("endpoint", "/users").            Request(r, false).            User(userID).            Wrapf(err, "create user failed")        http.Error(w, oops.GetPublic(err, "Internal server error"), http.StatusInternalServerError)        return
从这里开始 · 工作说明SKILL.md
golang-samber-oops
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 1 个章节,可在原文件中查看。

文件引用关系图

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

检查范围与遗漏

逐文件查看涉及的内容

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

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

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

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

代码和说明中提到的操作

连接外部网站
SKILL.md:12来自说明文档打开原文件
    emoji: "💥"    homepage: https://github.com/samber/cc-skills-golang    requires:
SKILL.md:77来自说明文档打开原文件
| `.Public("Could not fetch user.")` | Set user-safe message (separate from technical details) || `.Hint("Runbook: https://doc.acme.org/doc/abcd.md")` | Add debugging hint for developers || `.Owner("team/slack")` | Identify responsible team/owner |
SKILL.md:276来自说明文档打开原文件
- [github.com/samber/oops](https://github.com/samber/oops)- [pkg.go.dev/github.com/samber/oops](https://pkg.go.dev/github.com/samber/oops)
运行命令
SKILL.md:18来自说明文档打开原文件
    skill-library-version: "1.21.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:
读取了多少行
490
文件校验值(用于核对版本)
cfadf9fc8700a7d2d144c9fc53c3cce3ea0fade70a64b610cbbac9f3c54d1f83