зеркало из https://github.com/mozilla/MozDef.git
Appease the Linter gods
This commit is contained in:
Родитель
672bb09f67
Коммит
5692d01793
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче