From ffcc7e0631eaa3fb28c20cf606ec81d4874d6976 Mon Sep 17 00:00:00 2001 From: Tom King Date: Wed, 19 Jun 2019 10:25:34 +0100 Subject: [PATCH] new: Introduce ability to create a sharing group --- pymisp/api.py | 18 +++++++++++++++++- pymisp/mispevent.py | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 2b2c2db..70bd097 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -17,7 +17,7 @@ import zipfile from . import __version__, deprecated from .exceptions import PyMISPError, SearchError, NoURL, NoKey, PyMISPEmptyResponse -from .mispevent import MISPEvent, MISPAttribute, MISPUser, MISPOrganisation, MISPSighting, MISPFeed, MISPObject +from .mispevent import MISPEvent, MISPAttribute, MISPUser, MISPOrganisation, MISPSighting, MISPFeed, MISPObject, MISPSharingGroup from .abstract import AbstractMISP, MISPEncode logger = logging.getLogger('pymisp') @@ -2241,6 +2241,22 @@ class PyMISP(object): # ###################### # ### Sharing Groups ### # ###################### + def add_sharing_group(self, name, releasability, description, active=True, roaming=False): + """Add a new sharing group, which includes the organisation associated + with the API key and the local server + + :name: The name of the sharing group to create + :releasability: The releasibility information + :description: The description of the sharing group + :active: Should the sharing group be set to be active? + :roaming: Should the sharing group be allowed to roam? + """ + + new_sg = MISPSharingGroup() + new_sg.from_dict(name=name, releasability=releasability, + description=description, active=active, roaming=roaming) + + return self._rest_add('sharing_groups', new_sg) def sharing_group_org_add(self, sharing_group, organisation, extend=False): '''Add an organisation to a sharing group. diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index c660ed4..3ec8879 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -1176,3 +1176,12 @@ class MISPObject(AbstractMISP): if hasattr(self, 'name'): return '<{self.__class__.__name__}(name={self.name})'.format(self=self) return '<{self.__class__.__name__}(NotInitialized)'.format(self=self) + + +class MISPSharingGroup(AbstractMISP): + + def __init__(self): + super(MISPSharingGroup, self).__init__() + + def from_dict(self, **kwargs): + super(MISPSharingGroup, self).from_dict(**kwargs)