new: Allow to pass a list of WarningLists (in dict) as parameter
parent
d95ebeacfe
commit
133771d7c4
|
@ -108,16 +108,20 @@ class WarningList():
|
||||||
|
|
||||||
class WarningLists(collections.Mapping):
|
class WarningLists(collections.Mapping):
|
||||||
|
|
||||||
def __init__(self, slow_search=False):
|
def __init__(self, slow_search=False, lists=False):
|
||||||
"""Load all the warning lists from the package.
|
"""Load all the warning lists from the package.
|
||||||
:slow_search: If true, uses the most appropriate search method. Can be slower. Default: exact match.
|
:slow_search: If true, uses the most appropriate search method. Can be slower. Default: exact match.
|
||||||
|
:lists: A list of warning lists (typically fetched from a MISP instance)
|
||||||
"""
|
"""
|
||||||
self.root_dir_warninglists = os.path.join(os.path.abspath(os.path.dirname(sys.modules['pymispwarninglists'].__file__)),
|
if not lists:
|
||||||
'data', 'misp-warninglists', 'lists')
|
lists = []
|
||||||
|
self.root_dir_warninglists = os.path.join(os.path.abspath(os.path.dirname(sys.modules['pymispwarninglists'].__file__)),
|
||||||
|
'data', 'misp-warninglists', 'lists')
|
||||||
|
for warninglist_file in glob(os.path.join(self.root_dir_warninglists, '*', 'list.json')):
|
||||||
|
with open(warninglist_file, 'r') as f:
|
||||||
|
lists.append(json.load(f))
|
||||||
self.warninglists = {}
|
self.warninglists = {}
|
||||||
for warninglist_file in glob(os.path.join(self.root_dir_warninglists, '*', 'list.json')):
|
for warninglist in lists:
|
||||||
with open(warninglist_file, 'r') as f:
|
|
||||||
warninglist = json.load(f)
|
|
||||||
self.warninglists[warninglist['name']] = WarningList(warninglist, slow_search)
|
self.warninglists[warninglist['name']] = WarningList(warninglist, slow_search)
|
||||||
|
|
||||||
def validate_with_schema(self):
|
def validate_with_schema(self):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pymispwarninglists',
|
name='pymispwarninglists',
|
||||||
version='0.1',
|
version='0.2',
|
||||||
author='Raphaël Vinot',
|
author='Raphaël Vinot',
|
||||||
author_email='raphael.vinot@circl.lu',
|
author_email='raphael.vinot@circl.lu',
|
||||||
maintainer='Raphaël Vinot',
|
maintainer='Raphaël Vinot',
|
||||||
|
|
Loading…
Reference in New Issue