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

Đang mở
#419 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@fx-kurumi đang làm issue này rồi.

Từ ngày 13/11/2026.

  • #420 của @fx-kurumi — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
20/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

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/.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

现状问题

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/。
Ngôn ngữ chính
Go
Star
141
Fork
28
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
113

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/LoopForge

Tất cả issue của Tencent/LoopForge

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.