(text: str)
| 22 | |
| 23 | |
| 24 | def parse_vulnerabilities(text: str) -> list[dict[str, Any]]: |
| 25 | vulns: list[dict[str, Any]] = [] |
| 26 | raw_text = strip_ansi(text) |
| 27 | entries = re.split(r"(?=\[Vuln: )", raw_text) |
| 28 | |
| 29 | for entry in entries: |
| 30 | entry = entry.strip() |
| 31 | if not entry.startswith("[Vuln: "): |
| 32 | continue |
| 33 | |
| 34 | vuln_info: dict[str, Any] = {} |
| 35 | for line in entry.splitlines(): |
| 36 | line = line.strip() |
| 37 | if not line: |
| 38 | continue |
| 39 | |
| 40 | vuln_match = re.search(r"\[Vuln: (.*?)\]", line) |
| 41 | if vuln_match: |
| 42 | vuln_info["vuln"] = vuln_match.group(1) |
| 43 | continue |
| 44 | |
| 45 | map_match = re.search(r"(\w+)\s+map\[\"field\":\"(.*?)\"\s+\"value\":\"(.*?)\"\]", line) |
| 46 | if map_match: |
| 47 | vuln_info[map_match.group(1).lower()] = { |
| 48 | "field": map_match.group(2), |
| 49 | "value": map_match.group(3), |
| 50 | } |
| 51 | continue |
| 52 | |
| 53 | payload_match = re.search(r"Payload\s+\"(.*?)\"", line) |
| 54 | if payload_match: |
| 55 | vuln_info["payload"] = payload_match.group(1) |
| 56 | continue |
| 57 | |
| 58 | links_match = re.search(r"Links\s+\[(.*?)\]", line) |
| 59 | if links_match: |
| 60 | links = links_match.group(1).split(", ") |
| 61 | vuln_info["links"] = [link.strip().strip('"') for link in links if link.strip()] |
| 62 | continue |
| 63 | |
| 64 | field_match = re.search(r"(\w+)\s+\"(.*?)\"", line) |
| 65 | if field_match: |
| 66 | vuln_info[field_match.group(1).lower()] = field_match.group(2) |
| 67 | continue |
| 68 | |
| 69 | level_match = re.search(r"level\s+\"(.*?)\"\s*", line) |
| 70 | if level_match: |
| 71 | vuln_info["level"] = level_match.group(1) |
| 72 | |
| 73 | if {"vuln", "target", "vulntype"}.issubset(vuln_info): |
| 74 | vulns.append(vuln_info) |
| 75 | |
| 76 | return vulns |
| 77 | |
| 78 | |
| 79 | def success_markers(target: str, benchmark_name: str = "") -> list[str]: |
no test coverage detected