CI:action 釘 commit SHA,並補上兩種安全掃描 - #2
Merged
Merged
Conversation
**釘住的是身分,不是版本。** `actions/checkout@v7` 這樣的 tag 是上游可以移動的 指標——它移動的那一刻,我們的 CI 就在跑另一份程式,沒有任何審閱、沒有任何 diff、沒有任何地方會說出來。全部 47 處改成 40 字元 commit SHA,後面用註解 留版本號給人讀。 釘死之後必須有東西負責更新,否則只是把「安靜地換掉」換成「安靜地停在舊版」, 而兩者看起來一模一樣。所以同時補上 Dependabot(github-actions + gomod/npm), 把上游的更新變成一個看得見、審得到的 PR。 新增 `security.yml`,四種掃描各回答一個別人回答不了的問題:CodeQL(原始碼裡 已知形狀的漏洞)、govulncheck(我們**呼叫得到**的路徑上的 Go 漏洞)、 Gitleaks(有沒有憑證被提交進來)、Trivy(相依與設定)。每週排程,因為新的 advisory 是對著沒有動過的程式發布的。 三個設計決定,都是為了不產生「沒有人能處理的紅燈」: - **SARIF 上傳容許失敗,但一律另存 artifact。** 私有倉庫的 code scanning 要 GHAS,沒有啟用時上傳會 403——那是帳務狀態,不是這次掃描的結論。 - **govulncheck 只有相依的漏洞擋建置,標準函式庫的降為警告。** 兩者可以動的 東西不一樣:相依改一行 go.mod,標準函式庫只能換工具鏈,而永遠會有一個 「最新穩定版仍未修掉」的窗口。實測:七個 Go 倉庫共 121 個可呼叫到的漏洞 **全部**在標準函式庫,相依零個——把它們當紅燈,這支 workflow 第一天就是紅的。 - **Gitleaks 的允許清單列「值」不列「路徑」。** 首次全倉庫掃描 60 個命中全是 誤報,但只有六個相異的值(測試用固定祕密、RFC 6455 的範例 key、hoshi-mail 標示過的開發金鑰)。排除 `*_test.go` 會讓命中歸零,也會讓真的被貼進測試檔的 正式憑證一起消失——而測試檔正是最容易貼進真值的地方。 本機實測過的,不是推上去看 CI(AGENTS.md §1.7.3):gitleaks 對十五個倉庫全綠、 對一個植入的假憑證仍然紅;govulncheck 的判讀腳本從解析後的 YAML 取出來執行, 兩個方向都對;CodeQL 的三個 action 輸入名與 `upload: never` 對著釘住的那顆 commit 逐一核對過。 過程中被實測抓到一個錯:原本寫的是 `gitleaks detect`,而該子命令在 v8.19 就被 拆成 `git` 與 `dir`,v8.30 已經不認得它。
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
全倉庫安全加固的 CI 與掃描那一半。本倉庫沒有安全發現,這個 PR 只有基礎設施。
事項:
workspace/todo/安全加固與掃描自動化.md1. action 釘 commit SHA
釘住的是身分,不是版本。
actions/checkout@v7是一個上游可以移動的指標——它移動的那一刻,我們的 CI 就在跑另一份程式,而沒有任何 diff、沒有任何審閱、
沒有任何地方會說出來。
2. Dependabot(github-actions)
釘死之後必須有東西負責更新,否則只是把「安靜地被換掉」換成「安靜地停在一個
有已知問題的版本上」——而後者看起來和一個剛更新過的 SHA 一模一樣。
3.
security.yml:Gitleaks / Trivy本倉庫只有 Markdown,沒有 Go 或 JS 原始碼,所以沒有 CodeQL 與 govulncheck。
「只有文件」不是不掃憑證的理由——一個被貼進 Markdown 範例的真憑證,
和一個被貼進程式碼的沒有差別。Gitleaks 掃的是整個歷史,
因為一個被刪掉的憑證仍然在歷史裡,而它仍然是一個憑證。
每週排程 + push + 非草稿 PR。
都成立,其中十三個是私有的)。
本倉庫是公開的
新增的檔案(一支 workflow + dependabot 設定 +
.gitleaks.toml)逐一看過,沒有內部服務名、主機、埠或路徑。判準見
AGENTS.md§3 第一條。驗證
本倉庫沒有建置步驟。內部連結與規範關鍵字人工確認過;
本 PR 沒有動任何 Markdown。
Generated by Claude Code