Skip to content

[SIEM][CASE] ServiceNow executor#58894

Merged
cnasikas merged 45 commits intoelastic:masterfrom
cnasikas:servicenow_api
Mar 11, 2020
Merged

[SIEM][CASE] ServiceNow executor#58894
cnasikas merged 45 commits intoelastic:masterfrom
cnasikas:servicenow_api

Conversation

@cnasikas
Copy link
Copy Markdown
Member

@cnasikas cnasikas commented Feb 28, 2020

Summary

This PR implements a ServiceNow connector where one can create or update incidents to ServiceNow. The action is needed for the Case Management System.

Usage

Create action:

Create a ServiceNow action. See README for more information about the parameters.

Endpoint: api/action
Method: POST

Payload:

{
    "name": "ServiceNow",
    "actionTypeId": ".servicenow",
    "secrets": {
        "username": "username",
        "password": "password"
    },
    "config": {
        "apiUrl": "https://<instance>.service-now.com",
        "casesConfiguration": {
            "mapping": [
                {
                    "source": "title",
                    "target": "short_description",
                    "actionType": "nothing"
                },
                {
                    "source": "description",
                    "target": "description",
                    "actionType": "nothing"
                },
                {
                    "source": "comments",
                    "target": "comments",
                    "actionType": "nothing"
                }
            ]
        }
    }
}

Response:

{
    "id": "6dfba6ca-8efa-442c-9ab8-d91a50e5b430",
    "actionTypeId": ".servicenow",
    "name": "ServiceNow",
    "config": {
        "apiUrl": "https://<instance>.service-now.com",
        "casesConfiguration": {
            "mapping": [
                {
                    "source": "title",
                    "target": "short_description",
                    "actionType": "nothing"
                },
                {
                    "source": "description",
                    "target": "description",
                    "actionType": "nothing"
                },
                {
                    "source": "comments",
                    "target": "comments",
                    "actionType": "nothing"
                }
            ]
        }
    }
}

Create an incident:

Create an incident to ServiceNow. When the incidentId attribute is not in params the executor will create the incident.

Endpoint: api/action/<action_id>/_execute
Method: POST

Payload:

{
    "params": {
    	"caseId": "d4387ac5-0899-4dc2-bbfa-0dd605c934aa",
        "title": "A new incident",
        "description": "A description",
        "comments": [
            {
                "commentId": "b5b4c4d0-574e-11ea-9e2e-21b90f8a9631",
                "version": "WzU3LDFd",
                "comment": "A comment"
            }
        ]
    }
}

Response

{
    "status": "ok",
    "actionId": "f631be57-0a59-4e28-8833-16fc3b309374",
    "data": {
        "incidentId": "7d7aad9c072fc0100e48fbbf7c1ed0c2",
        "number": "INC0010044",
        "pushedDate": "2020-03-10T13:02:59.000Z",
        "comments": [
            {
                "commentId": "b5b4c4d0-574e-11ea-9e2e-21b90f8a9631",
                "pushedDate": "2020-03-10T13:03:00.000Z"
            }
        ]
    }
}

Update an incident:

Update an incident to ServiceNow. When the incidentId attribute is in params the executor will update the incident.

Endpoint: api/action/<action_id>/_execute
Method: POST

Payload:

{
    "params": {
    	"caseId": "d4387ac5-0899-4dc2-bbfa-0dd605c934aa",
        "incidentId": "7d7aad9c072fc0100e48fbbf7c1ed0c2"
        "title": "A new incident",
        "description": "A description",
        "comments": [
            {
                "commentId": "b5b4c4d0-574e-11ea-9e2e-21b90f8a9631",
                "version": "WzU3LDFd",
                "comment": "A comment"
            }
        ]
    }
}

Response

