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

[ResponseOps][Connectors] Allow to use POST method for get case information in case management webhook #197437

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Oct 23, 2024

Summary

Resolves #178074

This PR allows to use POST method and JSON payload for body for get case information in case management webhook.

Screenshot 2024-10-24 at 15 02 33

How to test

  • Create a case management webhook connector as per documentation
  • Use any public API which supports GET and POST methods
  • Use POST method for Get case information
  • Verify that it validates the URL and JSON payload correctly
  • Test the connector using Test tab
  • Create a rule with action using case management webhook connector
  • Verify alerts are generated and action executed without any errors

Checklist

Delete any items that are not applicable to this PR.

@js-jankisalvi js-jankisalvi self-assigned this Oct 23, 2024
@js-jankisalvi js-jankisalvi added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.17.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Actions/ConnectorsManagement Issues related to Connectors Management UX labels Oct 24, 2024
@js-jankisalvi js-jankisalvi marked this pull request as ready for review October 24, 2024 14:23
@js-jankisalvi js-jankisalvi requested a review from a team as a code owner October 24, 2024 14:23
@elasticmachine
Copy link
Contributor

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

@js-jankisalvi js-jankisalvi added v9.0.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 24, 2024
@adcoelho
Copy link
Contributor

The field now also allows PUT and PATCH requests but I think those might be by mistake.

Screenshot 2024-10-31 at 14 58 07

Copy link
Contributor

@Zacqary Zacqary left a comment

Choose a reason for hiding this comment

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

Looks mostly good, just need to limit the Get step to GET and POST

@js-jankisalvi
Copy link
Contributor Author

js-jankisalvi commented Nov 1, 2024

The field now also allows PUT and PATCH requests but I think those might be by mistake.

Previously used the same options in dropdown as create and update. But now changed to use only GET and POST

Screenshot 2024-11-01 at 10 18 12

@js-jankisalvi js-jankisalvi requested a review from Zacqary November 1, 2024 10:29
Copy link
Contributor

@Zacqary Zacqary left a comment

Choose a reason for hiding this comment

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

LGTM!

})
: null;

