Spaces:
Sleeping
Sleeping
Update analyzer.py
Browse files1234119 unmodified lines12412512612712812913013113213313413513685 unmodified lines222223224225# analyzer.pyimport osimport refrom dataclasses import dataclass, field119 unmodified linesclass Exporter:def __init__(self, report: ReportData, output_dir: str, base_name: str):self.report = reportself.output_dir = output_dirself.base_name = base_nameself.icons = {"network": "🌐", "execution": "⚡", "dom": "💉","storage": "🗄️", "sensitive": "📋", "dynamic": "🔗"}def write_markdown(self):path = os.path.join(self.output_dir, f"{self.base_name}.report.md")85 unmodified lines])with open(path, 'w', encoding='utf-8') as f:f.write("\n".join(lines))123119 unmodified lines12312412512612712812913013113213313413513613713813914014114214314414514614714814915015185 unmodified lines237238239240import osimport refrom dataclasses import dataclass, field119 unmodified linesclass Exporter:def __init__(self, report: ReportData, output_dir: str, base_name: str):self.output_dir = output_dirself.base_name = base_nameself.icons = {"network": "🌐", "execution": "⚡", "dom": "💉","storage": "🗄️", "sensitive": "📋", "dynamic": "🔗"}# --- 新增:雜訊過濾機制 ---cleaned_functions = {}for name, func in report.functions.items():is_anonymous = name.startswith("<anonymous")has_effects = len(func.side_effects) > 0has_calls = len(func.calls) > 0# 條件:如果是匿名函式,且「沒有副作用」也「沒有呼叫其他函式」,就當作雜訊丟棄if is_anonymous and not has_effects and not has_calls:continuecleaned_functions[name] = func# 將過濾後的乾淨清單存回 reportreport.functions = cleaned_functionsself.report = reportdef write_markdown(self):path = os.path.join(self.output_dir, f"{self.base_name}.report.md")85 unmodified lines])with open(path, 'w', encoding='utf-8') as f:f.write("\n".join(lines))
analyzer.py+18-3