How to use the pymisp.mispevent.MISPOrganisation function in pymisp

To help you get started, weā€™ve selected a few pymisp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MISP / PyMISP / pymisp / mispevent.py View on Github external
if kwargs.get('sharing_group_id'):
            self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
        if kwargs.get('RelatedEvent'):
            for rel_event in kwargs.pop('RelatedEvent'):
                sub_event = MISPEvent()
                sub_event.load(rel_event)
                self.RelatedEvent.append({'Event': sub_event})
        if kwargs.get('Tag'):
            [self.add_tag(tag) for tag in kwargs.pop('Tag')]
        if kwargs.get('Object'):
            [self.add_object(obj) for obj in kwargs.pop('Object')]
        if kwargs.get('Org'):
            self.Org = MISPOrganisation()
            self.Org.from_dict(**kwargs.pop('Org'))
        if kwargs.get('Orgc'):
            self.Orgc = MISPOrganisation()
            self.Orgc.from_dict(**kwargs.pop('Orgc'))

        super(MISPEvent, self).from_dict(**kwargs)
github MISP / PyMISP / pymisp / mispevent.py View on Github external
self.sighting_timestamp = datetime.datetime.fromtimestamp(int(kwargs.pop('sighting_timestamp')), datetime.timezone.utc)
            else:
                self.sighting_timestamp = datetime.datetime.fromtimestamp(int(kwargs.pop('sighting_timestamp')), UTC())
        if kwargs.get('sharing_group_id'):
            self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
        if kwargs.get('RelatedEvent'):
            for rel_event in kwargs.pop('RelatedEvent'):
                sub_event = MISPEvent()
                sub_event.load(rel_event)
                self.RelatedEvent.append({'Event': sub_event})
        if kwargs.get('Tag'):
            [self.add_tag(tag) for tag in kwargs.pop('Tag')]
        if kwargs.get('Object'):
            [self.add_object(obj) for obj in kwargs.pop('Object')]
        if kwargs.get('Org'):
            self.Org = MISPOrganisation()
            self.Org.from_dict(**kwargs.pop('Org'))
        if kwargs.get('Orgc'):
            self.Orgc = MISPOrganisation()
            self.Orgc.from_dict(**kwargs.pop('Orgc'))

        super(MISPEvent, self).from_dict(**kwargs)
github MISP / PyMISP / pymisp / api.py View on Github external
def add_organisation_json(self, json_file):
        with open(json_file, 'rb') as f:
            jdata = json.load(f)
        new_org = MISPOrganisation()
        new_org.from_dict(**jdata)
        return self._rest_add('admin/organisations', new_org)
github MISP / PyMISP / pymisp / aping.py View on Github external
def organisations(self, scope="local", pythonify: bool=False):
        """Get all the organisations."""
        organisations = self._prepare_request('GET', f'organisations/index/scope:{scope}')
        organisations = self._check_response(organisations, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in organisations:
            return organisations
        to_return = []
        for organisation in organisations:
            o = MISPOrganisation()
            o.from_dict(**organisation)
            to_return.append(o)
        return to_return
github MISP / PyMISP / pymisp / aping.py View on Github external
def update_organisation(self, organisation: MISPOrganisation, organisation_id: int=None, pythonify: bool=False):
        '''Update an organisation'''
        if organisation_id is None:
            organisation_id = self.__get_uuid_or_id_from_abstract_misp(organisation)
        else:
            organisation_id = self.__get_uuid_or_id_from_abstract_misp(organisation_id)
        updated_organisation = self._prepare_request('POST', f'admin/organisations/edit/{organisation_id}', data=organisation)
        updated_organisation = self._check_response(updated_organisation, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in updated_organisation:
            return updated_organisation
        o = MISPOrganisation()
        o.from_dict(**organisation)
        return o
github MISP / PyMISP / pymisp / api.py View on Github external
def add_organisation(self, name, **kwargs):
        if isinstance(name, MISPOrganisation):
            # Very dirty, allow to call that from ExpandedPyMISP
            new_org = name
        else:
            new_org = MISPOrganisation()
            new_org.from_dict(name=name, **kwargs)
            if 'local' in new_org:
                if new_org.get('local') is False:
                    if 'uuid' not in new_org:
                        raise PyMISPError('A remote org MUST have a valid uuid')
        return self._rest_add('admin/organisations', new_org)
github MISP / PyMISP / pymisp / mispevent.py View on Github external
def orgc(self, orgc):
        if isinstance(orgc, MISPOrganisation):
            self.Orgc = orgc
        else:
            raise PyMISPError('Orgc must be of type MISPOrganisation.')
github MISP / PyMISP / pymisp / mispevent.py View on Github external
def from_dict(self, **kwargs):
        if 'Organisation' in kwargs:
            kwargs = kwargs['Organisation']
        super(MISPOrganisation, self).from_dict(**kwargs)