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

[Security Solution] Webhook - Case Management Connector #131762

Merged
merged 122 commits into from
Jul 26, 2022

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented May 6, 2022

Webhook - Case Management Connector

Webhook - Case Management is a new connector that allows user to add any third party case management system and have it work within the Cases app. This connector is available in Cases, Stack Management > Connectors, but is not available in Rule Actions. It requires the user to fill out endpoint and JSON data to send to the third party system. The endpoints covered are create incident, get incident, update incident, and create comment. The only non-required endpoint is create comment.

Create Connector

create

Connector Validation

validation

Connector Test

test

Case Flow

flow

Connector Test - No Comments

no_comment_test

Case Flow - No Comments

no_comments

Test credentials

Jira
ServiceNow

Fields

The configuration for each connector requires the following fields (* indicates required):

  • Connector name*
    • name of connector
    • ex: Jira Webhook
  • Require authentication*
    • If true, a username and password for login type authentication must be provided.
  • Username (only required if require authentication is true*)
    • Username for HTTP basic authentication.
  • Password (only required if require authentication is true*)
    • Password for HTTP basic authentication.
  • Headers
    • A set of key-value pairs sent as headers with the request
    • For given examples, content-type: application/json is needed
  • Create Incident Method
    • Rest API Method to create incident in third party system
    • ex: POST
  • Create Incident URL*
    • Rest API URL to create incident in third party system
    • ex: https://siem-kibana.atlassian.net/rest/api/2/issue
  • Create Incident Object*
    • JSON object to create incident (case.tags field not required)
    • ex:
      {
        "fields": {
          "labels": {{{case.tags}}},
          "summary": {{{case.title}}},
          "description": {{{case.description}}},
          "project":{"key":"ROC"},
          "issuetype":{"id":"10024"}
        }
      }
      
  • Create Incident Response Incident Key*
    • JSON key in create incident response that contains the external incident id
    • ex: id
  • Get Incident URL*
    • API URL to GET incident details JSON from external system.
    • ex: https://siem-kibana.atlassian.net/rest/api/2/issue/{{{external.system.id}}}
  • Get Incident Response External Title Key*
    • JSON key in get incident response that contains the external incident title
    • ex: key
  • Get Incident Response Created Date Key*
    • JSON key in get incident response that contains the date the incident was created.
    • ex: fields.created
  • Get Incident Response Updated Date Key*
    • JSON key in get incident response that contains the date the incident was updated.
    • ex: fields.updated
  • External Incident View URL*
    • URL to view incident in external system.
    • ex: https://siem-kibana.atlassian.net/browse/{{{external.system.title}}}
  • Update Incident Method
    • Rest API Method to update incident in third party system
    • ex: PUT
  • Update Incident URL*
    • API URL to update incident.
    • ex: https://siem-kibana.atlassian.net/rest/api/2/issue/{{{external.system.id}}}
  • Update Incident Object*
    • JSON object to update incident. (case.tags field not required)
    • ex:
      {
        "fields": {
          "labels": {{{case.tags}}},
          "summary": {{{case.title}}},
          "description": {{{case.description}}},
          "project":{"key":"ROC"},
          "issuetype":{"id":"10024"}
        }
      }
      
  • Create Comment Method
    • Rest API Method to update incident in third party system
    • ex: POST
  • Create Comment URL
    • API URL to add comment to incident.
    • ex: https://siem-kibana.atlassian.net/rest/api/2/issue/{{{external.system.id}}}/comment
  • Create Comment Object
    • JSON object to update incident
    • ex:
      {
        "body": {{{case.comment}}}
      }
      

Links

RFC: https://docs.google.com/document/d/16qvY3TmjAiokubAABBf_CVZNH9lFAwU9UXYdfW1M7L0/edit?usp=sharing
Epic: #124687
Customer enhancement requests: https://github.com/elastic/enhancements/issues/15899, https://github.com/elastic/enhancements/issues/14938

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #1 / Alerts timeline Privileges: can crud "before each" hook for "should allow a user with crud privileges to attach alerts to cases"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases 489 492 +3
triggersActionsUi 575 591 +16
total +19

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
actions 259 261 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 355.6KB 358.2KB +2.6KB
triggersActionsUi 927.8KB 1014.0KB +86.1KB
total +88.7KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 122.3KB 122.4KB +121.0B
triggersActionsUi 90.6KB 91.6KB +1.0KB
total +1.2KB
Unknown metric groups

API count

id before after diff
actions 264 266 +2

async chunk count

id before after diff
cases 15 16 +1
triggersActionsUi 92 95 +3
total +4

ESLint disabled in files

id before after diff
triggersActionsUi 4 5 +1

ESLint disabled line counts

id before after diff
cases 73 74 +1
triggersActionsUi 184 188 +4
total +5

Total ESLint disabled count

id before after diff
cases 89 90 +1
triggersActionsUi 188 193 +5
total +6

History

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

Copy link
Contributor

@angorayc angorayc left a comment

Choose a reason for hiding this comment

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

Thanks Steph, followed the steps and ran it locally, all worked as expected!

@stephmilovic stephmilovic requested review from jonathan-buttner and cnasikas and removed request for mikecote and cnasikas July 26, 2022 13:38
Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

Great work Steph!

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Great work Steph! Thank you for addressing our feedback. Some items can be done in another PR. Could you please open an issue for that:

  • The method and the URL are not properly aligned in step 4:

Screenshot 2022-07-25 at 5 44 15 PM

  • Docs
  • Add more unit tests for React components and utility functions
  • Remove real URLs from tests
  • By introducing the isExperimental flag we show the experimental badge. There are some parts in the framework that do not show the experimental flag even though the flag is set. This is a bug in the framework. For example the edit connector flyout or in the connector add flyout

Screenshot 2022-07-26 at 1 16 28 PM

'{"fields":{"title":{{{case.title}}},"description":{{{case.description}}},"tags":{{{case.tags}}},"project":{"key":"ROC"},"issuetype":{"id":"10024"}}}',
createIncidentMethod: CasesWebhookMethods.POST,
createIncidentResponseKey: 'id',
createIncidentUrl: 'https://siem-kibana.atlassian.net/rest/api/2/issue',
Copy link
Member

Choose a reason for hiding this comment

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

We should not commit real URLs in tests.

@@ -85,9 +96,17 @@ const FlyoutHeaderComponent: React.FC<{
</EuiTitle>
)}
</EuiFlexItem>
{actionTypeName && isExperimental && (
Copy link
Member

Choose a reason for hiding this comment

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

A unit test is missing for this case.

@@ -91,6 +93,7 @@ export const ActionTypeMenu = ({
const checkEnabledResult = checkActionTypeEnabled(item.actionType);
const card = (
<EuiCard
betaBadgeProps={item.isExperimental ? betaBadgeProps : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

A unit test is missing for this case

@stephmilovic stephmilovic merged commit 4f3e554 into elastic:main Jul 26, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 26, 2022
@MadameSheema MadameSheema deleted the cases_webhook branch July 26, 2022 16:10
@lcawl lcawl added the Feature:Actions/ConnectorTypes Issues related to specific Connector Types on the Actions Framework label Jul 28, 2022
@nastasha-solomon nastasha-solomon added the Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) label Aug 1, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed backport:skip This commit does not require backporting Feature:Actions/ConnectorsManagement Issues related to Connectors Management UX Feature:Actions/ConnectorTypes Issues related to specific Connector Types on the Actions Framework needs_docs release_note:feature Makes this part of the condensed release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.4.0
Projects
No open projects
Development

Successfully merging this pull request may close these issues.