diff --git a/README.md b/README.md index b7eb554..9350b25 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,14 @@ vulners_api = vulners.Vulners(api_key="YOUR_API_KEY_HERE") # Parentseeds means "what KB are covering this KB". superseeds = vulners_api.kbSuperseeds("KB4524135") ``` +### Get Windows KB updates list and download urls +```python +import vulners + +vulners_api = vulners.Vulners(api_key="YOUR_API_KEY_HERE") +microsoft_updates_for_kb = vulners_api.kbUpdates("KB4524135") +updates_download_links = [update.get('href') for update in microsoft_updates_for_kb] +``` ### Score any vulnerability description using [Vulners AI](https://lab.wallarm.com/new-from-wallarm-research-first-ai-based-tool-to-predict-vulnerability-risk-2d0a7e9b3474) ```python import vulners diff --git a/vulners/__init__.py b/vulners/__init__.py index 44010f8..e0893f9 100644 --- a/vulners/__init__.py +++ b/vulners/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version__ = "1.5.3" +__version__ = "1.5.4" from vulners.api import Vulners diff --git a/vulners/api.py b/vulners/api.py index 0449514..957c976 100644 --- a/vulners/api.py +++ b/vulners/api.py @@ -552,10 +552,38 @@ def kbSuperseeds(self, kb_identificator): :param kb_identificator: Microsoft KB identificator :return: {'superseeds':[], 'parentseeds':[]} """ + if not isinstance(kb_identificator, string_types): + raise TypeError('KB Identificator expected to be a a string') kb_candidate = self.__id(identificator=kb_identificator, fields=['superseeds', 'parentseeds'], references=False) kb_document = kb_candidate.get('documents',{}).get(kb_identificator, {}) return {'superseeds':kb_document.get('superseeds', []), 'parentseeds':kb_document.get('parentseeds', [])} + def kbUpdates(self, kb_identificator, fields = None): + """ + Returns list of updates for KB + :param kb_identificator: Microsoft KB identificator + :return: List of the found documents, total found bulletins + """ + if not isinstance(kb_identificator, string_types): + raise TypeError('KB Identificator expected to be a a string') + + query = "type:msupdate AND kb:(%s)" % (kb_identificator) + + total_bulletins = self.__search(query, 0, 0, ['id']).get('total') + dataDocs = [] + total = 0 + offset = 0 + limit = 1000 + for skip in range(offset, total_bulletins, limit): + results = self.__search(query, skip, limit, fields or self.default_fields) + if not isinstance(results, dict): + raise AssertionError( + "Asserted result failed. No JSON returned from Vulners.\nReturned response: %s..." % results[:100]) + total = max(results.get('total'), total) + for element in results.get('search'): + dataDocs.append(element.get('_source')) + return AttributeList(dataDocs, total=total) + def documentList(self, identificatorList, fields = None): """ Fetch information about multiple bulletin identificators