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

Add support of custom fields to the case model #39

Closed
nadouani opened this issue Sep 20, 2017 · 2 comments
Closed

Add support of custom fields to the case model #39

nadouani opened this issue Sep 20, 2017 · 2 comments
Assignees
Milestone

Comments

@nadouani
Copy link
Contributor

nadouani commented Sep 20, 2017

Request Type

Feature Request

Problem Description

TheHive added support to case custom fields, but TheHive4Py didn't allow setting this attribute. We need to enhance the Case model class to support providing custom fields

The custom fields should also be available on the CaseTemplate class

@nadouani nadouani self-assigned this Sep 20, 2017
@nadouani nadouani added this to the 1.4.0 milestone Sep 20, 2017
@billmurrin
Copy link

I just did this here but didn't issue a PR since it might include another merge for the get_task_logs method that I have the open PR for. If you can use this, please feel free.

@nadouani
Copy link
Contributor Author

Thanks @billmurrin. The issue with custom fields is the required structure. In a case, we need to provide custom fields data with the following format:

{
    "booleanField": {
        "boolean": true,
        "order": 0
    },
    "businessImpact": {
        "order": 1,
        "string": "HIGH"
    },
    "cvss": {
        "number": 9,
        "order": 3
    },
    "occurDate": {
        "date": 1512054889000,
        "order": 2
    }
}

We need to keep the order (used to display the fields on the right order, and the field's type.

I'll create a helper class to allow easy creation of custom fields. Example:

# Prepare the custom fields
customFields = CustomFieldHelper()\
    .add_boolean('booleanField', True)\
    .add_string('businessImpact', 'HIGH')\
    .add_date('occurDate', int(time.time())*1000)\
    .add_number('cvss', 9)\
    .build()

case = Case(title='From TheHive4Py',            
            description='N/A',
            customFields=customFields)

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

No branches or pull requests

2 participants