03-29-2019 01:17 PM
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'
Solved! Go to Solution.
03-29-2019 02:30 PM - edited 03-29-2019 02:31 PM
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.
03-29-2019 02:30 PM - edited 03-29-2019 02:31 PM
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.
05-18-2020 08:02 AM
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)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide