From c18d5cac6d2f944409fb9e1a399b08f7c7dd3f0b Mon Sep 17 00:00:00 2001 From: obsidianpentesting Date: Thu, 6 Jul 2017 16:06:59 -0500 Subject: [PATCH 1/2] Simple function to cache all feeds at once. This is almost identical to fetch_feed. In the future, I would like to specify the scope to include other values. --- pymisp/api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pymisp/api.py b/pymisp/api.py index af091f8..162d0b6 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -1501,6 +1501,16 @@ class PyMISP(object): response = session.get(url) return self._check_response(response) + # ########################### + # ### Cache All Feeds ### + # ########################### + + def cache_all_feeds(self): + session = self.__prepare_session() + url = urljoin(self.root_url, 'feeds/cacheFeeds/all') + response = session.post(url) + return self._check_response(response) + # ########################### # ####### Deprecated ######## # ########################### From 17e44c1c74784f761ea93a4d8789fbafaafdd9db Mon Sep 17 00:00:00 2001 From: obsidianpentesting Date: Thu, 6 Jul 2017 16:07:34 -0500 Subject: [PATCH 2/2] Example script to invoke the cache_all_feeds() from PyMISP. --- examples/cache_all.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/cache_all.py diff --git a/examples/cache_all.py b/examples/cache_all.py new file mode 100644 index 0000000..00e3eea --- /dev/null +++ b/examples/cache_all.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from keys import misp_url, misp_key, misp_verifycert +from pymisp import PyMISP + + +def init(url, key): + return PyMISP(url, key, misp_verifycert, 'json') + + +if __name__ == '__main__': + misp = init(misp_url, misp_key) + misp.cache_all_feeds() \ No newline at end of file