fix: 测试靶场只展示 index.json 登记的样本 + 清 4 个临时调试文件
问题:
控制台测试靶场页面样本数: 目录 172 个 vs index.json 168 条
差了 4 个是 YARA 调试时创建的临时文件 (L4-005_hotreload.txt 等)
这些临时文件没进 index.json → meta_map 查不到 → category='未知' case_id='—'
修复:
1) console.py test_center_page:
samples_list 从遍历目录 (iterdir) 改成只从 index.json 来
每个样本必须 index.json 有登记 + 磁盘上确实存在
以后目录里即使有临时文件也不会混入靶场列表
2) 清理 4 个重复临时调试文件:
L4-005_hotreload.txt → index.json 正式: L4-005_005_sample.txt
L4-007_meta_rule.txt → index.json 正式: L4-007_meta_rule_match.txt
L4-010_regex_pattern.txt → index.json 正式: L4-010_010_sample.txt
L4-012_size_condition.txt → index.json 正式: L4-012_size_condition.bin
控制台页面现在: 168 条, 全部有 case_id 和 category, 无 '未知' 和 '—'
This commit is contained in:
@@ -960,15 +960,13 @@ async def test_page(request: Request, current=Depends(require_login)):
|
||||
index = json.loads(index_path.read_text(encoding="utf-8"))
|
||||
meta_map = {s["filename"]: s for s in index.get("samples", [])}
|
||||
|
||||
# 收集所有样本文件
|
||||
for fpath in sorted(samples_dir.iterdir()):
|
||||
if not fpath.is_file():
|
||||
continue
|
||||
if fpath.name == "index.json" or fpath.name.startswith("_"):
|
||||
continue
|
||||
if fpath.suffix == ".json" and fpath.name.startswith("_scan_results"):
|
||||
continue
|
||||
samples_list.append(fpath)
|
||||
# ★ 只展示 index.json 里登记的样本(不遍历目录,避免临时/调试文件混入)
|
||||
# 每个样本必须: index.json 有登记 + 磁盘上确实存在
|
||||
for s in index.get("samples", []):
|
||||
fname = s["filename"]
|
||||
fpath = samples_dir / fname
|
||||
if fpath.is_file():
|
||||
samples_list.append(fpath)
|
||||
|
||||
results: list[dict] = []
|
||||
pass_cnt = fail_cnt = 0
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
meshsafe-hot-reload-test-string present here
|
||||
@@ -1 +0,0 @@
|
||||
trojan-metadata-test payload here
|
||||
@@ -1 +0,0 @@
|
||||
powershell -enc ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx+/==
|
||||
@@ -1 +0,0 @@
|
||||
size_condition_test_payload small file
|
||||
Reference in New Issue
Block a user