Display scan result in a nice format.
(result)
| 174 | |
| 175 | |
| 176 | def display_result(result): |
| 177 | """Display scan result in a nice format.""" |
| 178 | if not result.success: |
| 179 | console.print("[red]Scan failed with errors:[/red]") |
| 180 | for error in result.errors: |
| 181 | console.print(f" - {error}") |
| 182 | return |
| 183 | |
| 184 | # Show findings |
| 185 | if result.findings: |
| 186 | for finding in result.findings: |
| 187 | severity_colors = { |
| 188 | "critical": "red bold", |
| 189 | "high": "red", |
| 190 | "medium": "yellow", |
| 191 | "low": "blue", |
| 192 | "info": "green", |
| 193 | } |
| 194 | color = severity_colors.get(finding.severity.value, "white") |
| 195 | |
| 196 | panel = Panel( |
| 197 | f"[{color}]{finding.description}[/{color}]", |
| 198 | title=f"[{color}][{finding.severity.value.upper()}] {finding.title}[/{color}]", |
| 199 | border_style=color, |
| 200 | ) |
| 201 | console.print(panel) |
| 202 | |
| 203 | if finding.data: |
| 204 | for key, value in finding.data.items(): |
| 205 | if isinstance(value, list) and len(value) > 5: |
| 206 | console.print(f" {key}: {value[:5]} ... ({len(value)} total)") |
| 207 | else: |
| 208 | console.print(f" {key}: {value}") |
| 209 | console.print() |
| 210 | |
| 211 | # Duration |
| 212 | if result.duration_seconds: |
| 213 | console.print(f"[dim]Completed in {result.duration_seconds:.2f}s[/dim]") |
| 214 | |
| 215 | |
| 216 | # ============== OSINT Commands ============== |
no test coverage detected