You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thehive_api = TheHiveApi()
thehive_api.update_alert(alert_id=alert_id, alert=Alert(**alert), fields=['artifacts'])
--------------
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AlertArtifact is not JSON serializable
Possible Solutions
#api.py
def update_alert(self, alert_id, alert, fields=[]):
req = self.url + "/api/alert/{}".format(alert_id)
# update only the alert attributes that are not read-only
update_keys = ['tlp', 'severity', 'tags', 'caseTemplate', 'title', 'description', 'customFields']
if len(fields) > 0:
data = {k: v for k, v in alert.__dict__.items() if k in fields}
else:
data = {k: v for k, v in alert.__dict__.items() if k in update_keys}
- if hasattr(data, 'artifacts'):
+ if hasattr(alert, 'artifacts'):
data['artifacts'] = [a.__dict__ for a in alert.artifacts]
try:
return requests.patch(req, headers={'Content-Type': 'application/json'}, json=data, proxies=self.proxies, auth=self.auth, verify=self.cert)
except requests.exceptions.RequestException as e:
raise AlertException("Alert update error: {}".format(e))
The text was updated successfully, but these errors were encountered:
Request Type
Bug
Work Environment
Problem Description
Error updating alert artifact:
Possible Solutions
The text was updated successfully, but these errors were encountered: