@@ -50,18 +50,23 @@ def build_dbs_ip_asn(reports: dict, ptrs: dict, lookup_lists: dict, networks: di
50
50
IPv4Address (ip )
51
51
mmdb4 .insert_network (ipset , {** asn_info ['full' ], ** net })
52
52
53
- if asn not in json4 :
54
- json4 [asn ] = {}
53
+ if asn != 0 :
54
+ if asn not in json4 :
55
+ json4 [asn ] = {}
55
56
56
- json4 [asn ][ip ] = {** asn_info ['small' ], ** net_sm }
57
+ json4 [asn ][ip ] = {** asn_info ['small' ], ** net_sm }
57
58
58
59
except AddressValueError :
59
60
mmdb6 .insert_network (ipset , {** asn_info ['full' ], ** net })
60
61
61
- if asn not in json6 :
62
- json6 [asn ] = {}
62
+ if asn != 0 :
63
+ if asn not in json6 :
64
+ json6 [asn ] = {}
63
65
64
- json6 [asn ][ip ] = {** asn_info ['small' ], ** net_sm }
66
+ json6 [asn ][ip ] = {** asn_info ['small' ], ** net_sm }
67
+
68
+ if asn == 0 :
69
+ continue
65
70
66
71
if asn not in asn_reports :
67
72
try :
@@ -94,13 +99,13 @@ def build_dbs_ip_asn(reports: dict, ptrs: dict, lookup_lists: dict, networks: di
94
99
}
95
100
96
101
if not asn_reports [asn ]['kind' ]['hosting' ]:
97
- asn_info = str (asn_reports [asn ]['info' ]['org' ]).lower ()
98
- if asn_info .find ('cloud' ) != - 1 or asn_info .find ('hosting ' ) != - 1 :
102
+ asn_org = str (asn_reports [asn ]['info' ]['org' ]).lower ()
103
+ if asn_org .find ('cloud' ) != - 1 or asn_org .find ('host ' ) != - 1 :
99
104
asn_reports [asn ]['kind' ]['hosting' ] = True
100
105
101
106
except KeyError as e :
102
- print (f'ERROR: Failed to lookup metadata of ASN { asn } ({ e } )' )
103
- asn_reports [ asn ] = { 'reports' : ip_reports }
107
+ print (f'ERROR: Failed to lookup metadata of ASN { asn } (KeyError: { e } )' )
108
+ continue
104
109
105
110
else :
106
111
for report_type , report_count in ip_reports .items ():
0 commit comments