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

[Bug] TheHive V4 API Errors "Operation Not Permitted" and "Date format" #1496

Closed
graememeyer opened this issue Aug 26, 2020 · 2 comments
Closed
Assignees
Labels
bug TheHive4 TheHive4 related issues
Milestone

Comments

@graememeyer
Copy link

graememeyer commented Aug 26, 2020

[Bug] TheHive V4 API Errors "Operation Not Permitted" and "Date format"

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu 18 (Training VM)
OS version (client) Windows 10.
TheHive version / git hash 4.0
Package Type Training VM
Browser type & version N/A

Problem Description

"Operation not permitted" and invalid date format errors when posting to TheHive4 "Create Alert" API.

I'm using the training VMs for 3.4 and 4.0. A curl POST to the v4 VM gives me a date format error (below), and when you remove the date parameter you get an "Operation not permitted error".

Steps to Reproduce

TheHive4 Curl:
curl -X POST -H 'Authorization: Bearer 7ywJAe8sk9v0qCPjWF0ysrc7+Q6JouTR' -H 'Content-Type: application/json' http://thehive4.local:9000/api/alert -d '{"title": "Test Alert","description": "Created with curl via the API","type": "CurlTest","source": "API","sourceRef": "TA1","date": "1598453685000"}'
Result:
{"type":"AttributeCheckingError","message":"[Invalid format for date: FString(1598453685000), expected date (date)]","errors":[{"name":"date","format":"date","acceptedInput":["date"],"field":"FString(1598453685000)","type":"InvalidFormatAttributeError"}]}

TheHive4 Curl:
curl -X POST -H 'Authorization: Bearer 7ywJAe8sk9v0qCPjWF0ysrc7+Q6JouTR' -H 'Content-Type: application/json' http://thehive4.local:9000/api/alert -d '{"title": "Test Alert","description": "Created with curl via the API","type": "CurlTest","source": "API","sourceRef": "TA2"}'
Result:
{"type":"AuthorizationError","message":"Operation not permitted"}

TheHive3 Curl:
curl -X POST -H 'Authorization: Bearer SuGd5Aj4NNudH8unh5CpWLm4U/MYDeVc' -H 'Content-Type: application/json' http://thehive3.local:9000/api/alert -d '{"title": "Test Alert","description": "Created with curl via the API","type": "CurlTest","source": "API","sourceRef": "TA1","date": "1598453685000"}'
Result:
{"severity":2,"date":1598453685000,"_routing":"e88708eaf54e196b1826e24ac227bbcd","customFields":{},"_type":"alert","description":"Created with curl via the API","lastSyncDate":1598455169746,"source":"API","type":"CurlTest","follow":true,"title":"Test Alert","createdAt":1598455169743,"_parent":null,"createdBy":"admin","tlp":2,"_id":"e88708eaf54e196b1826e24ac227bbcd","id":"e88708eaf54e196b1826e24ac227bbcd","sourceRef":"TA2","_version":1,"artifacts":[],"status":"New"}

@graememeyer graememeyer added TheHive4 TheHive4 related issues bug labels Aug 26, 2020
@graememeyer graememeyer changed the title [Bug] [Bug] TheHive V4 API Errors "Operation Not Permitted" and "Date format" Aug 26, 2020
@To-om
Copy link
Contributor

To-om commented Sep 2, 2020

TheHive3 is too tolerant. Date format must be an integer (not a string).
For backward compatibility reason, I'll permit date as string.

Regarding your "Operation not permitted" issue, it occurs when the user doesn't have the "manageAlert" permission. If your user is in several organisations, you need to inform TheHive on which organisation the alert will be created. This can be done using "X-Organisation" HTTP header:

curl -X POST -H 'X-Organisation: MyOrganisationName' -H 'Authorization: Bearer 7ywJAe8sk9v0qCPjWF0ysrc7+Q6JouTR' -H 'Content-Type: application/json' http://thehive4.local:9000/api/alert -d '{"title": "Test Alert","description": "Created with curl via the API","type": "CurlTest","source": "API","sourceRef": "TA2"}'

To-om added a commit that referenced this issue Sep 2, 2020
@To-om To-om added this to the 4.0.1 milestone Sep 2, 2020
@To-om To-om closed this as completed Sep 2, 2020
@graememeyer
Copy link
Author

That's great feedback for both errors. Thank you! 🙏

To-om added a commit that referenced this issue Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug TheHive4 TheHive4 related issues
Projects
None yet
Development

No branches or pull requests

2 participants