Fix CbResponseAPI usage for non-adminstrative users on Cb EDR 7.6 and above #304
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?
Issue #303
Ticket Number: N/A
Issue Number: N/A
Pull Request Description
Users without Admin tokens are unable to connect to Carbon Black EDR with the
CbResponseAPI
client, starting from version 7.6. This fixes issue #303, as reported by @sevdog.Upon initialization of the client, the users are presented a
ClientError
with an underlaying 403 HTTP response code.Looking into the code, this is caused by a 403 on the
_has_legacy_partitions
check in theCbResponseAPI.__init__()
function.As we do not have access to this API Endpoint since 7.6, intentionally or not, we should not care about them, and thus the 403 can be ignored.
I chose to wrap the check with a try/except block, ignoring a
ClientError
exception with a error code403
, so that the average Carbon Black user can continue whatever they need to do, without breaking functionality for the administrative user or whichever user that has rights to work with the partitions.Does this introduce a breaking change?
How Has This Been Tested?
Manually, locally by connecting to Carbon Black Instances before and after the change and performing normal and automated tasks of the past.
Other information:
src/cbapi/response/rest_api.py