-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathadd_object_reference.py
More file actions
executable file
·29 lines (21 loc) · 1.1 KB
/
add_object_reference.py
File metadata and controls
executable file
·29 lines (21 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pymisp import PyMISP
from keys import misp_url, misp_key, misp_verifycert
import argparse
# Suppress those "Unverified HTTPS request is being made"
if not misp_verifycert:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Add a reference between two objects')
parser.add_argument("-o", "--object", help="The id, uuid or json of the object referencing.",required=True)
parser.add_argument("-t", "--target", help="The id, uuid or json of the object referenced.",required=True)
parser.add_argument("-r", "--relationship-type", help="The type of the relationship",required=True)
args = parser.parse_args()
misp = PyMISP(misp_url, misp_key, misp_verifycert)
misp_object = misp.get_object(args.object,pythonify=True)
target_object = misp.get_object(args.target,pythonify=True)
object_ref = misp_object.add_reference(target_object.uuid,args.relationship_type)
print(object_ref)
misp.add_object_reference(object_ref)