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

openVulnQuery API query filtering

MarcusSjogren
Level 1
Level 1

Hi,

 

I am working a bit with the Python module openVulnQuery and I am not getting the filtering to work.

 

The code is as per below:

query_client = query_client.OpenVulnQueryClient(client_id="1234", client_secret="5678")
query_filter = query_client.TemporalFilter(query_client.PUBLISHED_LAST, '2019-01-01', '2019-05-17')
query = query_client.get_by_product("default", args.platform, a_filter=query_filter)

for x in range(len(query)):
                print('Advisory ID: ', query[x].advisory_id)

And I am receiving the below error:

AttributeError: 'OpenVulnQueryClient' object has no attribute 'TemporalFilter'

I do understand that the attribute does not seem to exist, but it should do according to the GitHub.

 

Did anyone get this working properly? 
Is there any better documentation in regards of the Python module besides the GitHub?

Cheers!

2 Replies 2

MarcusSjogren
Level 1
Level 1

After researching the source code it looks like it is not supported to filter dates when fetching by "product".

Seb Rupik
VIP Alumni
VIP Alumni

Hi there,

It looks like you are getting your variables mixed up with class names. You are creating a new OpenVulnQueryClient object from query_client and assigning it to the variable query_client. You then try to create a TemporalFilter object from query_client object which is now a OpenVulnQueryClient.

Try this:

 

query_c = query_client.OpenVulnQueryClient(client_id="1234", client_secret="5678")
query_f = query_client.TemporalFilter(query_client.PUBLISHED_LAST, '2019-01-01', '2019-05-17')
query = query_c.get_by_product("default", args.platform, a_filter=query_f)

for x in range(len(query)):
                print('Advisory ID: ', query[x].advisory_id)

The GitHub repo is your only documentation as far as I know!

 

cheers,

Seb.