feat(asn): expose BGP prefix in AsnInfo and enrich_ip

Synthesize the covering CIDR at lookup time from the matched iptoasn
range using ipaddress.summarize_address_range. AsnInfo.prefix is
populated per-query; not persisted in the pickle cache.

enrich_ip now returns (asn, as_name, bgp_prefix, provider_name).
Profiler worker updated to unpack the 4-tuple and write bgp_prefix
into the attacker record dict.
This commit is contained in:
2026-05-21 16:07:57 -04:00
parent f160eccdae
commit e3d9908bed
5 changed files with 65 additions and 14 deletions

View File

@@ -356,7 +356,7 @@ def _build_record(
fingerprints = [b for b in bounties if b.get("bounty_type") == "fingerprint"]
credential_count = sum(1 for b in bounties if b.get("bounty_type") == "credential")
country_code, country_source = enrich_ip(ip)
asn, as_name, asn_source = enrich_ip_asn(ip)
asn, as_name, bgp_prefix, asn_source = enrich_ip_asn(ip)
record: dict[str, Any] = {
"ip": ip,
@@ -377,6 +377,7 @@ def _build_record(
"country_source": country_source,
"asn": asn,
"as_name": as_name,
"bgp_prefix": bgp_prefix,
"asn_source": asn_source,
"updated_at": datetime.now(timezone.utc),
}