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] Custom Field Order ignored #1552

Closed
s-knauer opened this issue Sep 28, 2020 · 2 comments
Closed

[Bug] Custom Field Order ignored #1552

s-knauer opened this issue Sep 28, 2020 · 2 comments
Assignees
Labels
bug TheHive4 TheHive4 related issues
Milestone

Comments

@s-knauer
Copy link

The Sequence of the Custom Fields is ignored when using TheHive4py to create new alerts.

Request Type

Bug

Work Environment

Question Answer
OS version (server) Debian 10
OS version (client) Debian 10
TheHive version 4
Package Type DEB
Browser type & version Firefox 68

Problem Description

The sequence of custom fields is still not preserved in alert and case creation for TH4.

I set the order in the case template and checked the (equivalent) order being in the CustomFieldhelper.fields dictionary when using thehive4py for uploading a new alert (which should be imported as a case via the case template.)

The dictionary shows: {'fieldname' : {'order': 0, 'string': 'ABCD'}, 'fieldname2': {'order': 1, 'string': 'EFGH'} .... }.
The template also states the correct sorting for Custom Fields: Fieldname, then fieldname2 and so on.
But the display in the webinterface is randomised. In the alert as well as in the case.

When i create an empty case via the webinterface, the fields have the right order. But when using real data for creating an alert, the ordering is ignored.

Steps to Reproduce

  1. Create a Casetemplate "CT1" with CustomFields "A" and "B" in the Order A before B
  2. Create an Alert via TH4Py using the CustomFieldHelper to create Custom Fields A and B in that order:

alert = Alert(title="title", tpl=2, tags="[tag"], description="description", type="type", source="source", sourceRef=str(uuid.uuid4())[0:6], artifacts=[list of predefined artifacts], caseTemplate= "CT1", customFields=CustomFieldHelper().add_string(name='A', value='xyz').add_string(name='B', value='zyx').build())

response = TheHiveAPI(url, apikey).create_alert(alert)

You can check the resulting dictionary before uploading showing: {'A':{ 'order':0, 'string':'xyz'}, 'B':{'order':1, 'string':'zyx'}}

  1. Look at the alert in the webinterface. Now sometimes Field A comes before B and sometimes it does not.

  2. Making a Case from that alert using the template does not fix the error. The sequence from the alert is preserved.

  3. When creating an empty case via the webinterface, A always comes before B.

Complementary information

I already read some similar complaints from people using curl instead of th4py and the hints given by the deps, that naming custom fields during creation overwrites the fields preconfigured via the template. This maybe explaines why the ordering works when creating an empty case. But the ordering (which is clearly seen in the dictionary during upload) seemes to be discarded at some point.

Thanks for your attention and great work!

@s-knauer s-knauer added TheHive4 TheHive4 related issues bug labels Sep 28, 2020
@To-om To-om self-assigned this Nov 3, 2020
@rriclet rriclet self-assigned this Nov 4, 2020
rriclet added a commit that referenced this issue Nov 5, 2020
rriclet added a commit that referenced this issue Nov 6, 2020
rriclet added a commit that referenced this issue Nov 6, 2020
@rriclet rriclet added this to the 4.0.1 milestone Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
To-om pushed a commit that referenced this issue Nov 6, 2020
@To-om To-om closed this as completed Nov 6, 2020
@nadouani nadouani reopened this Nov 11, 2020
@nadouani
Copy link
Contributor

Reopening the issue because I can still see the issue:

  • Patching a case with a body like {"customFields.csirts":{"integer":null,"order":1}} returns a case where customFields attribute has all the order fields set to null
  • Getting the case object, returns customFields attribute with order:0

I don't know if the issue is related to saving the order correctly or getting is correctly.

@nadouani
Copy link
Contributor

To reproduce:

  • open a new case or and existing one
  • add custom fields to it (the front end computes the order based on the number of the existing custom fields in the case: max(order)+1 )
  • refresh the page
  • check the order of custom fields

@To-om To-om closed this as completed Nov 12, 2020
To-om pushed a commit that referenced this issue Nov 13, 2020
To-om pushed a commit that referenced this issue Nov 13, 2020
To-om pushed a commit that referenced this issue Nov 13, 2020
To-om pushed 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

4 participants