feat: 数据流架构审计-22个脚本自拉API违规标记
This commit is contained in:
@@ -136,13 +136,29 @@ function toggleFt(g) {
|
||||
});
|
||||
}
|
||||
|
||||
function renderDataFlow(entities, jsonFiles) {
|
||||
function renderDataFlow(entities, jsonFiles, architecture) {
|
||||
// 只显示有写入方或读取方的实体
|
||||
const filtered = entities.filter(e => (e.writers||[]).length > 0 || (e.readers||[]).length > 0);
|
||||
// 只显示有读写关系的json
|
||||
const jf = jsonFiles.filter(j => (j.readers||[]).length > 0);
|
||||
|
||||
let html = '<div style="margin-bottom:10px;color:#8b949e;font-size:13px">';
|
||||
|
||||
// 架构违规告警
|
||||
const violations = (architecture||{}).price_api_violations || [];
|
||||
if (violations.length > 0) {
|
||||
const scripts = [...new Set(violations.map(v => v.script))];
|
||||
html += `<div style="background:#3d1c02;border:1px solid #d29922;border-radius:6px;padding:10px;margin-bottom:12px">`;
|
||||
html += `<div style="font-weight:bold;color:#d29922;margin-bottom:4px">⚠️ 架构违规: ${violations.length}处, ${scripts.length}个脚本自拉API不走live_prices</div>`;
|
||||
html += `<div style="font-size:11px;color:#8b949e;margin-bottom:6px">预期: price_monitor→live_prices→其他脚本读。以下脚本直接调腾讯API:</div>`;
|
||||
html += `<div style="font-size:11px">`;
|
||||
scripts.forEach(s => {
|
||||
const lines = violations.filter(v => v.script === s).map(v => `L${v.line}`).join(',');
|
||||
html += `<span class="cron-tag" style="border-color:#d29922;color:#d29922;margin-right:4px;margin-bottom:3px;display:inline-block">${s} (${lines})</span>`;
|
||||
});
|
||||
html += `</div></div>`;
|
||||
}
|
||||
|
||||
html += `显示 ${filtered.length} 个数据表 + ${jf.length} 个JSON文件的读写流向。绿色→写入,蓝色→读取。</div>`;
|
||||
|
||||
// 按写入方数量排序,最活跃的排前面
|
||||
@@ -239,7 +255,8 @@ function loadData() {
|
||||
`<span>数据表: ${d.entities.length} | ` +
|
||||
`<span style="color:#f85149">孤立${d.entities.filter(e=>e.flow_status==='orphan').length}</span> ` +
|
||||
`<span style="color:#d29922">写无读${d.entities.filter(e=>e.flow_status==='write_only').length}</span> ` +
|
||||
`<span style="color:#58a6ff">读无写${d.entities.filter(e=>e.flow_status==='read_only').length}</span></span>`;
|
||||
`<span style="color:#58a6ff">读无写${d.entities.filter(e=>e.flow_status==='read_only').length}</span>` +
|
||||
`<span style="color:#d29922;margin-left:8px">架构⚠️${(d.architecture||{}).violation_count||0}</span></span>`;
|
||||
|
||||
// Tab 0: 功能树
|
||||
document.getElementById('panel0').innerHTML = renderFeatureTree(d.feature_tree);
|
||||
@@ -269,7 +286,7 @@ function loadData() {
|
||||
document.getElementById('panel2').innerHTML = h2;
|
||||
|
||||
// Tab 3: 数据流
|
||||
document.getElementById('panel3').innerHTML = renderDataFlow(d.entities, d.json_files||[]);
|
||||
document.getElementById('panel3').innerHTML = renderDataFlow(d.entities, d.json_files||[], d.architecture||{});
|
||||
})
|
||||
.catch(e => document.getElementById('summary').innerHTML = '❌ 加载失败: ' + e.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user