Skip to content

Commit

Permalink
Minor 1.5.4
Browse files Browse the repository at this point in the history
Windows KB updates listing helper
  • Loading branch information
vulnersCom committed Oct 10, 2019
1 parent 65402b5 commit 666f4b0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vulners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__version__ = "1.5.3"
__version__ = "1.5.4"

from vulners.api import Vulners
28 changes: 28 additions & 0 deletions vulners/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 666f4b0

Please sign in to comment.