Correlate and deduplicate findings across scans.
| 41 | |
| 42 | class FindingCorrelator: |
| 43 | """Correlate and deduplicate findings across scans.""" |
| 44 | |
| 45 | # Severity weights for risk scoring |
| 46 | SEVERITY_WEIGHTS = { |
| 47 | Severity.CRITICAL: 10.0, |
| 48 | Severity.HIGH: 7.0, |
| 49 | Severity.MEDIUM: 4.0, |
| 50 | Severity.LOW: 2.0, |
| 51 | Severity.INFO: 0.5, |
| 52 | } |
| 53 | |
| 54 | # Attack chain patterns |
| 55 | ATTACK_PATTERNS = { |
| 56 | "web_compromise": { |
| 57 | "name": "Web Application Compromise", |
| 58 | "description": "Path from reconnaissance to potential system compromise via web vulnerabilities", |
| 59 | "stages": [ |
| 60 | ["osint", "tech_detect"], # Recon |
| 61 | ["webscanner.crawler", "webscanner.dirbrute"], # Discovery |
| 62 | ["webscanner.xss", "webscanner.sqli"], # Exploitation |
| 63 | ], |
| 64 | "mitre": ["TA0043", "TA0001", "TA0002"], # Recon, Initial Access, Execution |
| 65 | }, |
| 66 | "exposed_services": { |
| 67 | "name": "Exposed Service Attack", |
| 68 | "description": "Exposed services leading to potential unauthorized access", |
| 69 | "stages": [ |
| 70 | ["osint.port_scan", "osint.shodan"], # Service discovery |
| 71 | ["exploit.searchsploit", "exploit.metasploit"], # Exploit research |
| 72 | ], |
| 73 | "mitre": ["TA0043", "TA0001"], |
| 74 | }, |
| 75 | "credential_exposure": { |
| 76 | "name": "Credential Exposure Risk", |
| 77 | "description": "Paths that could lead to credential theft", |
| 78 | "stages": [ |
| 79 | ["osint.email_harvest"], # Target identification |
| 80 | ["webscanner.xss", "phishing"], # Credential capture |
| 81 | ], |
| 82 | "mitre": ["TA0043", "TA0006"], # Recon, Credential Access |
| 83 | }, |
| 84 | } |
| 85 | |
| 86 | def __init__(self): |
| 87 | self.logger = get_logger("ai.correlator") |
| 88 | |
| 89 | def correlate(self, scan_results: list[ScanResult]) -> CorrelationReport: |
| 90 | """Correlate findings across multiple scan results. |
| 91 | |
| 92 | Args: |
| 93 | scan_results: List of scan results to correlate |
| 94 | |
| 95 | Returns: |
| 96 | CorrelationReport with analysis |
| 97 | """ |
| 98 | if not scan_results: |
| 99 | return CorrelationReport( |
| 100 | target="", |
no outgoing calls
no test coverage detected