TheHive4py
TheHive4py copied to clipboard
Feature: Granulate exceptions in api.py functions to raise on 40x errors.
Request Type
Feature Request
Work Environment
| Question | Answer |
|---|---|
| OS version (server) | Ubuntu |
| OS version (client) | ... |
| TheHive4py version / git hash | 1.8.1 |
Problem Description
As of now the functions in api.py only raises on requests.exceptions.RequestException which is exceptions from the requests libary, that does not raise on client errors which is expected because the errors are not located in the "protocol layer" as timeouts, schema error or ssl exceptions
This, in practical terms mean that you can use thehive4py 1.8.1 and previous versions, and try to as an example use create_alert(alert) and because you have provided duplicate artifacts/observables, the api would respond with a 400 error and not ingest the alert, but it fails silently and you wouldnt know of it. I think its important when you provide a "pythonic way" of interacting with api that you also raise errors when they happen.
Possible Solutions
Implement raise logic that looks at errors or status codes from api and raises the appropiate exception.
As of now i have "monkey patched" the one "create_alert" function to raise AlertException if status code is anything other than 200 or 201, with the response.text and the data from request, to catch "client errors/user errors".