-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Add bindings to PyMISPWarninglists
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from pymisp import PyMISP | ||
from pymisp.tools import load_warninglists | ||
import argparse | ||
from keys import misp_url, misp_key | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser(description='Load the warninglists.') | ||
parser.add_argument("-p", "--package", action='store_true', help="from the PyMISPWarninglists package.") | ||
parser.add_argument("-r", "--remote", action='store_true', help="from the MISP instance.") | ||
|
||
args = parser.parse_args() | ||
|
||
if args.package: | ||
print(load_warninglists.from_package()) | ||
elif args.remote: | ||
pm = PyMISP(misp_url, misp_key) | ||
print(load_warninglists.from_instance(pm)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
try: | ||
from pymispwarninglists import WarningLists | ||
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) |