This commit is contained in:
Emma Rose 2019-05-16 13:54:18 -04:00
Родитель 91d7fe21e3
Коммит c4ac61f24d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1486642516ED3535
1 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -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