feature/rglob #29
@ -9,6 +9,7 @@ from .pyc_detection import disassemble_pyc
|
|||||||
from .utils import *
|
from .utils import *
|
||||||
import sys
|
import sys
|
||||||
from colorama import init, Fore, Style
|
from colorama import init, Fore, Style
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
PYCDC_FLAG = True
|
PYCDC_FLAG = True
|
||||||
PYCDC_ADDR_FLAG = True
|
PYCDC_ADDR_FLAG = True
|
||||||
@ -361,27 +362,40 @@ def process_path(
|
|||||||
):
|
):
|
||||||
results = {"high": [], "medium": [], "low": [], "none": []}
|
results = {"high": [], "medium": [], "low": [], "none": []}
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
# 获取所有文件
|
||||||
|
all_files = []
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
file_extension = os.path.splitext(file)[1]
|
file_extension = os.path.splitext(file)[1]
|
||||||
if file_extension in SUPPORTED_EXTENSIONS:
|
if file_extension in SUPPORTED_EXTENSIONS:
|
||||||
file_path = os.path.join(root, file)
|
file_path = os.path.join(root, file)
|
||||||
file_results = checkModeAndDetect(
|
all_files.append(file_path)
|
||||||
mode, file_path, file_extension, pycdc_addr
|
# 扫描动画
|
||||||
)
|
for file_path in tqdm(all_files, desc="Scanning files", unit="file"):
|
||||||
if file_results is not None:
|
file_extension = os.path.splitext(file_path)[1]
|
||||||
for key in file_results:
|
file_results = checkModeAndDetect(
|
||||||
if key != "none": # Exclude 'none' risk level
|
mode, file_path, file_extension, pycdc_addr
|
||||||
results[key].extend(
|
)
|
||||||
[
|
if file_results is not None:
|
||||||
(f"{file_path}: Line {line_num}", line)
|
for key in file_results:
|
||||||
for line_num, line in file_results[key]
|
if key != "none": # Exclude 'none' risk level
|
||||||
]
|
results[key].extend(
|
||||||
)
|
[
|
||||||
|
(f"{file_path}: Line {line_num}", line)
|
||||||
|
for line_num, line in file_results[key]
|
||||||
|
]
|
||||||
|
)
|
||||||
elif os.path.isfile(path):
|
elif os.path.isfile(path):
|
||||||
|
file_results = ""
|
||||||
file_extension = os.path.splitext(path)[1]
|
file_extension = os.path.splitext(path)[1]
|
||||||
if file_extension in SUPPORTED_EXTENSIONS:
|
if file_extension in SUPPORTED_EXTENSIONS:
|
||||||
file_results = checkModeAndDetect(mode, path, file_extension, pycdc_addr)
|
# 扫描动画
|
||||||
|
with tqdm(total=100, desc="Scanning file", unit="%", ncols=100) as pbar:
|
||||||
|
for i in range(10):
|
||||||
|
file_results = checkModeAndDetect(
|
||||||
|
mode, path, file_extension, pycdc_addr
|
||||||
|
)
|
||||||
|
pbar.update(10) # Update the progress bar by 10%
|
||||||
if file_results is not None:
|
if file_results is not None:
|
||||||
for key in file_results:
|
for key in file_results:
|
||||||
if key != "none": # Exclude 'none' risk level
|
if key != "none": # Exclude 'none' risk level
|
||||||
|
Loading…
x
Reference in New Issue
Block a user