-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean_fuzz_dir.py
More file actions
46 lines (38 loc) · 1.55 KB
/
clean_fuzz_dir.py
File metadata and controls
46 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import os
import shutil
import fire
def clean_project_dirs(root_dir="/home/jiayiguo/FuzzAug/fuzz/oss-fuzz/projects"):
"""
清理 oss-fuzz 项目目录下的 fuzz_inputs 和 tests-gen 文件夹
Args:
root_dir (str): 项目的根目录路径
"""
removed_files = 0
removed_dirs = 0
for project in os.listdir(root_dir):
project_path = os.path.join(root_dir, project)
if not os.path.isdir(project_path):
continue
# 删除 fuzz_inputs 文件夹
fuzz_inputs_path = os.path.join(project_path, "fuzz_inputs")
if os.path.isdir(fuzz_inputs_path):
shutil.rmtree(fuzz_inputs_path)
print(f"🗑️ Removed dir: {fuzz_inputs_path}")
removed_dirs += 1
# 删除 tests-gen 文件夹
tests_gen_path = os.path.join(project_path, "tests-gen")
if os.path.isdir(tests_gen_path):
shutil.rmtree(tests_gen_path)
print(f"🗑️ Removed dir: {tests_gen_path}")
removed_dirs += 1
# 如果需要删除 .inputs.py 文件,取消注释以下代码
# for fname in os.listdir(project_path):
# if fname.endswith(".inputs.py"):
# file_path = os.path.join(project_path, fname)
# os.remove(file_path)
# print(f"🗑️ Removed file: {file_path}")
# removed_files += 1
print(f"\n✅ Done. Removed {removed_files} files and {removed_dirs} directories.")
if __name__ == "__main__":
fire.Fire(clean_project_dirs)