cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1237
Views
0
Helpful
2
Replies

OpenVuln API Python Library with Filtering

ryansharpe
Level 1
Level 1

I'm trying to build a script using the Python Library using the filtering example provided on Github, but I'm getting errors:

 

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from openVulnQuery import query_client
>>> client = query_client.OpenVulnQueryClient(id, secret)

>>> advisories = client.get_by_all(adv_format='cvrf', all_adv='all', LastUpdate(2019-03-01, 2019-03-28))
File "<stdin>", line 1
advisories = client.get_by_all(adv_format='cvrf', all_adv='all', LastUpdate(2019-03-01, 2019-03-28))
^
SyntaxError: invalid token

>>> adv = client.get_by_severity(adv_format='cvrf', severity='high', LastUpdate(2019-03-01, 2019-03-28))
File "<stdin>", line 1
adv = client.get_by_severity(adv_format='cvrf', severity='high', LastUpdate(2019-03-01, 2019-03-28))
^
SyntaxError: invalid token
>>> filter = client.LastUpdate(2019-03-01, 2019-03-28)
File "<stdin>", line 1
filter = client.LastUpdate(2019-03-01, 2019-03-28)
^
SyntaxError: invalid token
>>> adv = client.get_by_severity(adv_format='cvrf', severity='high', LastUpdate('2019-03-01', '2019-03-28'))
File "<stdin>", line 1
SyntaxError: positional argument follows keyword argument
>>> filter = client.LastUpdate('2019-03-01', '2019-03-28')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'OpenVulnQueryClient' object has no attribute 'LastUpdate'
1 Accepted Solution

Accepted Solutions

ryansharpe
Level 1
Level 1

Here is the correct way to apply filters:

client = query_client.OpenVulnQueryClient(client_id=creds.cisco_id, client_secret=creds.cisco_secret)
filter = query_client.TemporalFilter(query_client.PUBLISHED_LAST, '2019-03-01', '2019-03-28')
cisco_advisories = client.get_by_all(adv_format='default', all_adv='all', a_filter=filter)

 Someone should update the github documentation.

View solution in original post

2 Replies 2

ryansharpe
Level 1
Level 1

Here is the correct way to apply filters:

client = query_client.OpenVulnQueryClient(client_id=creds.cisco_id, client_secret=creds.cisco_secret)
filter = query_client.TemporalFilter(query_client.PUBLISHED_LAST, '2019-03-01', '2019-03-28')
cisco_advisories = client.get_by_all(adv_format='default', all_adv='all', a_filter=filter)

 Someone should update the github documentation.

Can you check if the filter is working for the get by product API call?

get_by_all works fine. But the filter doesn't work well for get_by_product. It fetches all the advisories for that product but not by the given time duration. 

 

Please assist.

a = '2020-05-15'
b = '2020-05-18'
filter = query_client.TemporalFilter(query_client.PUBLISHED_LAST, a, b)
#cisco_advisories = client.get_by_all(adv_format='default', all_adv='all', a_filter=filter)
cisco_advisories_product = client.get_by_product(adv_format='default', product_name='iso', a_filter=filter)