Expand intel coverage and refresh monitoring
这个提交包含在:
@@ -191,7 +191,38 @@ def _clear_json_dir(path: Path) -> None:
|
||||
file_path.unlink()
|
||||
|
||||
|
||||
def render_system_scaffolding(source_map: Dict[str, Any], advisories: List[AdvisoryRecord]) -> None:
|
||||
def _sync_json_dir(path: Path, payloads: Dict[str, Any]) -> None:
|
||||
ensure_dir(path)
|
||||
desired = set(payloads.keys())
|
||||
for file_path in path.glob("*.json"):
|
||||
if file_path.name not in desired:
|
||||
file_path.unlink()
|
||||
for filename, payload in payloads.items():
|
||||
write_json(path / filename, payload)
|
||||
|
||||
|
||||
def _sync_selected_json_dir(path: Path, payloads: Dict[str, Any], selected_system_ids: set[str], *, systems_dir: bool = False) -> None:
|
||||
ensure_dir(path)
|
||||
desired = set(payloads.keys())
|
||||
for file_path in path.glob("*.json"):
|
||||
if systems_dir:
|
||||
system_id = file_path.stem
|
||||
if system_id not in selected_system_ids:
|
||||
continue
|
||||
else:
|
||||
if not any(file_path.name.startswith(f"{system_id}--") for system_id in selected_system_ids):
|
||||
continue
|
||||
if file_path.name not in desired:
|
||||
file_path.unlink()
|
||||
for filename, payload in payloads.items():
|
||||
write_json(path / filename, payload)
|
||||
|
||||
|
||||
def render_system_scaffolding(
|
||||
source_map: Dict[str, Any],
|
||||
advisories: List[AdvisoryRecord],
|
||||
selected_system_ids: set[str] | None = None,
|
||||
) -> None:
|
||||
run_map = latest_runs_by_advisory()
|
||||
grouped: Dict[str, List[AdvisoryRecord]] = defaultdict(list)
|
||||
for advisory in advisories:
|
||||
@@ -200,6 +231,10 @@ def render_system_scaffolding(source_map: Dict[str, Any], advisories: List[Advis
|
||||
groups: Dict[str, List[Dict[str, Any]]] = defaultdict(list)
|
||||
for system in source_map["systems"]:
|
||||
groups[_group_name(system["output_dir"])].append(system)
|
||||
target_systems = source_map["systems"]
|
||||
if selected_system_ids:
|
||||
target_systems = [system for system in source_map["systems"] if system["system_id"] in selected_system_ids]
|
||||
for system in target_systems:
|
||||
system_dir = FRAMEWORK_ROOT / _group_name(system["output_dir"]) / system["system_id"]
|
||||
ensure_dir(system_dir / "cases")
|
||||
|
||||
@@ -311,9 +346,11 @@ def render_system_scaffolding(source_map: Dict[str, Any], advisories: List[Advis
|
||||
write_text(FRAMEWORK_ROOT / "README.md", "\n".join(root_lines))
|
||||
|
||||
|
||||
def render_case_pages(advisories: List[AdvisoryRecord]) -> None:
|
||||
def render_case_pages(advisories: List[AdvisoryRecord], selected_system_ids: set[str] | None = None) -> None:
|
||||
run_map = latest_runs_by_advisory()
|
||||
for item in advisories:
|
||||
if selected_system_ids and item.system_id not in selected_system_ids:
|
||||
continue
|
||||
if not item.render_markdown or not item.case_path:
|
||||
continue
|
||||
merged = _merged_item(item, run_map)
|
||||
@@ -410,28 +447,36 @@ def render_case_pages(advisories: List[AdvisoryRecord]) -> None:
|
||||
write_text(ROOT / item.case_path, "\n".join(lines))
|
||||
|
||||
|
||||
def render_registry(source_map: Dict[str, Any], advisories: List[AdvisoryRecord], triage: List[Dict[str, Any]]) -> None:
|
||||
_clear_json_dir(REGISTRY_ROOT / "advisories")
|
||||
_clear_json_dir(REGISTRY_ROOT / "systems")
|
||||
_clear_json_dir(TRIAGE_DIR)
|
||||
|
||||
def render_registry(
|
||||
source_map: Dict[str, Any],
|
||||
advisories: List[AdvisoryRecord],
|
||||
triage: List[Dict[str, Any]],
|
||||
selected_system_ids: set[str] | None = None,
|
||||
) -> None:
|
||||
run_map = latest_runs_by_advisory()
|
||||
grouped: Dict[str, List[AdvisoryRecord]] = defaultdict(list)
|
||||
advisory_payloads: Dict[str, Dict[str, Any]] = {}
|
||||
for advisory in advisories:
|
||||
write_json(REGISTRY_ROOT / "advisories" / f"{advisory.canonical_id}.json", _merged_item(advisory, run_map))
|
||||
if selected_system_ids and advisory.system_id not in selected_system_ids:
|
||||
continue
|
||||
advisory_payloads[f"{advisory.canonical_id}.json"] = _merged_item(advisory, run_map)
|
||||
grouped[advisory.system_id].append(advisory)
|
||||
|
||||
triage_by_system: Dict[str, List[Dict[str, Any]]] = defaultdict(list)
|
||||
triage_payloads: Dict[str, Dict[str, Any]] = {}
|
||||
for item in triage:
|
||||
if selected_system_ids and item["system_id"] not in selected_system_ids:
|
||||
continue
|
||||
triage_by_system[item["system_id"]].append(item)
|
||||
write_json(TRIAGE_DIR / f"{item['canonical_id']}.json", item)
|
||||
triage_payloads[f"{item['canonical_id']}.json"] = item
|
||||
|
||||
system_payloads: Dict[str, Dict[str, Any]] = {}
|
||||
for system in source_map["systems"]:
|
||||
system_id = system["system_id"]
|
||||
items = grouped.get(system_id, [])
|
||||
merged_items = [_merged_item(item, run_map) for item in items]
|
||||
counts = _status_counts(merged_items)
|
||||
payload = {
|
||||
system_payloads[f"{system_id}.json"] = {
|
||||
"system_id": system_id,
|
||||
"display_name": system["display_name"],
|
||||
"category": system["category"],
|
||||
@@ -448,7 +493,14 @@ def render_registry(source_map: Dict[str, Any], advisories: List[AdvisoryRecord]
|
||||
"manual_count": counts["manual"],
|
||||
"items": [item.canonical_id for item in sorted(items, key=lambda item: item.published_at or "", reverse=True)],
|
||||
}
|
||||
write_json(SYSTEMS_DIR / f"{system_id}.json", payload)
|
||||
if selected_system_ids:
|
||||
_sync_selected_json_dir(REGISTRY_ROOT / "advisories", advisory_payloads, selected_system_ids)
|
||||
_sync_selected_json_dir(TRIAGE_DIR, triage_payloads, selected_system_ids)
|
||||
_sync_selected_json_dir(REGISTRY_ROOT / "systems", system_payloads, selected_system_ids, systems_dir=True)
|
||||
return
|
||||
_sync_json_dir(REGISTRY_ROOT / "advisories", advisory_payloads)
|
||||
_sync_json_dir(TRIAGE_DIR, triage_payloads)
|
||||
_sync_json_dir(REGISTRY_ROOT / "systems", system_payloads)
|
||||
|
||||
|
||||
def render_generated(
|
||||
@@ -525,7 +577,10 @@ def render_generated(
|
||||
"failures": failures,
|
||||
},
|
||||
)
|
||||
render_lab_dashboard()
|
||||
render_lab_dashboard(
|
||||
advisory_records=[item.to_dict() for item in advisories],
|
||||
source_map_data=source_map,
|
||||
)
|
||||
|
||||
|
||||
def render_secure_code(source_map: Dict[str, Any]) -> None:
|
||||
|
||||
在新工单中引用
屏蔽一个用户