From c0cb29235055e4b25c961686310a0c3e9c64cc1d Mon Sep 17 00:00:00 2001 From: zhaolei <12153398@qq.com> Date: Thu, 29 Oct 2026 17:11:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E9=9D=B6=E5=9C=BA?= =?UTF-8?q?=E5=8F=AA=E5=B1=95=E7=A4=BA=20index.json=20=E7=99=BB=E8=AE=B0?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E6=9C=AC=20+=20=E6=B8=85=204=20=E4=B8=AA?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=B0=83=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: 控制台测试靶场页面样本数: 目录 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, 无 '未知' 和 '—' --- app/console.py | 16 +++++++--------- tests/samples/L4-005_hotreload.txt | 1 - tests/samples/L4-007_meta_rule.txt | 1 - tests/samples/L4-010_regex_pattern.txt | 1 - tests/samples/L4-012_size_condition.txt | 1 - 5 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 tests/samples/L4-005_hotreload.txt delete mode 100644 tests/samples/L4-007_meta_rule.txt delete mode 100644 tests/samples/L4-010_regex_pattern.txt delete mode 100644 tests/samples/L4-012_size_condition.txt diff --git a/app/console.py b/app/console.py index 8e1da55..5eba78c 100644 --- a/app/console.py +++ b/app/console.py @@ -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 diff --git a/tests/samples/L4-005_hotreload.txt b/tests/samples/L4-005_hotreload.txt deleted file mode 100644 index 00af789..0000000 --- a/tests/samples/L4-005_hotreload.txt +++ /dev/null @@ -1 +0,0 @@ -meshsafe-hot-reload-test-string present here \ No newline at end of file diff --git a/tests/samples/L4-007_meta_rule.txt b/tests/samples/L4-007_meta_rule.txt deleted file mode 100644 index f578307..0000000 --- a/tests/samples/L4-007_meta_rule.txt +++ /dev/null @@ -1 +0,0 @@ -trojan-metadata-test payload here \ No newline at end of file diff --git a/tests/samples/L4-010_regex_pattern.txt b/tests/samples/L4-010_regex_pattern.txt deleted file mode 100644 index 09f8c76..0000000 --- a/tests/samples/L4-010_regex_pattern.txt +++ /dev/null @@ -1 +0,0 @@ -powershell -enc ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx+/== \ No newline at end of file diff --git a/tests/samples/L4-012_size_condition.txt b/tests/samples/L4-012_size_condition.txt deleted file mode 100644 index 7abaf37..0000000 --- a/tests/samples/L4-012_size_condition.txt +++ /dev/null @@ -1 +0,0 @@ -size_condition_test_payload small file \ No newline at end of file