Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown attribute alert.customFields when creating alert in version 1.5.1 #88

Closed
dvanhise opened this issue Oct 15, 2018 · 1 comment
Closed

Comments

@dvanhise
Copy link

dvanhise commented Oct 15, 2018

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu, theHive 3.0.10
OS version (client) Ubuntu 18.04
TheHive4py version / git hash 1.5.1

Problem Description

When creating an alert using version 1.5.1 of thehive4py it always returns with a 400 status code and the response

{'tableName': 'alert', 'type': 'AttributeCheckingError', 'errors': [[{'name': 'alert.customFields', 'value': {'type': 'JsonInputValue', 'value': {}}, 'type': 'UnknownAttributeError', 'message': 'Unknown attribute alert.customFields: {"type":"JsonInputValue","value":{}}'}]]}

Steps to Reproduce

With TheHive4py at version 1.5.1, run

from thehive4py.api import TheHiveApi
from thehive4py.models import Alert

hive = TheHiveApi('hostname', 'username', password='password', cert=False)

data = {
    'title': 'test',
    'description': 'test',
    'severity': 2,
    'tags': [],
    'status': 'New',
    'type': 'test',
    'source': 'test',
    'sourceRef': 'test',
    'artifacts': [],
}
alert = Alert(**data)
print(alert.jsonify())
try:
    response = hive.create_alert(alert)
    response.raise_for_status()
except Exception as e:
    print(e)
    print(response.json())

The result is:

{
   "artifacts": [],
   "caseTemplate": null,
   "customFields": {},
   "date": 1539632884000,
   "description": "test",
   "severity": 2,
   "source": "test",
   "sourceRef": "test",
   "tags": [],
   "title": "test",
   "tlp": 2,
   "type": "test"
}
400 Client Error: Bad Request for url: https://somehiveserver.com/api/alert
{'tableName': 'alert', 'type': 'AttributeCheckingError', 'errors': [[{'name': 'alert.customFields', 'value': {'type': 'JsonInputValue', 'value': {}}, 'type': 'UnknownAttributeError', 'message': 'Unknown attribute alert.customFields: {"type":"JsonInputValue","value":{}}'}]]}

Complementary information

I printed out the jsonified alert in the code to show what I think the issue is; customFields is added by default but results in the server not accepting the data. When I downgrade to thehive4py version 1.5.0, the alert saves without errors.

@nadouani
Copy link
Contributor

TheHive <3.1 doesn't handle custom fields on alerts, so please stick with TheHive4py 1.5.0 if you use TheHive <3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants