carbonblack / cb-integration

Carbon Black integration Python utility library
MIT License
12 stars 4 forks source link

500 errors from CB server are not handled #27

Open strazzere opened 6 years ago

strazzere commented 6 years ago

https://github.com/carbonblack/cb-integration/blob/d46824771fa1c3d936cca710522c9c704f3da6c9/cbint/detonation.py#L210-L214

This will result in an error message telling the user to check the log, which will just tell them a 500 occurred. Likely the error should be caught, and the detonation should be retried at a later time. If something is wrong with the detonation, then it would likely be best for CB to actually respond with a meaningful status code / error message.

2018-10-15 20:11:37,198 ERROR insert_binaries_from_db(218) Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/cbint-2.0.0-py3.6.egg/cbint/detonation.py", line 215, in insert_binaries_from_db
    self.download_binary_insert_queue(detonation)
  File "/usr/local/lib/python3.6/site-packages/cbint-2.0.0-py3.6.egg/cbint/detonation.py", line 173, in download_binary_insert_queue
    binary_query[0].file.read()
  File "/usr/local/lib/python3.6/site-packages/cbapi/response/models.py", line 1663, in file
    with closing(self._cb.session.get("/api/v1/binary/{0:s}".format(self.md5sum), stream=True)) as r:
  File "/usr/local/lib/python3.6/site-packages/cbapi/connection.py", line 200, in get
    return self.http_request("GET", url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/cbapi/connection.py", line 196, in http_request
    raise ServerError(error_code=r.status_code, message=r.text)
cbapi.errors.ServerError: Received error code 500 from API: Unhandled exception. Check logs for details.
zacharyestep commented 6 years ago

I believe you're right, please use the cb-yara-connector instead of this until we get the bugs ironed our and release.

V/r,

nileshp11 commented 5 years ago

I am trying to hit https://<Base_URL>/api/v1/binary?cb.urlver=2&amp;q=(ipaddr:10.1.180.21)&amp;sort=&amp;rows=1000&amp;start=0&amp;q.server_added_timestamp=%5B2019-06-03T12:22:18%20TO%202019-06-10T12:22:18%5D&#13; with X-Auth-Token but still receiving 500 Internal Server Error with Unhandled exception. Check logs for details message. Can someone please comment on this?