【架构优化】合并 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 摘要。