Improve parse_results logic for better code clarity

Co-authored-by: GilbertKrantz <90319182+GilbertKrantz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-05 18:20:44 +00:00
parent 0d22b027f4
commit c60fa2be42

View File

@ -119,16 +119,18 @@ class SQLMapCLI:
if "sqlmap identified the following injection point" in output: if "sqlmap identified the following injection point" in output:
# Extract injection details # Extract injection details
lines = output.split('\n') lines = output.split('\n')
param = None # Initialize to avoid undefined reference current_param = 'Unknown' # Default parameter name
for i, line in enumerate(lines): for i, line in enumerate(lines):
if "Parameter:" in line: if "Parameter:" in line:
param = line.split("Parameter:")[1].strip() current_param = line.split("Parameter:")[1].strip()
if "Type:" in line: elif "Type:" in line:
vuln_type = line.split("Type:")[1].strip() vuln_type = line.split("Type:")[1].strip()
# Check if next line contains the title
if i + 1 < len(lines) and "Title:" in lines[i + 1]: if i + 1 < len(lines) and "Title:" in lines[i + 1]:
title = lines[i + 1].split("Title:")[1].strip() title = lines[i + 1].split("Title:")[1].strip()
vulns.append({ vulns.append({
'parameter': param if param is not None else 'Unknown', 'parameter': current_param,
'type': vuln_type, 'type': vuln_type,
'title': title 'title': title
}) })