Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Fix geomodel alert and update mozdef-util (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcrose committed Apr 29, 2020
1 parent f246cc3 commit 7ef21bc
Show file tree
Hide file tree
Showing 6 changed files with 547 additions and 34 deletions.
1 change: 1 addition & 0 deletions alerts/geomodel/factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def factor(alert: Alert) -> Enhancement:
asn_pairs = [
(asn_info[i], asn_info[i + 1])
for i in range(len(asn_info) - 1)
if asn_info[i] is not None and asn_info[i + 1] is not None
]
asn_hops = [
pair
Expand Down
7 changes: 6 additions & 1 deletion mozdef_util/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@ Add is_ip utility function
3.0.4 (2019-09-19)
------------------

* Added SubnetMatch query model
* Added SubnetMatch query models

3.0.5 (2020-04-29)
------------------

* Rewrite dict2List to improve correctness and generality
50 changes: 19 additions & 31 deletions mozdef_util/mozdef_util/utilities/dict2List.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
def dict2List(inObj):
'''given a dictionary, potentially with multiple sub dictionaries
return a list of the dict keys and values
from datetime import datetime


def dict2List(value):
'''Convert dictionaries into a list of keys and values,
with strings in lowercase and datetimes converted to isoformat.
'''
if isinstance(inObj, dict):
for key, value in inObj.items():
if isinstance(value, dict):
for d in dict2List(value):
yield d
elif isinstance(value, list):
yield key.lower()
for l in dict2List(value):
yield l
else:
yield key.lower()
if isinstance(value, str):
yield value.lower()
else:
yield value
elif isinstance(inObj, list):
for v in inObj:
if isinstance(v, str):
yield v.lower()
elif isinstance(v, list):
for l in dict2List(v):
yield l
elif isinstance(v, dict):
for l in dict2List(v):
yield l
else:
yield v

if isinstance(value, dict):
for key, val in value.items():
yield from dict2List(key)
yield from dict2List(val)
elif isinstance(value, (list, tuple)):
for val in value:
yield from dict2List(val)
elif isinstance(value, datetime):
yield value.isoformat()
elif isinstance(value, str):
yield value.lower()
else:
yield ''
yield value
2 changes: 1 addition & 1 deletion mozdef_util/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
test_suite='tests',
tests_require=[],
url='https://github.com/mozilla/MozDef/tree/master/lib',
version='3.0.4',
version='3.0.5',
zip_safe=False,
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ipwhois==0.15.0
jmespath==0.9.3
kombu==4.1.0
mozdef-client==1.0.11
mozdef-util==3.0.4
mozdef-util==3.0.5
netaddr==0.7.19
oauth2client==1.4.12
pyOpenSSL==18.0.0
Expand Down

0 comments on commit 7ef21bc

Please sign in to comment.