feat: 使用rglob扫描
This commit is contained in:
parent
62b77812af
commit
d1ac4594e4
@ -10,6 +10,7 @@ from .utils import *
|
|||||||
import sys
|
import sys
|
||||||
from colorama import init, Fore, Style
|
from colorama import init, Fore, Style
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
PYCDC_FLAG = True
|
PYCDC_FLAG = True
|
||||||
PYCDC_ADDR_FLAG = True
|
PYCDC_ADDR_FLAG = True
|
||||||
@ -362,19 +363,18 @@ def process_path(
|
|||||||
):
|
):
|
||||||
results = {"high": [], "medium": [], "low": [], "none": []}
|
results = {"high": [], "medium": [], "low": [], "none": []}
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
# 获取所有文件
|
# 使用rglob获取所有文件
|
||||||
all_files = []
|
all_files = [
|
||||||
for root, dirs, files in os.walk(path):
|
file_path
|
||||||
for file in files:
|
for file_path in Path(path).rglob("*")
|
||||||
file_extension = os.path.splitext(file)[1]
|
if file_path.suffix in SUPPORTED_EXTENSIONS
|
||||||
if file_extension in SUPPORTED_EXTENSIONS:
|
]
|
||||||
file_path = os.path.join(root, file)
|
|
||||||
all_files.append(file_path)
|
|
||||||
# 扫描动画
|
# 扫描动画
|
||||||
for file_path in tqdm(all_files, desc="Scanning files", unit="file"):
|
for file_path in tqdm(all_files, desc="Scanning files", unit="file"):
|
||||||
file_extension = os.path.splitext(file_path)[1]
|
file_extension = file_path.suffix
|
||||||
file_results = checkModeAndDetect(
|
file_results = checkModeAndDetect(
|
||||||
mode, file_path, file_extension, pycdc_addr
|
mode, str(file_path), file_extension, pycdc_addr
|
||||||
)
|
)
|
||||||
if file_results is not None:
|
if file_results is not None:
|
||||||
for key in file_results:
|
for key in file_results:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user