зеркало из https://github.com/mozilla/MozDef.git
Satisfy tests
This commit is contained in:
Родитель
91d7fe21e3
Коммит
c4ac61f24d
|
@ -49,23 +49,30 @@ def enrich(alert, known_ips):
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def ip_in_range(ip):
|
||||||
|
return lambda known: netaddr.IPAddress(ip) in netaddr.IPSet([known['range']])
|
||||||
|
|
||||||
|
|
||||||
ips = find_ips(alert)
|
ips = find_ips(alert)
|
||||||
|
|
||||||
alert = alert.copy()
|
alert = alert.copy()
|
||||||
|
|
||||||
|
alert['details']['sites'] = []
|
||||||
|
|
||||||
for ip in set(ips):
|
for ip in set(ips):
|
||||||
ip_address = netaddr.IPAddress(ip)
|
matching_descriptions = filter(ip_in_range(ip), known_ips)
|
||||||
|
|
||||||
matching_descriptions = filter(
|
|
||||||
lambda known: ip_address in netaddr.IPSet([known['range']]),
|
|
||||||
known_ips)
|
|
||||||
|
|
||||||
for desc in matching_descriptions:
|
for desc in matching_descriptions:
|
||||||
enriched = desc['format'].format(ip, desc['site'])
|
enriched = desc['format'].format(ip, desc['site'])
|
||||||
|
|
||||||
alert['details']['site'] = desc['site']
|
|
||||||
alert['summary'] += '; ' + enriched
|
alert['summary'] += '; ' + enriched
|
||||||
|
|
||||||
|
alert['details']['sites'].append({
|
||||||
|
'ip': ip,
|
||||||
|
'site': desc['site'],
|
||||||
|
})
|
||||||
|
|
||||||
return alert
|
return alert
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче