How to use the pymisp.mispevent.MISPFeed 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 / aping.py View on Github external
def update_feed(self, feed: MISPFeed, feed_id: int=None, pythonify: bool=False):
        '''Update a feed on a MISP instance'''
        if feed_id is None:
            feed_id = self.__get_uuid_or_id_from_abstract_misp(feed)
        else:
            feed_id = self.__get_uuid_or_id_from_abstract_misp(feed_id)
        # FIXME: https://github.com/MISP/MISP/issues/4834
        feed = {'Feed': feed}
        updated_feed = self._prepare_request('POST', f'feeds/edit/{feed_id}', data=feed)
        updated_feed = self._check_response(updated_feed, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in updated_feed:
            return updated_feed
        f = MISPFeed()
        f.from_dict(**updated_feed)
        return f
github MISP / PyMISP / pymisp / aping.py View on Github external
def enable_feed(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool=False):
        '''Enable a feed (fetching it will create event(s)'''
        if not isinstance(feed, MISPFeed):
            feed_id = self.__get_uuid_or_id_from_abstract_misp(feed)  # In case we have a UUID
            feed = MISPFeed()
            feed.id = feed_id
            feed.enabled = True
        return self.update_feed(feed=feed, pythonify=pythonify)
github MISP / PyMISP / pymisp / aping.py View on Github external
def search_feeds(self, value: Optional[SearchParameterTypes]=None, pythonify: Optional[bool]=False):
        '''Search in the feeds cached on the servers'''
        response = self._prepare_request('POST', '/feeds/searchCaches', data={'value': value})
        normalized_response = self._check_response(response, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in normalized_response:
            return normalized_response
        to_return = []
        for feed in normalized_response:
            f = MISPFeed()
            f.from_dict(**feed)
            to_return.append(f)
        return to_return
github MISP / PyMISP / pymisp / mispevent.py View on Github external
def __init__(self):
        super(MISPFeed, self).__init__()
github MISP / PyMISP / pymisp / api.py View on Github external
def add_feed(self, source_format, url, name, input_source, provider, **kwargs):
        """Delete a feed"""
        new_feed = MISPFeed()
        new_feed.from_dict(source_format=source_format, url=url, name=name,
                           input_source=input_source, provider=provider)
        return self._rest_add('feeds', new_feed)
github MISP / PyMISP / pymisp / aping.py View on Github external
def add_feed(self, feed: MISPFeed, pythonify: bool=False):
        '''Add a new feed on a MISP instance'''
        # FIXME: https://github.com/MISP/MISP/issues/4834
        feed = {'Feed': feed}
        new_feed = self._prepare_request('POST', 'feeds/add', data=feed)
        new_feed = self._check_response(new_feed, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in new_feed:
            return new_feed
        f = MISPFeed()
        f.from_dict(**new_feed)
        return f
github MISP / PyMISP / pymisp / aping.py View on Github external
def get_feed(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool=False):
        """Get a feed by id."""
        feed_id = self.__get_uuid_or_id_from_abstract_misp(feed)
        feed = self._prepare_request('GET', f'feeds/view/{feed_id}')
        feed = self._check_response(feed, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in feed:
            return feed
        f = MISPFeed()
        f.from_dict(**feed)
        return f
github MISP / PyMISP / pymisp / aping.py View on Github external
def feeds(self, pythonify: bool=False):
        """Get the list of existing feeds."""
        feeds = self._prepare_request('GET', 'feeds')
        feeds = self._check_response(feeds, expect_json=True)
        if not (self.global_pythonify or pythonify) or 'errors' in feeds:
            return feeds
        to_return = []
        for feed in feeds:
            f = MISPFeed()
            f.from_dict(**feed)
            to_return.append(f)
        return to_return
github MISP / PyMISP / pymisp / aping.py View on Github external
def disable_feed(self, feed: Union[MISPFeed, int, str, UUID], pythonify: bool=False):
        '''Disable a feed'''
        if not isinstance(feed, MISPFeed):
            feed_id = self.__get_uuid_or_id_from_abstract_misp(feed)  # In case we have a UUID
            feed = MISPFeed()
            feed.id = feed_id
            feed.enabled = False
        return self.update_feed(feed=feed, pythonify=pythonify)