(title, entries, limit=25)
| 6587 | shared_data.vulnerable_host_count = len(vulnerable_hosts) |
| 6588 | logger.debug(f"Updated vulnerable host count: {old_host_count} -> {shared_data.vulnerable_host_count}") |
| 6589 | |
| 6590 | # SQLite is the primary source of truth - CSV livestatus file is deprecated |
| 6591 | logger.debug(f"Synchronized vulnerability count: {vuln_count}") |
| 6592 | return vuln_count |
| 6593 | |
| 6594 | except Exception as e: |
| 6595 | logger.error(f"Error synchronizing vulnerability count: {e}") |
| 6596 | return safe_int(shared_data.vulnnbr) |
| 6597 | |
| 6598 | |
| 6599 | def sync_all_counts(): |
| 6600 | """Synchronize all counts (targets, ports, vulnerabilities, credentials) across data sources. |
| 6601 | |
| 6602 | This function reads from SQLite database as the single source of truth and applies the |
| 6603 | 30-ping failure rule to determine which hosts are considered active (alive vs degraded). |
| 6604 | """ |
| 6605 | global last_sync_time, network_scan_cache |
| 6606 | |
| 6607 | with sync_lock: |
| 6608 | start_time = time.time() |
| 6609 | try: |
| 6610 | logger.debug("Starting sync_all_counts()") |
| 6611 | |
| 6612 | # Sync vulnerability count |
| 6613 | sync_vulnerability_count() |
| 6614 | |
| 6615 | # ============================================================================== |
| 6616 | # PRIMARY DATA SOURCE: Read from SQLite database |
| 6617 | # ============================================================================== |
| 6618 | |
| 6619 | aggregated_targets = 0 |
| 6620 | aggregated_ports = 0 # Count total port instances across all hosts |
| 6621 | total_target_count = 0 |
| 6622 | inactive_target_count = 0 |
| 6623 | current_snapshot = {} |
| 6624 | discovered_macs = set() |
| 6625 | port_debug_info = [] # Track which hosts contribute to port count |
no test coverage detected