1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+
4+ from pymisp import PyMISP
5+ from keys import misp_url , misp_key , misp_verifycert
6+ import argparse
7+
8+ # Suppress those "Unverified HTTPS request is being made"
9+ if not misp_verifycert :
10+ import urllib3
11+ urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
12+
13+ if __name__ == '__main__' :
14+
15+ valid_object_type = {'Attribute' , 'Event' , 'EventReport' , 'GalaxyCluster' , 'Galaxy' ,
16+ 'Object' , 'Note' , 'Opinion' , 'Relationship' , 'Organisation' ,
17+ 'SharingGroup' }
18+
19+ parser = argparse .ArgumentParser (description = 'Add a reference between two objects' )
20+ parser .add_argument ("-o" , "--object" , help = "The uuid of the object referencing." ,required = True )
21+ parser .add_argument ("-t" , "--target-uuid" , help = "The uuid of the object referenced." ,required = True )
22+ parser .add_argument ("-r" , "--relationship-type" , help = "The type of the relationship" ,required = True )
23+ parser .add_argument ("--type" , help = "The type of the referenced object" ,required = True ,choices = valid_object_type )
24+ args = parser .parse_args ()
25+
26+ misp = PyMISP (misp_url , misp_key , misp_verifycert )
27+
28+ misp_object = misp .get_object (args .object ,pythonify = True )
29+
30+ relationship = misp_object .add_relationship (args .type , args .target_uuid , args .relationship_type )
31+
32+ print (relationship )
33+
34+ misp .add_relationship (relationship )
0 commit comments