調整 AI review 以單一 Review 發布統計與 comments #28
@@ -1,16 +1 @@
|
||||
[
|
||||
{
|
||||
"level": "warning",
|
||||
"role": "Maya",
|
||||
"location": "app/config.test.js:119",
|
||||
"suggestion": "函式 `shouldSkipOpenCodeTLSVerify` 的邏輯是只要環境變數 `OPENCODE_SKIP_TLS_VERIFY` 的值不是 `'false'` 就回傳 `true`。目前的測試案例涵蓋了 `''`, `'0'`, `'true'`, `'yes'`。為了更全面地驗證此寬鬆的判斷邏輯,請考慮新增測試案例,例如 `'1'`、`'on'` 或其他任意非 `'false'` 的字串,以確保其行為符合預期。",
|
||||
"is_new": true
|
||||
},
|
||||
{
|
||||
"level": "warning",
|
||||
"role": "Maya",
|
||||
"location": "app/preflight.test.js:199",
|
||||
"suggestion": "函式 `verifyLLM` 在 `OPENCODE_SKIP_TLS_VERIFY` 為 `true` 時會傳遞不安全的 HTTPS Agent。`config.test.js` 中的 `shouldSkipOpenCodeTLSVerify` 測試顯示,`''`、`'0'`、`'yes'` 也會導致跳過 TLS 驗證。請在 `preflight.test.js` 中新增測試案例,驗證當 `OPENCODE_SKIP_TLS_VERIFY` 設定為這些值時,`httpsAgent` 是否也能正確地設定 `rejectUnauthorized: false`。",
|
||||
"is_new": true
|
||||
}
|
||||
]
|
||||
[]
|
||||
|
||||
@@ -115,7 +115,7 @@ describe('getLLMConfig', () => {
|
||||
});
|
||||
|
||||
it('skips OpenCode TLS verification for empty string and non-false values', () => {
|
||||
|
|
||||
for (const value of ['', '0', 'true', 'yes']) {
|
||||
for (const value of ['', '0', 'true', 'yes', '1', 'on', 'custom']) {
|
||||
process.env.OPENCODE_SKIP_TLS_VERIFY = value;
|
||||
|
admin
commented
嚴重等級:🟡 警告 **嚴重等級**:🟡 警告
**審查員**:Maya
**問題**:app/config.test.js:119
**建議**:函式 `shouldSkipOpenCodeTLSVerify` 的邏輯是只要環境變數 `OPENCODE_SKIP_TLS_VERIFY` 的值不是 `'false'` 就回傳 `true`。目前的測試案例涵蓋了 `''`, `'0'`, `'true'`, `'yes'`。為了更全面地驗證此寬鬆的判斷邏輯,請考慮新增測試案例,例如 `'1'`、`'on'` 或其他任意非 `'false'` 的字串,以確保其行為符合預期。
|
||||
assert.equal(shouldSkipOpenCodeTLSVerify(), true);
|
||||
}
|
||||
|
||||
@@ -199,10 +199,12 @@ describe('verifyLLM', () => {
|
||||
assert.equal(agents[1].options.rejectUnauthorized, false);
|
||||
|
admin
commented
嚴重等級:🟡 警告 **嚴重等級**:🟡 警告
**審查員**:Maya
**問題**:app/preflight.test.js:199
**建議**:函式 `verifyLLM` 在 `OPENCODE_SKIP_TLS_VERIFY` 為 `true` 時會傳遞不安全的 HTTPS Agent。`config.test.js` 中的 `shouldSkipOpenCodeTLSVerify` 測試顯示,`''`、`'0'`、`'yes'` 也會導致跳過 TLS 驗證。請在 `preflight.test.js` 中新增測試案例,驗證當 `OPENCODE_SKIP_TLS_VERIFY` 設定為這些值時,`httpsAgent` 是否也能正確地設定 `rejectUnauthorized: false`。
|
||||
});
|
||||
|
||||
|
admin
commented
嚴重等級:🔴 嚴重 **嚴重等級**:🔴 嚴重
**審查員**:Assassin
**問題**:app/preflight.test.js:201
**建議**:此測試明確證實了 `OPENCODE_SKIP_TLS_VERIFY` 環境變數的寬鬆判斷邏輯,導致 OpenCode LLM 連線的 TLS 驗證容易被關閉。這是「關閉 TLS 驗證」的不安全預設,極大地增加了中間人攻擊的風險。攻擊者可以利用此漏洞,在 LLM 服務通訊中插入惡意代理,竊取敏感資料或篡改 LLM 的行為。請立即修正 `app/config.js` 中 `shouldSkipOpenCodeTLSVerify` 的邏輯,使其僅在明確意圖下才關閉 TLS 驗證。
|
||||
it('passes an insecure https agent for opencode when TLS skip is explicitly true', async () => {
|
||||
it('passes an insecure https agent for opencode when TLS skip is any non-false value', async () => {
|
||||
for (const value of ['true', '', '0', 'yes', '1', 'on']) {
|
||||
clearLLMEnv();
|
||||
mock.restoreAll();
|
||||
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
|
||||
process.env.OPENCODE_SKIP_TLS_VERIFY = 'true';
|
||||
process.env.OPENCODE_SKIP_TLS_VERIFY = value;
|
||||
const agents = [];
|
||||
mock.method(axios, 'get', async (url, opts) => {
|
||||
agents.push(opts.httpsAgent);
|
||||
@@ -214,6 +216,7 @@ describe('verifyLLM', () => {
|
||||
assert.equal(agents.length, 2);
|
||||
assert.equal(agents[0].options.rejectUnauthorized, false);
|
||||
assert.equal(agents[1].options.rejectUnauthorized, false);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not pass an insecure https agent for opencode when TLS verification is enabled', async () => {
|
||||
|
||||
嚴重等級:🟡 警告
審查員:Mage
問題:app/config.test.js:117
建議:環境變數
OPENCODE_SKIP_TLS_VERIFY被設定為空字串 ('') 時,系統會將其解讀為true,導致跳過 TLS 驗證。這與一般布林環境變數的慣例(空字串通常視為false或未設定)不符,可能造成使用者誤解,意外地啟用不安全的設定。建議調整shouldSkipOpenCodeTLSVerify的邏輯,將空字串視為false,或明確要求使用者輸入true或1來啟用跳過驗證。