Redact live-streamed subprocess output in System.run()

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

@armadavalor đang làm issue này rồi.

Từ ngày 25/10/2026.

  • #304 của @armadavalor — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
cli, security

Hướng nghiên cứu

Bắt đầu với src/model/system/system.ts để lần theo đường dẫn ghi stdout/stderr trực tiếp, sau đó đọc src/model/secret-redaction.ts và chuỗi thảo luận review về hành vi redaction hiện có. Kiểm thử một secret bị chia thành hai stream chunk và xác minh rằng đầu ra được truyền được redacted trong khi runResult.output không thay đổi; đồng thời bao phủ cả đường dẫn không có secrets.

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

Mô tả

Context

game-ci/cli#246 added the first secret redaction in src/. Before it, nothing anywhere redacted anything.

That PR covers the paths where secrets are formatted for logging:

  • the logger's formatArgs (so whole-object logs like cli.ts's parsed: dump and loadConfig's cliOptions are scrubbed)
  • the docker run command string logged at -vv
  • System.run's captured-output debug dump, redacted before truncation

It deliberately does not cover live-streamed subprocess output.

The gap

System.run() defaults to silent: false, so Docker.run() writes the child's stdout/stderr straight through to CI logs as it arrives. Those chunks are never redacted.

This is not a regression — that output was equally unredacted before #246 — but it is the one remaining place a registered secret can reach a log.

Why it wasn't fixed in #246

Doing it correctly is more than wrapping each chunk in SecretRedaction.redact():

  1. Chunk boundaries. A secret can be split across two data events, so a naive per-chunk redact misses it. It needs a retained tail of at least maxSecretLength - 1 bytes carried between chunks.
  2. Throughput. This stream carries whole Unity build logs (multi-MB). A regex pass per registered secret per chunk is a real cost on the hot path, unlike the -vv-gated paths #246 touched.
  3. Fidelity. runResult.output should stay unredacted so callers such as UnityBuildValidation.validateBuild keep matching on the true text. Only what is written out should change.
Suggested approach
  • A small streaming redactor holding a carry-over tail sized from the longest registered secret.
  • Apply it only on the write-out path, leaving runResult.output untouched.
  • Skip the work entirely when no secrets are registered, which is the common case and already how SecretRedaction.redact behaves.
  • Test: a secret deliberately split across two chunk boundaries.
References
Ngôn ngữ chính
TypeScript
Star
20
Fork
11
Merge trung bình
5 giờ 28 phút
Pull request đã merge (30 ngày)
4

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 game-ci/cli

Tất cả issue của game-ci/cli

Issue tương tự

Thêm issue về TypeScript

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.