fix: support wrapped exclusions schema
This commit is contained in:
+21
-1
@@ -34,6 +34,12 @@ function readJSONArray(fullPath, label) {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeExclusions(data) {
|
||||
if (Array.isArray(data)) return data;
|
||||
if (data && Array.isArray(data.excluded_findings)) return data.excluded_findings;
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 讀取舊 findings(從 workspace 的 FINDINGS_PATH)
|
||||
*/
|
||||
@@ -107,7 +113,21 @@ export async function deduplicateWithAI(findings) {
|
||||
* 讀取排除問題檔案(從 workspace 的 EXCLUSIONS_PATH)
|
||||
*/
|
||||
export function loadExclusions(workspace) {
|
||||
const exclusions = readJSONArray(path.join(workspace, EXCLUSIONS_PATH), '排除問題');
|
||||
const fullPath = path.join(workspace, EXCLUSIONS_PATH);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
console.log(' 排除問題檔案不存在,視為空');
|
||||
console.log(' 讀取排除問題: 0 筆');
|
||||
return [];
|
||||
}
|
||||
|
||||
let exclusions = [];
|
||||
try {
|
||||
const data = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
|
||||
exclusions = normalizeExclusions(data);
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ 讀取排除問題失敗: ${e.message},視為空`);
|
||||
exclusions = [];
|
||||
}
|
||||
console.log(` 讀取排除問題: ${exclusions.length} 筆`);
|
||||
return exclusions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user