{
    "status": "ok",
    "actionId": "f631be57-0a59-4e28-8833-16fc3b309374",
    "data": {
        "incidentId": "7d7aad9c072fc0100e48fbbf7c1ed0c2",
        "number": "INC0010044",
        "pushedDate": "2020-03-10T13:02:59.000Z",
        "comments": [
            {
                "commentId": "b5b4c4d0-574e-11ea-9e2e-21b90f8a9631",
                "pushedDate": "2020-03-10T13:03:00.000Z"
            }
        ]
    }
}

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cnasikas cnasikas added WIP Work in progress Team:SIEM v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.7.0 in progress Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// labels Feb 28, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/siem (Team:SIEM)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@cnasikas cnasikas changed the title [SIEM][CASE] ServiceNow executor [SIEM][CASE][skip-ci] ServiceNow executor Feb 28, 2020
@cnasikas cnasikas force-pushed the servicenow_api branch 3 times, most recently from 08482fa to 42cff02 Compare March 4, 2020 19:22
@cnasikas
Copy link
Copy Markdown
Member Author

cnasikas commented Mar 9, 2020

@elasticmachine merge upstream

@peterschretlen
Copy link
Copy Markdown
Contributor

  • I noticed we don't have any docs regarding ServiceNow within plugins/actions/README.md. @peterschretlen I know you're converting those to asciidoc. Is the README still a place we should add documentation for ServiceNow or you've started something already?

Adding to the README would be great. If there's a README description I will take care of the asciidoc conversion when the time comes.

Copy link
Copy Markdown
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cnasikas
Copy link
Copy Markdown
Member Author

cnasikas commented Mar 10, 2020

@mikecote @YulNaumenko Thanks a lot for your review. I did a few small changes to the logic of the executor, especially how we treat comments. @mikecote I made the changes you requested.

Copy link
Copy Markdown
Contributor

@mikecote mikecote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 just one comment about the README.

@cnasikas cnasikas merged commit e6327d3 into elastic:master Mar 11, 2020
cnasikas added a commit to cnasikas/kibana that referenced this pull request Mar 11, 2020
* Refactor structure

* Init ServiceNow class

* Add constants

* Add configuration scheme

* Refactor configuration schema

* Refactor parameters schema

* Create new types

* Add supported source fields

* Create helpers

* Create ServiceNow lib

* Push incident

* Declare private methods

* Create UpdateIncident type

* Create updateIncident method

* Create executor actions

* Refactor response

* Test helpers

* Remove unnecessary validation

* Fix validation errors

* Throw error for unsupported actions

* Create mock incident

* Test executor

* Test ServiceNow lib

* Convert to camelCase

* Remove caller_id

* Refactor helpers

* Refactor schema

* Remove executorAction

* Test action handlers

* Refactor tests

* Create and update comments

* Remove closure option & change attribute name

* Fix tests

* Change lib structure

* Validate empty mapping

* Fix functional tests

* Fix type

* Change API to only add comments through incident's API

* Add instruction to README

* Change API version

* Test

* Test simulator

* Fix version on tests

* Remove SIEM reference in README
cnasikas added a commit that referenced this pull request Mar 11, 2020
* Refactor structure

* Init ServiceNow class

* Add constants

* Add configuration scheme

* Refactor configuration schema

* Refactor parameters schema

* Create new types

* Add supported source fields

* Create helpers

* Create ServiceNow lib

* Push incident

* Declare private methods

* Create UpdateIncident type

* Create updateIncident method

* Create executor actions

* Refactor response

* Test helpers

* Remove unnecessary validation

* Fix validation errors

* Throw error for unsupported actions

* Create mock incident

* Test executor

* Test ServiceNow lib

* Convert to camelCase

* Remove caller_id

* Refactor helpers

* Refactor schema

* Remove executorAction

* Test action handlers

* Refactor tests

* Create and update comments

* Remove closure option & change attribute name

* Fix tests

* Change lib structure

* Validate empty mapping

* Fix functional tests

* Fix type

* Change API to only add comments through incident's API

* Add instruction to README

* Change API version

* Test

* Test simulator

* Fix version on tests

* Remove SIEM reference in README
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mikecote mikecote added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Team:SIEM v7.7.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants