From f0aa5d9035a5747aa5e5b62e2446bdebdfe4ab5a Mon Sep 17 00:00:00 2001 From: Hoshi <132435834+hoshimoe@users.noreply.github.com> Date: Mon, 17 Aug 2026 05:54:02 +0000 Subject: [PATCH] =?UTF-8?q?CI=20=E5=88=86=E7=95=8C=E6=94=B9=E6=88=90?= =?UTF-8?q?=E3=80=8C=E6=9C=83=E4=B8=8D=E6=9C=83=E5=BD=B1=E9=9F=BF=20correc?= =?UTF-8?q?tness=E3=80=8D=EF=BC=9AGitleaks=20=E6=8E=9B=E5=9B=9E=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 裁示 2026-08-16。兩組驗證回答的是不同的問題——integration/e2e 問「這個 PR 合進去會不會真的壞」,掃描問「現在這份 main 有沒有已知安全問題」。第二種 問的是現況,所以不必卡在每個 PR 上。 但 Gitleaks 不屬於第二種。判準是漏到 main 之後要付什麼:CodeQL/govulncheck/ Trivy 找到的東西修程式就結束了;一個憑證進了 main 就進了 git 歷史,刪掉不會 讓它失效,必須輪替。那一段不是 CI 省得下來的東西。 作法是把閘門下移:ci.yml 的 security job 不再帶 if(帶在那裡會把 Gitleaks 一起關掉),改由 security.yml 的 codeql/govulncheck/trivy 各自帶 if: github.event_name != pull_request。Gitleaks 那個 job 刻意沒有。 刻意不把 Gitleaks 搬成獨立 workflow:那會把檢查名稱從「安全掃描 / Gitleaks」 變成「Gitleaks / Gitleaks」,而分支保護是按名字釘的。security.yml 的 on: 註解早就記著這個代價。閘門下移拿到相同行為且一個字都沒改到名稱。 順帶:「重型」這個詞退休,改叫環境相依的完整驗證。它是照「要起幾個真東西」 取的名字,而那從來不是判準——實測 1.5~6.5 分鐘,比安全掃描便宜。 --- .github/workflows/ci.yml | 21 +++++++++++++++------ .github/workflows/security.yml | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba8545d..9dd7dfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,13 +66,22 @@ jobs: # # 掃描本身的定義在 `security.yml`,那支同時還掛著每週排程。 security: - # **只在 main(與手動)跑,PR 上不掃。** 掃描找到的東西是「處理一次就 - # 結束」的那一類,不是每個 PR 都要重新確認一次的;而它是這條流水線上 - # 最慢的一段,掛在 PR 上換到的回饋遠少於它拖長的等待。 + # **這一組在 PR 上也跑,但裡面只有 Gitleaks 會動**(裁示 2026-08-16)。 # - # 用 `!= 'pull_request'` 而不是 `== 'push'`:後者會順手把 - # `workflow_dispatch` 的手動掃描也關掉,而那是要用的。 - if: github.event_name != 'pull_request' + # 判準是「漏到 `main` 之後要付什麼」: + # + # | | 補救 | + # |---|---| + # | CodeQL/govulncheck/Trivy | **修程式**,修好就結束 | + # | **Gitleaks** | 刪掉不夠——憑證已經在 git 歷史裡,**必須輪替** | + # + # 前三種在 PR 攔下與在 `main` 攔下代價一樣,所以留在 `main`(省下每個 PR + # 數分鐘);Gitleaks 是唯一代價不同的,所以掛回 PR。 + # + # **閘門下移到被呼叫的那三個 job 上**(`security.yml` 裡各自的 + # `if: github.event_name != 'pull_request'`),不是留在這裡——留在這裡會把 + # Gitleaks 一起關掉。這樣做同時保住了檢查名稱:它仍然是 + # `安全掃描 / Gitleaks`,按名字釘住的分支保護不受影響。 name: 安全掃描 # 閘門對公開倉庫也成立了(裁示 2026-08-16):掃描要先等基礎驗證綠。 # 取代 workspace decisions/infrastructure/公開倉庫的掃描不經閘門.md diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index f1990b4..734ec1a 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -73,6 +73,16 @@ permissions: jobs: codeql: + # 這一種在 PR 上不跑(裁示 2026-08-16):找到的東西是「修一次就結束」的, + # 在 PR 攔下與在 `main` 攔下代價一樣。Gitleaks 沒有這一行——它是例外, + # 理由見 `ci.yml` 的 `security` job。 + # + # 用 `!= 'pull_request'` 而不是 `== 'push'`:後者會順手把排程與 + # `workflow_dispatch` 的手動掃描也關掉,而那兩個都是要用的。 + # + # 被 `ci.yml` 呼叫時,這裡讀到的 `github.event_name` 是**呼叫端的**事件, + # 所以這個判斷成立。 + if: github.event_name != 'pull_request' name: CodeQL (${{ matrix.language }}) runs-on: ubuntu-latest timeout-minutes: 40 @@ -176,6 +186,16 @@ jobs: if-no-files-found: warn trivy: + # 這一種在 PR 上不跑(裁示 2026-08-16):找到的東西是「修一次就結束」的, + # 在 PR 攔下與在 `main` 攔下代價一樣。Gitleaks 沒有這一行——它是例外, + # 理由見 `ci.yml` 的 `security` job。 + # + # 用 `!= 'pull_request'` 而不是 `== 'push'`:後者會順手把排程與 + # `workflow_dispatch` 的手動掃描也關掉,而那兩個都是要用的。 + # + # 被 `ci.yml` 呼叫時,這裡讀到的 `github.event_name` 是**呼叫端的**事件, + # 所以這個判斷成立。 + if: github.event_name != 'pull_request' name: Trivy runs-on: ubuntu-latest timeout-minutes: 25