From d4d02638b9b0422276dacaf923bb414cdb2221bd Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 26 Jun 2026 15:46:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(dockerfile):=20=E7=A7=BB=E9=99=A4=20--n?= =?UTF-8?q?o-check-certificate=20=E4=B8=A6=E9=87=98=E9=81=B8=20alpine:3.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 對齊上游 actions/code-review:保留套件來源 TLS 憑證驗證、釘選明確基底版本以確保建置可重現。 Co-Authored-By: Claude Opus 4.8 (1M context) --- Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d708574..d53aa5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,18 +6,15 @@ # 更新日期:2026/06/26 11:34:46 # ============================================================================= -# 指定基底映像為 Alpine Linux 最新版;Alpine 體積小,可縮小最終映像大小並加快拉取速度。 -# 需人工確認:使用 latest tag 會在不同時間建置出不同基底版本,可能影響可重現性, -# 建議釘選明確版本(例如 alpine:3.20)以確保建置一致。 -FROM alpine:latest +# 指定基底映像為 Alpine Linux 3.20(釘選明確版本以確保建置可重現,與上游 actions/code-review 一致)。 +# Alpine 體積小,可縮小最終映像大小並加快拉取速度。 +FROM alpine:3.20 -# 安裝必要的工具 # 安裝執行 code review 所需的工具:bash(執行 entrypoint 腳本)、git(前置遠端驗證/取得 diff)、 # nodejs 與 npm(執行 app 內的 Node.js 程式)。 # --no-cache:不保留 apk 套件索引快取,避免殘留在映像層中以減少映像大小。 -# 需人工確認:--no-check-certificate 會略過套件來源的憑證驗證,存在中間人攻擊風險, -# 僅在內網或憑證受限環境下使用;正式環境建議移除以維持安全性。 -RUN apk add --no-cache --no-check-certificate bash git nodejs npm +# 已移除 --no-check-certificate:保留套件來源 TLS 憑證驗證以防中間人攻擊(標準 alpine 來源憑證有效,上游亦未使用此旗標)。 +RUN apk add --no-cache bash git nodejs npm # 將專案的 app/ 目錄複製到映像內的 /app;包含 Node.js 程式碼與 package.json 等相依宣告。 COPY ./app /app -- 2.53.0 From e36ce75d5f0d02c2332bbb97d9111c16b741652b Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 26 Jun 2026 15:46:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(ai-review):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=B7=B2=E8=A7=A3=E6=B1=BA=E7=9A=84=20Dockerfile=20findings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/ai-review/findings.json | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.gitea/ai-review/findings.json b/.gitea/ai-review/findings.json index 1320606..bf416cc 100644 --- a/.gitea/ai-review/findings.json +++ b/.gitea/ai-review/findings.json @@ -1,28 +1,4 @@ [ - { - "level": "critical", - "role": "Assassin", - "location": "Dockerfile:17", - "problem": "在 `apk add` 中使用了 `--no-check-certificate` 參數。這會強制忽略套件來源的 SSL/TLS 憑證檢查,攻擊者可以透過中間人攻擊(MITM)在容器建置期間植入惡意套件,導致整個建置環境被入侵。", - "suggestion": "正式環境嚴禁使用 `--no-check-certificate`。若遇到憑證問題,應排查環境配置(如是否缺少根憑證),或是確實解決憑證驗證問題,確保套件來源可信。", - "is_new": false - }, - { - "level": "warning", - "role": "Assassin", - "location": "Dockerfile:12", - "problem": "使用了 `alpine:latest` 作為基底映像。`latest` 標籤極不穩定,當 Alpine Linux 發布新版本時,建置出的映像環境可能會產生難以預期的變更,甚至引入不相容的套件版本,導致建置再現性(Reproducibility)崩潰。", - "suggestion": "建議釘選明確的 Alpine 版本號(例如 `alpine:3.20`),以確保每次建置的執行環境完全一致且可預測。", - "is_new": false - }, - { - "level": "warning", - "role": "Leo", - "location": "Dockerfile:21", - "problem": "Dockerfile 中留下了明確的安全性警告註解(關於 --no-check-certificate)。這種將安全性風險留在程式碼中並以註解提醒的做法,容易被未來的維護者忽略,導致潛在的安全性漏洞。", - "suggestion": "若此 flag 僅為暫時性,應盡快優化環境以移除它;若不可避免,應將此設定集中管理,而非在 Dockerfile 中寫死此類不安全的設定。", - "is_new": false - }, { "level": "info", "role": "Leo", -- 2.53.0