Render the compact summary table shown after a scan.
(results: Union[dict, List[dict], None], elapsed: Optional[timedelta] = None)
| 578 | |
| 579 | |
| 580 | def output(results: Union[dict, List[dict], None], elapsed: Optional[timedelta] = None) -> None: |
| 581 | """Render the compact summary table shown after a scan.""" |
| 582 | if not results: |
| 583 | err_console.print("[yellow]No results to display.[/yellow]") |
| 584 | return |
| 585 | |
| 586 | items = [results] if isinstance(results, dict) else results |
| 587 | notes: List[str] = [] |
| 588 | |
| 589 | table = _new_table(box_style=box.SIMPLE_HEAVY, show_header=True, header_style="bold cyan") |
| 590 | table.add_column("Domain", style="cyan", width=SUMMARY_DOMAIN_WIDTH, min_width=SUMMARY_DOMAIN_WIDTH, max_width=SUMMARY_DOMAIN_WIDTH, no_wrap=True, overflow="ellipsis") |
| 591 | table.add_column( |
| 592 | "IP", |
| 593 | style="white", |
| 594 | width=SUMMARY_IP_WIDTH, |
| 595 | min_width=SUMMARY_IP_WIDTH, |
| 596 | max_width=SUMMARY_IP_WIDTH, |
| 597 | no_wrap=False, |
| 598 | overflow="fold", |
| 599 | ) |
| 600 | table.add_column("HTTP", justify="center", width=SUMMARY_CODE_WIDTH, min_width=SUMMARY_CODE_WIDTH, max_width=SUMMARY_CODE_WIDTH, no_wrap=True) |
| 601 | table.add_column("HTTPS", justify="center", width=SUMMARY_CODE_WIDTH, min_width=SUMMARY_CODE_WIDTH, max_width=SUMMARY_CODE_WIDTH, no_wrap=True) |
| 602 | table.add_column("Cert", justify="center", width=SUMMARY_CERT_WIDTH, min_width=SUMMARY_CERT_WIDTH, max_width=SUMMARY_CERT_WIDTH, no_wrap=True) |
| 603 | table.add_column("Expiry", justify="center", width=SUMMARY_EXPIRY_WIDTH, min_width=SUMMARY_EXPIRY_WIDTH, max_width=SUMMARY_EXPIRY_WIDTH, no_wrap=True) |
| 604 | table.add_column("TLS", overflow="fold", no_wrap=False) |
| 605 | table.add_column("Status", justify="center", width=SUMMARY_STATUS_WIDTH, min_width=SUMMARY_STATUS_WIDTH, max_width=SUMMARY_STATUS_WIDTH, no_wrap=True) |
| 606 | |
| 607 | for item in items: |
| 608 | for note in (item.get("scan_notes") or []): |
| 609 | if isinstance(note, str) and note and note not in notes: |
| 610 | notes.append(note) |
| 611 | |
| 612 | ips = _format_ips_for_cell(item.get("ip") or []) |
| 613 | |
| 614 | http = item.get("http") or [None, None, None, None] |
| 615 | https = item.get("https") or [None, None, None, None] |
| 616 | cert = item.get("cert") or [None, None, None, None] |
| 617 | |
| 618 | http_code = "-" if len(http) < 1 or http[0] is None else str(http[0]) |
| 619 | https_code = "-" if len(https) < 1 or https[0] is None else str(https[0]) |
| 620 | |
| 621 | cert_ok = cert[0] |
| 622 | cert_text = "-" |
| 623 | if cert_ok is True: |
| 624 | cert_text = "[green]valid[/green]" |
| 625 | elif cert_ok is False: |
| 626 | cert_text = "[red]invalid[/red]" |
| 627 | |
| 628 | status = _status_text(http, https, cert) |
| 629 | takeover = item.get("takeover") or {} |
| 630 | takeover_status = str(takeover.get("status") or "").strip().lower() |
| 631 | if takeover_status in {"possible", "likely"} and status == "ok": |
| 632 | status = "warning" |
| 633 | |
| 634 | if status == "ok": |
| 635 | status_text = "[green]ok[/green]" |
| 636 | elif status == "warning": |
| 637 | status_text = "[yellow]warning[/yellow]" |
no test coverage detected