【架构优化】合并 domain.PublicRunnerTask 中单仓库/多仓库重复的凭据脱敏为 publicRunnerRepository

未关闭
#419 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@fx-kurumi 已经在做这个了。

开始于 2026年11月13日。

  • #420 来自 @fx-kurumi —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
20/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
停滞
技术栈
go
领域
backend

调研方向

The duplicated scrubbing lives in PublicRunnerTask in internal/domain/runner.go, once for the single Repository field and once for the Repositories list. Read both blocks and the existing tests TestPublicRunnerTaskScrubsMultiRepositoryTokens and TestPublicRunnerTaskStripsCloneURLCredentials in runner_test.go. Work is already in progress in linked PR #420, so check that first. Done means one shared helper handles both paths and the tests pass under go test ./internal/domain/.

由索引模型根据 Issue 内容生成。

描述

现状问题

internal/domain/runner.go 的 PublicRunnerTask 对 Invocation.Repository(旧的单仓库字段)和 Invocation.Repositories(多仓库列表)各写了一遍相同的脱敏逻辑:清空 GitToken、用 StripURLCredentials 去掉 CloneURL 里的凭据。两处必须保持同步,以后给 RunnerRepository 加敏感字段时容易只改一处,造成凭据泄漏到管理接口响应。

重构方案

抽出包内函数 publicRunnerRepository(repository RunnerRepository) RunnerRepository(值传入、值返回,不改调用方数据),单仓库和多仓库两处都改为调用它。PublicRunnerTask 签名与行为不变。

影响范围

仅 internal/domain/runner.go 一个函数内部,以及 internal/domain/runner_test.go 新增测试;不改对外接口、不改 JSON 结构。

验证方式

  • 新增 publicRunnerRepository 单元测试:脱敏 token 与 URL 凭据、保留其他字段、不修改入参。
  • 原有 TestPublicRunnerTaskScrubsMultiRepositoryTokens / TestPublicRunnerTaskStripsCloneURLCredentials 继续通过。
  • gofmt、go vet ./internal/domain/、go test ./internal/domain/。
主要语言
Go
星标
141
派生
28
平均合并
1 天 15 小时
30 天内合并 PR
113

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Tencent/LoopForge 的其他 Issue

查看 Tencent/LoopForge 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。