mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-21 07:41:28 +02:00
Three findings from reading the feature against itself. Wrong description on 8 curated ports. describe() consulted _BY_NAME before the port's own entry, and _BY_NAME keeps one spec per name, so port 2376 reported "Docker API without TLS, equivalent to root on the host" — the opposite of what it is, and the kind of claim an operator acts on. The port's own entry now wins unless a banner named something the port does not imply, which keeps 2222/ssh resolving to SSH. Checked exhaustively: all 73 curated ports now return their own description and class. is:new was quadratic. service_has_baseline correlated per row on target_id alone, giving Postgres nothing selective to join on: 41.5M rows removed by join filter on a 6,400-service scan. Whether an earlier scan exists is a scan-level fact, so it is now a non-correlated EXISTS evaluated once as an InitPlan, and the API's page-level check shares the same predicate instead of carrying a second copy in raw SQL. On 24,897 subdomains x 6,440 services with a populated baseline: is:new 5.5s -> 0.72s, findings 4.6s -> 1.7s. The naabu replace left a hole. clear() committed, naabu then ran for minutes, and only then did the rows come back, so a scan in progress showed an empty port table for the length of the scan. Delete and insert now share one transaction inside upsert(). Also removed SERVICE_CLASS_HELP, PORT_PROFILE_KEYS and is_sensitive(), which had no consumers. Measured and rejected: replacing the hosts CTE with per-address GIN lookups (44.8s vs 191ms), and an ix_ports(target_id, ip, number) index (Postgres picks a hash anti-join either way, 5.4ms with and without). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BnC2xMMzV6WQnpDp5zcXoU