Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions examples/add_object_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
34 changes: 34 additions & 0 deletions examples/add_object_relationship.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)