-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathadd_object_relationship.py
More file actions
executable file
·34 lines (24 loc) · 1.37 KB
/
add_object_relationship.py
File metadata and controls
executable file
·34 lines (24 loc) · 1.37 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
30
31
32
33
34
#!/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__':
valid_object_type = {'Attribute', 'Event', 'EventReport', 'GalaxyCluster', 'Galaxy',
'Object', 'Note', 'Opinion', 'Relationship', 'Organisation',
'SharingGroup'}
parser = argparse.ArgumentParser(description='Add a reference between two objects')
parser.add_argument("-o", "--object", help="The uuid of the object referencing.",required=True)
parser.add_argument("-t", "--target-uuid", help="The uuid of the object referenced.",required=True)
parser.add_argument("-r", "--relationship-type", help="The type of the relationship",required=True)
parser.add_argument("--type", help="The type of the referenced object",required=True,choices=valid_object_type)
args = parser.parse_args()
misp = PyMISP(misp_url, misp_key, misp_verifycert)
misp_object = misp.get_object(args.object,pythonify=True)
relationship = misp_object.add_relationship(args.type, args.target_uuid, args.relationship_type)
print(relationship)
misp.add_relationship(relationship)