This commit is contained in:
Emma Rose 2019-09-26 15:04:33 -04:00
Родитель 672bb09f67
Коммит 5692d01793
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1486642516ED3535
4 изменённых файлов: 10 добавлений и 13 удалений

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

@ -74,7 +74,7 @@ def alert(
if len(locs_to_consider) < 2:
return None
pairs = [
(locs_to_consider[i], locs_to_consider[i + 1])
for i in range(len(locs_to_consider) - 1)

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

@ -9,7 +9,6 @@ import json
import os
import sys
import traceback
from operator import attrgetter
from lib.alerttask import AlertTask
from mozdef_util.query_models import SearchQuery, TermMatch, SubnetMatch, QueryStringMatch as QSMatch
@ -68,7 +67,6 @@ class AlertGeoModel(AlertTask):
def onAggregation(self, agg):
username = agg['value']
#events = sorted(agg['events'], key=lambda x: x['_source']['utctimestamp'], reverse=False)
events = agg['events']
cfg = agg['config']

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

@ -11,7 +11,7 @@ class TestAlert:
'''
def test_do_not_alert_when_travel_possible(self):
state = locality.State('locality', 'testuser', [
evts = [
locality.Locality(
sourceipaddress='1.2.3.123',
city='Toronto',
@ -28,14 +28,14 @@ class TestAlert:
latitude=37.773972,
longitude=-122.431297,
radius=50)
])
]
alert_produced = alert(state.username, state.localities)
alert_produced = alert('tester1', evts, [])
assert alert_produced is None
def test_do_alert_when_travel_impossible(self):
state = locality.State('locality', 'testuser', [
evts = [
locality.Locality(
sourceipaddress='1.2.3.123',
city='Toronto',
@ -52,9 +52,9 @@ class TestAlert:
latitude=37.773972,
longitude=-122.431297,
radius=50)
])
]
alert_produced = alert(state.username, state.localities)
alert_produced = alert('testuser', evts, [])
assert alert_produced is not None
assert alert_produced.username == 'testuser'
@ -62,7 +62,7 @@ class TestAlert:
assert alert_produced.hops[0].destination.city == 'Toronto'
def test_alerts_include_all_impossible_hops(self):
state = locality.State('locality', 'testuser', [
evts = [
locality.Locality(
sourceipaddress='1.2.3.123',
city='Toronto',
@ -87,9 +87,9 @@ class TestAlert:
latitude=37.773972,
longitude=-122.431297,
radius=50)
])
]
alert_produced = alert(state.username, state.localities)
alert_produced = alert('tester', evts, [])
assert alert_produced is not None
assert len(alert_produced.hops) == 2

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

@ -1,5 +1,4 @@
from datetime import datetime, timedelta
import itertools
from freezegun import freeze_time