Properly populate urlobject with ORG KEY value in _count() function #237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the ticket or issue number?
No known ticket or issue number
Pull Request Description
using
.len()
on ThreatHunter Event query objects throws a 403 error because the_count()
function incbapi/psc/threathunter/query.py
does not populateself._doc_class.urlobject
with an ORG KEY value (i.e.self._cb.credentials.org_key
). This fix adds the required.format()
function that inserts the ORG KEY into the urlobject.A similar fix was added for the
_perform_query()
function where theurl
variable is assigned a properly populated urlobject value (which includes the ORG KEY value), but is then not used in theget_object()
function that follows it.UI event count shows 582 events are being returned by Cb ThreatHunter
Running the below sample script will error with the current version of cbapi due to the missing ORG KEY value in
self._doc_class.urlobject
. Rerunning the script using the changes from this pull request returns the expected value of 582. Counting the actual iterations when looping over the results still yields lower results (see below).Does this introduce a breaking change?
How Has This Been Tested?
This was tested using the following code snippet:
Other information:
While this fixes the
len()
function on a event query result object, it does not resolve the issue where iterating over the results yields far fewer results than are said to be available (#239). The above test script will show that in specific cases thelen()
function returns a higher value than counting the iterations when looping over the results.