Skip to content

Commit

Permalink
Merge pull request #408 from tomking2/master
Browse files Browse the repository at this point in the history
Introduce ability to create a sharing group
  • Loading branch information
Rafiot committed Jul 4, 2019
2 parents 24f31e4 + 709ba2c commit 9f53426
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pymisp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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')
Expand Down Expand Up @@ -2241,6 +2241,20 @@ def cache_all_feeds(self):
# ######################
# ### Sharing Groups ###
# ######################
def add_sharing_group(self, name, releasability, description, active=True):
"""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?
"""

new_sg = MISPSharingGroup()
new_sg.from_dict(name=name, releasability=releasability,
description=description, active=active)
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.
Expand Down
9 changes: 9 additions & 0 deletions pymisp/mispevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,3 +1176,12 @@ def __repr__(self):
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)

0 comments on commit 9f53426

Please sign in to comment.