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

Comments

Projects
None yet
2 participants
@nadouani
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

This comment has been minimized.

Show comment
Hide comment
@billmurrin

billmurrin Sep 20, 2017

Contributor

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.

Contributor

billmurrin commented Sep 20, 2017

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

This comment has been minimized.

Show comment
Hide comment
@nadouani

nadouani Nov 30, 2017

Contributor

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)
Contributor

nadouani commented Nov 30, 2017

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