2018-01-25 17:56:30 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
try:
|
2020-01-23 10:27:40 +01:00
|
|
|
from pymispwarninglists import WarningLists # type: ignore
|
2018-01-25 17:56:30 +01:00
|
|
|
has_pymispwarninglists = True
|
|
|
|
except ImportError:
|
|
|
|
has_pymispwarninglists = False
|
|
|
|
|
|
|
|
|
|
|
|
def from_instance(pymisp_instance, slow_search=False):
|
|
|
|
"""Load the warnindlist from an existing MISP instance
|
|
|
|
:pymisp_instance: Already instantialized PyMISP instance."""
|
|
|
|
|
|
|
|
warninglists_index = pymisp_instance.get_warninglists()['Warninglists']
|
|
|
|
all_warningslists = []
|
|
|
|
for warninglist in warninglists_index:
|
|
|
|
wl = pymisp_instance.get_warninglist(warninglist['Warninglist']['id'])['Warninglist']
|
|
|
|
wl['list'] = wl.pop('WarninglistEntry')
|
|
|
|
all_warningslists.append(wl)
|
|
|
|
|
|
|
|
return WarningLists(slow_search, all_warningslists)
|
|
|
|
|
|
|
|
|
|
|
|
def from_package(slow_search=False):
|
|
|
|
return WarningLists(slow_search)
|