Fix capitalization issues and handle cases where the answer is "none".
Build and Push CodeReview / build (push) Waiting to run Details

This commit is contained in:
vinland100 2026-01-12 14:04:12 +08:00
parent a98e3e531b
commit b373692577
2 changed files with 21 additions and 3 deletions

View File

@ -1352,7 +1352,17 @@ async def _save_findings(
def _calculate_security_score(findings: List[Dict]) -> float: def _calculate_security_score(findings: List[Dict]) -> float:
"""计算安全评分""" """计算安全评分
评分逻辑 100 分开始根据漏洞严重程度扣分
- Critical: -25
- High: -15
- Medium: -8
- Low: -3
- Info: -1
🔥 FIX: 确保 severity 转换为小写后再匹配 deductions 字典
"""
if not findings: if not findings:
return 100.0 return 100.0
@ -1368,8 +1378,11 @@ def _calculate_security_score(findings: List[Dict]) -> float:
total_deduction = 0 total_deduction = 0
for f in findings: for f in findings:
if isinstance(f, dict): if isinstance(f, dict):
sev = f.get("severity", "low") # 🔥 FIX: 将 severity 转换为小写,确保能正确匹配 deductions 字典
total_deduction += deductions.get(sev, 3) raw_sev = f.get("severity") or f.get("risk") or "low"
sev = str(raw_sev).lower().strip()
deduction = deductions.get(sev, 3) # 默认使用 low 的扣分
total_deduction += deduction
score = max(0, 100 - total_deduction) score = max(0, 100 - total_deduction)
return float(score) return float(score)

View File

@ -913,6 +913,11 @@ Action Input: {{"参数": "值"}}
# Normalize the finding first # Normalize the finding first
normalized_new = self._normalize_finding(new_f) normalized_new = self._normalize_finding(new_f)
# 🔥 FIX: Skip if normalization returned None (e.g., file path validation failed)
if normalized_new is None:
logger.debug(f"[Orchestrator] Skipping invalid finding: {new_f.get('title', 'N/A')[:50]}")
continue
# Create fingerprint for deduplication (file + description similarity) # Create fingerprint for deduplication (file + description similarity)
new_file = normalized_new.get("file_path", "").lower().strip() new_file = normalized_new.get("file_path", "").lower().strip()
new_desc = (normalized_new.get("description", "") or "").lower()[:100] new_desc = (normalized_new.get("description", "") or "").lower()[:100]