移除 RUNNER_TOKEN 輸入,一律改用 Gitea 自動 token #3

Merged
admin merged 2 commits from ai-review-resolve/develop-20260715-112031 into develop 2026-07-15 04:02:04 +00:00
2 changed files with 8 additions and 12 deletions
Showing only changes of commit adab16fb45 - Show all commits
+3 -7
View File
@@ -1,5 +1,5 @@
# 檔案用途:定義 CLEANUP OLD RELEASES 這個 Docker action 的輸入參數與執行環境
# 更新日期:2026/07/11 21:02:25
# 更新日期:2026/07/15 11:17:00
# Action 名稱,會顯示在 action 市集與文件中
name: 'CLEANUP OLD RELEASES'
@@ -12,10 +12,6 @@ author: 'Jeffery'
# 定義可由使用者或呼叫端傳入的輸入參數
inputs:
# RUNNER_TOKEN 用於授權呼叫 Gitea API;未提供時會改用 secrets
RUNNER_TOKEN:
# 參數說明,讓呼叫端知道這是 Runner Token
description: 'Gitea Runner Token'
# KEEP_COUNT 用於控制保留的 release 數量
KEEP_COUNT:
# 參數說明,這裡表示保留的版本數量
@@ -35,7 +31,7 @@ runs:
GITEA_SERVER_URL: ${{ gitea.server_url }}
# GITEA_REPOSITORY 由 Gitea runtime 注入,供程式指定目標 repo
GITEA_REPOSITORY: ${{ gitea.repository }}
# 優先使用傳入的 RUNNER_TOKEN,否則退回 Gitea token secrets
RUNNER_TOKEN: ${{ inputs.RUNNER_TOKEN || secrets.GITEA_TOKEN || secrets.RUNNER_TOKEN }}
# 使用 Gitea runtime 自動核發的 token,權限僅限當前 repo 且 job 結束即失效
GITEA_TOKEN: ${{ gitea.token }}
# KEEP_COUNT 直接沿用輸入值,交由程式驗證
KEEP_COUNT: ${{ inputs.KEEP_COUNT }}
+5 -5
View File
@@ -400,7 +400,7 @@ function hasBatchFailure(results) {
async function main() {
const GITEA_SERVER_URL = normalizeEnvValue(process.env.GITEA_SERVER_URL);
const GITEA_REPOSITORY = normalizeEnvValue(process.env.GITEA_REPOSITORY);
const RUNNER_TOKEN = normalizeEnvValue(process.env.RUNNER_TOKEN) ?? '';
const GITEA_TOKEN = normalizeEnvValue(process.env.GITEA_TOKEN) ?? '';
const KEEP_COUNT = normalizeEnvValue(process.env.KEEP_COUNT) ?? '';
const MAX_PAGES = normalizeEnvValue(process.env.MAX_PAGES) ?? '';
@@ -421,11 +421,11 @@ async function main() {
const keepCount = Number(KEEP_COUNT);
const authHeaders = {};
if (isEmptyOrNull(RUNNER_TOKEN)) {
warn('RUNNER_TOKEN is empty; release API calls will be anonymous');
if (isEmptyOrNull(GITEA_TOKEN)) {
warn('GITEA_TOKEN is empty; release API calls will be anonymous');
} else {
Review

嚴重等級🟡 警告
審查員:Maya
問題:有 token 時會改成記錄 redacted 訊息並建立 Authorization header,但目前看不到任何測試在保護這個授權分支;一旦 header 格式或遮蔽輸出出錯,就可能讓 API 請求失敗或把敏感值寫進 log。
建議:補一個有 token 的案例,驗證 log 只會出現 [redacted],而實際送出的 header 會是 token ${GITEA_TOKEN},同時不要把明文 token 暴露到輸出中。

**嚴重等級**:🟡 警告 **審查員**:Maya **問題**:有 token 時會改成記錄 redacted 訊息並建立 `Authorization` header,但目前看不到任何測試在保護這個授權分支;一旦 header 格式或遮蔽輸出出錯,就可能讓 API 請求失敗或把敏感值寫進 log。 **建議**:補一個有 token 的案例,驗證 log 只會出現 `[redacted]`,而實際送出的 header 會是 `token ${GITEA_TOKEN}`,同時不要把明文 token 暴露到輸出中。
info('RUNNER_TOKEN=[redacted]');
authHeaders.Authorization = `token ${RUNNER_TOKEN}`;
info('GITEA_TOKEN=[redacted]');
authHeaders.Authorization = `token ${GITEA_TOKEN}`;
}
const serverBase = new URL(GITEA_SERVER_URL);