🦅 天眼系统代码审查修复 · 简化正则 + 错误提示优化 + 空值安全 + 降级日志增强
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
9d3fc45205
commit
e9fd2ec4f4
|
|
@ -53,7 +53,7 @@ jobs:
|
||||||
mkdir -p /tmp/skyeye
|
mkdir -p /tmp/skyeye
|
||||||
node scripts/skyeye/scan-workflows.js > /tmp/skyeye/workflow-health.json
|
node scripts/skyeye/scan-workflows.js > /tmp/skyeye/workflow-health.json
|
||||||
gh run list --limit 50 --json name,status,conclusion,createdAt,updatedAt \
|
gh run list --limit 50 --json name,status,conclusion,createdAt,updatedAt \
|
||||||
> /tmp/skyeye/recent-runs.json || echo "[]" > /tmp/skyeye/recent-runs.json
|
> /tmp/skyeye/recent-runs.json || { echo "⚠️ gh run list 失败,使用空列表" && echo "[]" > /tmp/skyeye/recent-runs.json; }
|
||||||
FAILED_COUNT=$(cat /tmp/skyeye/recent-runs.json | \
|
FAILED_COUNT=$(cat /tmp/skyeye/recent-runs.json | \
|
||||||
python3 -c "import sys,json; runs=json.load(sys.stdin); print(sum(1 for r in runs if r.get('conclusion')=='failure'))" 2>/dev/null || echo "0")
|
python3 -c "import sys,json; runs=json.load(sys.stdin); print(sum(1 for r in runs if r.get('conclusion')=='failure'))" 2>/dev/null || echo "0")
|
||||||
echo "failed_count=$FAILED_COUNT" >> $GITHUB_OUTPUT
|
echo "failed_count=$FAILED_COUNT" >> $GITHUB_OUTPUT
|
||||||
|
|
|
||||||
|
|
@ -185,8 +185,10 @@ function main() {
|
||||||
|
|
||||||
if (disallowedFiles.length > 0 && allowedFiles.length > 0) {
|
if (disallowedFiles.length > 0 && allowedFiles.length > 0) {
|
||||||
// 部分文件越权,部分合法 → 回退整个 commit(不做部分修复,避免复杂性)
|
// 部分文件越权,部分合法 → 回退整个 commit(不做部分修复,避免复杂性)
|
||||||
const msg = `⚠️ 部分路径越权 · 推送者: ${actor} · ${developer.name}(${developer.devId})\n\n` +
|
const devName = developer ? `${developer.name}(${developer.devId})` : `未注册开发者`;
|
||||||
`允许路径: ${developer.allowed_paths.join(', ')}\n\n` +
|
const devPaths = developer && developer.allowed_paths ? developer.allowed_paths.join(', ') : '无';
|
||||||
|
const msg = `⚠️ 部分路径越权 · 推送者: ${actor} · ${devName}\n\n` +
|
||||||
|
`允许路径: ${devPaths}\n\n` +
|
||||||
`✅ 合法文件:\n` + allowedFiles.map(f => `- \`${f}\``).join('\n') + '\n\n' +
|
`✅ 合法文件:\n` + allowedFiles.map(f => `- \`${f}\``).join('\n') + '\n\n' +
|
||||||
`❌ 越权文件:\n` + disallowedFiles.map(f => `- \`${f}\``).join('\n') +
|
`❌ 越权文件:\n` + disallowedFiles.map(f => `- \`${f}\``).join('\n') +
|
||||||
`\n\n该 commit 已被自动回退。请将越权文件移除后重新提交。`;
|
`\n\n该 commit 已被自动回退。请将越权文件移除后重新提交。`;
|
||||||
|
|
|
||||||
|
|
@ -104,16 +104,19 @@ function generateReport() {
|
||||||
auto_fixed: repairResult ? repairResult.total_repaired : 0,
|
auto_fixed: repairResult ? repairResult.total_repaired : 0,
|
||||||
needs_human: diagnosis ? diagnosis.needs_human : 0,
|
needs_human: diagnosis ? diagnosis.needs_human : 0,
|
||||||
watching: diagnosis ? diagnosis.watch_list : 0,
|
watching: diagnosis ? diagnosis.watch_list : 0,
|
||||||
issues: diagnosis ? (diagnosis.issues || []).map(i => ({
|
issues: diagnosis ? (diagnosis.issues || []).map(i => {
|
||||||
id: i.id,
|
const repairEntry = repairResult
|
||||||
symptom: i.symptom,
|
? (repairResult.repairs || []).find(r => r.issue_id === i.id)
|
||||||
root_cause: i.root_cause,
|
: null;
|
||||||
impact: i.impact,
|
return {
|
||||||
fix_applied: i.fixable ? i.fix_plan : null,
|
id: i.id,
|
||||||
verified: repairResult
|
symptom: i.symptom,
|
||||||
? (repairResult.repairs || []).find(r => r.issue_id === i.id)?.verified || false
|
root_cause: i.root_cause,
|
||||||
: false
|
impact: i.impact,
|
||||||
})) : []
|
fix_applied: i.fixable ? i.fix_plan : null,
|
||||||
|
verified: repairEntry ? repairEntry.verified : false
|
||||||
|
};
|
||||||
|
}) : []
|
||||||
},
|
},
|
||||||
|
|
||||||
repairs_applied: repairResult
|
repairs_applied: repairResult
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function checkYamlSyntax(filePath) {
|
||||||
const content = fs.readFileSync(filePath, 'utf8');
|
const content = fs.readFileSync(filePath, 'utf8');
|
||||||
// Basic checks: not empty, has 'name:', has 'on:', has 'jobs:'
|
// Basic checks: not empty, has 'name:', has 'on:', has 'jobs:'
|
||||||
const hasName = /^name\s*:/m.test(content);
|
const hasName = /^name\s*:/m.test(content);
|
||||||
const hasOn = /^on\s*:/m.test(content) || /^on:/m.test(content) || /^"on"\s*:/m.test(content) || /^'on'\s*:/m.test(content);
|
const hasOn = /^on\s*:/m.test(content) || /^"on"\s*:/m.test(content) || /^'on'\s*:/m.test(content);
|
||||||
const hasJobs = /^jobs\s*:/m.test(content);
|
const hasJobs = /^jobs\s*:/m.test(content);
|
||||||
|
|
||||||
const issues = [];
|
const issues = [];
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ function notionRequest(apiPath, body) {
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
resolve({ statusCode: res.statusCode, body: data });
|
resolve({ statusCode: res.statusCode, body: data });
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Notion API ${res.statusCode}: ${data.substring(0, 200)}`));
|
reject(new Error(`Notion API ${res.statusCode}: ${data.length > 200 ? data.substring(0, 200) + '...' : data}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue