feat: 旧样本 L7 归类 + 中文规则标签

- rules/rule_labels.yaml: 64 条 rule_name → 中文标签映射
- console.py: 加载 rule_labels + layer_definitions 传给 template
- test_center.html: 期望规则 / 实际规则 全显示中文名(hover 保留英文原名)
- scripts/regen_v2.py: 全量扫描自动打 L7 标签 + case_id
- tests/samples/index.json: 168 条全有 case_id,层分布 L0=27 L1=25 L3=25 L4=15 L5=21 NEG=20 L7=35

前端效果: NC 反弹 Shell / UPX 加壳 / 压缩包路径穿越 / RWX 可写可执行节...
This commit is contained in:
2026-10-29 11:51:31 +08:00
parent f99452d553
commit da05c544e9
4 changed files with 591 additions and 617 deletions

View File

@@ -885,6 +885,25 @@ async def test_page(request: Request, current=Depends(require_login)):
samples_dir = Path(__file__).resolve().parent.parent / "tests" / "samples"
index_path = samples_dir / "index.json"
labels_path = Path(__file__).resolve().parent.parent / "rules" / "rule_labels.yaml"
# 加载规则中文标签
rule_labels: dict[str, str] = {}
layer_definitions: dict[str, str] = {}
try:
import yaml as _yaml
if labels_path.exists():
_lbl_raw = _yaml.safe_load(labels_path.read_text(encoding="utf-8")) or {}
# 映射 engine_rule_name → 中文标签
for k, v in _lbl_raw.items():
if isinstance(v, dict) and "label" in v:
rule_labels[k] = v["label"]
# 层定义
if index_path.exists():
_idx = json.loads(index_path.read_text(encoding="utf-8"))
layer_definitions = _idx.get("layer_definition", {})
except Exception: # noqa: BLE001
pass
rescan = request.query_params.get("rescan") == "1"
samples_list: list[Path] = []
@@ -1146,6 +1165,8 @@ async def test_page(request: Request, current=Depends(require_login)):
"policy_version": policy_version,
"last_run_at": last_run_at,
"rescan": rescan,
"rule_labels": rule_labels,
"layer_definitions": layer_definitions,
},
)