if (json !== null) {
Copy link
Contributor

@adcoelho adcoelho Nov 6, 2024

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
if (json !== null) {
if (getIncidentMethod === WebhookMethods.POST && json !== null) {

I'm not sure 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am checking this at line 120:

 const json = getIncidentMethod === WebhookMethods.POST && getIncidentJson 
   ? renderMustacheStringNoEscape() 
   : null

So json will be null if getIncidentMethod is not WebhookMethods.POST

@adcoelho
Copy link
Contributor

adcoelho commented Nov 6, 2024

I saw that you do validator: containsExternalIdForPost(getIncidentMethod) and was curious about the ansible API.

In the original enhancement request, the client uses Ansible, and a specific example is given.

We want to use Ansible, to retrieve the case information. Ansible only allows POST requests. it would look something like this:

POST https://ansible.domain/api/v2/job_templates/100/
{
"whateverKey": {{{external.system.id}}}
}

But then I checked the documentation for this api/v2/job_templates endpoint and it really doesn't seem to match the "retrieve case information" scenario. Check this out.

Make a POST request to this resource with the following job template fields to create a new job template associated with this organization.

I don't know what a job template is but it doesn't feel like it matches the view case scenario 😆

Copy link
Contributor

@adcoelho adcoelho left a comment

Choose a reason for hiding this comment

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

LGTM! I left some small comments but the only thing I find more important is containsExternalIdForPost i'd be up for removing it wdyt?

Ah and also the comment about the original feature request. I hope this fixes it for them but I dunno if this isn't a case of misconfiguring the connector :D

@js-jankisalvi
Copy link
Contributor Author

But then I checked the documentation for this api/v2/job_templates endpoint and it really doesn't seem to match the "retrieve case information" scenario. Check this out.

Agree, The docs does not show any POST method to get job templates information. But using a post to get data is possible with some APIs. So I think it's a good option to provide.

I don't know what a job template is but it doesn't feel like it matches the view case scenario 😆

Do you think we should ask them? @cnasikas

@cnasikas
Copy link
Member

cnasikas commented Nov 7, 2024

But then I checked the documentation for this api/v2/job_templates endpoint and it really doesn't seem to match the "retrieve case information" scenario. Check this out.

Agree, The docs does not show any POST method to get job templates information. But using a post to get data is possible with some APIs. So I think it's a good option to provide.

I don't know what a job template is but it doesn't feel like it matches the view case scenario 😆

Do you think we should ask them? @cnasikas

I also agree. We should go with the feature either way as it is a valid scenario.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
stackConnectors 681.3KB 686.1KB +4.7KB

History

cc @js-jankisalvi

@js-jankisalvi js-jankisalvi merged commit d81d071 into elastic:main Nov 7, 2024
22 checks passed
@js-jankisalvi js-jankisalvi deleted the case-management-webhook-post-case-info branch November 7, 2024 12:44
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11723252200

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 7, 2024
…mation in case management webhook (elastic#197437)

## Summary

Resolves elastic#178074

This PR allows to use POST method and JSON payload for body for get case
information in case management webhook.

<img width="1279" alt="Screenshot 2024-10-24 at 15 02 33"
src="https://github.com/user-attachments/assets/aaabc5b8-cd9e-46d6-aab8-85a27731bd88">

### How to test
- Create a case management webhook connector [as per
documentation](https://www.elastic.co/guide/en/kibana/master/cases-webhook-action-type.html)
- Use any public API which supports GET and POST methods
- Use POST method for Get case information
- Verify that it validates the URL and JSON payload correctly
- Test the connector using Test tab
- Create a rule with action using case management webhook connector
- Verify alerts are generated and action executed without any errors

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))

(cherry picked from commit d81d071)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 7, 2024
… information in case management webhook (#197437) (#199307)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Connectors] Allow to use POST method for get case
information in case management webhook
(#197437)](#197437)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Janki
Salvi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-07T12:44:54Z","message":"[ResponseOps][Connectors]
Allow to use POST method for get case information in case management
webhook (#197437)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/178074\r\n\r\nThis PR allows to
use POST method and JSON payload for body for get case\r\ninformation in
case management webhook.\r\n\r\n<img width=\"1279\" alt=\"Screenshot
2024-10-24 at 15 02
33\"\r\nsrc=\"https://github.com/user-attachments/assets/aaabc5b8-cd9e-46d6-aab8-85a27731bd88\">\r\n\r\n###
How to test\r\n- Create a case management webhook connector [as
per\r\ndocumentation](https://www.elastic.co/guide/en/kibana/master/cases-webhook-action-type.html)\r\n-
Use any public API which supports GET and POST methods \r\n- Use POST
method for Get case information\r\n- Verify that it validates the URL
and JSON payload correctly \r\n- Test the connector using Test tab\r\n-
Create a rule with action using case management webhook connector\r\n-
Verify alerts are generated and action executed without any
errors\r\n\r\n### Checklist\r\n\r\nDelete any items that are not
applicable to this PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard
accessibility](https://webaim.org/techniques/keyboard/))","sha":"d81d0716a7007132d4a8210d1739e3f38a2c8cf9","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","Feature:Actions/ConnectorsManagement","backport:prev-minor","v8.17.0"],"title":"[ResponseOps][Connectors]
Allow to use POST method for get case information in case management
webhook","number":197437,"url":"https://github.com/elastic/kibana/pull/197437","mergeCommit":{"message":"[ResponseOps][Connectors]
Allow to use POST method for get case information in case management
webhook (#197437)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/178074\r\n\r\nThis PR allows to
use POST method and JSON payload for body for get case\r\ninformation in
case management webhook.\r\n\r\n<img width=\"1279\" alt=\"Screenshot
2024-10-24 at 15 02
33\"\r\nsrc=\"https://github.com/user-attachments/assets/aaabc5b8-cd9e-46d6-aab8-85a27731bd88\">\r\n\r\n###
How to test\r\n- Create a case management webhook connector [as
per\r\ndocumentation](https://www.elastic.co/guide/en/kibana/master/cases-webhook-action-type.html)\r\n-
Use any public API which supports GET and POST methods \r\n- Use POST
method for Get case information\r\n- Verify that it validates the URL
and JSON payload correctly \r\n- Test the connector using Test tab\r\n-
Create a rule with action using case management webhook connector\r\n-
Verify alerts are generated and action executed without any
errors\r\n\r\n### Checklist\r\n\r\nDelete any items that are not
applicable to this PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard
accessibility](https://webaim.org/techniques/keyboard/))","sha":"d81d0716a7007132d4a8210d1739e3f38a2c8cf9"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197437","number":197437,"mergeCommit":{"message":"[ResponseOps][Connectors]
Allow to use POST method for get case information in case management
webhook (#197437)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/178074\r\n\r\nThis PR allows to
use POST method and JSON payload for body for get case\r\ninformation in
case management webhook.\r\n\r\n<img width=\"1279\" alt=\"Screenshot
2024-10-24 at 15 02
33\"\r\nsrc=\"https://github.com/user-attachments/assets/aaabc5b8-cd9e-46d6-aab8-85a27731bd88\">\r\n\r\n###
How to test\r\n- Create a case management webhook connector [as
per\r\ndocumentation](https://www.elastic.co/guide/en/kibana/master/cases-webhook-action-type.html)\r\n-
Use any public API which supports GET and POST methods \r\n- Use POST
method for Get case information\r\n- Verify that it validates the URL
and JSON payload correctly \r\n- Test the connector using Test tab\r\n-
Create a rule with action using case management webhook connector\r\n-
Verify alerts are generated and action executed without any
errors\r\n\r\n### Checklist\r\n\r\nDelete any items that are not
applicable to this PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard
accessibility](https://webaim.org/techniques/keyboard/))","sha":"d81d0716a7007132d4a8210d1739e3f38a2c8cf9"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Janki Salvi <[email protected]>
mbondyra pushed a commit to mbondyra/kibana that referenced this pull request Nov 8, 2024
…mation in case management webhook (elastic#197437)

## Summary

Resolves elastic#178074

This PR allows to use POST method and JSON payload for body for get case
information in case management webhook.

<img width="1279" alt="Screenshot 2024-10-24 at 15 02 33"
src="https://github.com/user-attachments/assets/aaabc5b8-cd9e-46d6-aab8-85a27731bd88">

### How to test
- Create a case management webhook connector [as per
documentation](https://www.elastic.co/guide/en/kibana/master/cases-webhook-action-type.html)
- Use any public API which supports GET and POST methods 
- Use POST method for Get case information
- Verify that it validates the URL and JSON payload correctly 
- Test the connector using Test tab
- Create a rule with action using case management webhook connector
- Verify alerts are generated and action executed without any errors

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Actions/ConnectorsManagement Issues related to Connectors Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

webhook – Case management | "Get case information" - ability to use a POST
6 participants