…installation and data (#191843) (#193989)
# Backport
This will backport the following commits from `main` to `8.x`:
- [[Entity Analytics] New API endpoint to cleanup the risk engine
installation and data
(#191843)](#191843)
<!--- Backport version: 8.9.8 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)
<!--BACKPORT [{"author":{"name":"Abhishek
Bhatia","email":"117628830+abhishekbhatia1710@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-25T11:35:24Z","message":"[Entity
Analytics] New API endpoint to cleanup the risk engine installation and
data (#191843)\n\n## Summary\r\n\r\n1. Create a new public API endpoint
:
`DELETE\r\n/api/risk_score/engine/dangerously_delete_data`\r\n\r\n\r\n##
Test cases Result\r\n\r\n```\r\n PASS
x-pack/plugins/security_solution/server/lib/entity_analytics/risk_engine/routes/delete.test.ts
(7.017 s)\r\n risk engine cleanup route\r\n invokes the risk engine
cleanup route\r\n ✓ should call the router with the correct route and
handler (71 ms)\r\n ✓ returns a 200 when cleanup is successful (64
ms)\r\n ✓ returns a 500 when cleanup is unsuccessful (57 ms)\r\n ✓
returns a 500 when cleanup is unsuccessful with multiple errors (53
ms)\r\n when task manager is unavailable\r\n ✓ returns a 400 when task
manager is unavailable (55 ms)\r\n when user does not have the required
privileges\r\n ✓ returns a 403 when user does not have the required
privileges (88 ms)\r\n```\r\n\r\n\r\n### API Responses\r\n\r\n## When
multiple errors encountered\r\n```\r\n{\r\n \"risk_engine_cleanup\":
false,\r\n \"errors\": [\r\n {\r\n \"seq\": 1,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: Transform with id
[risk_score_latest_transform_default] could not be found\"\r\n },\r\n
{\r\n \"seq\": 2,\r\n \"error\": \"index_not_found_exception\\n\\tRoot
causes:\\n\\t\\tindex_not_found_exception: no such index
[risk-score.risk-score-default]\"\r\n },\r\n {\r\n \"seq\": 3,\r\n
\"error\": \"index_template_missing_exception\\n\\tRoot
causes:\\n\\t\\tindex_template_missing_exception: index_template
[.risk-score.risk-score-default-index-template] missing\"\r\n },\r\n
{\r\n \"seq\": 4,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: .risk-score-mappings\"\r\n
}\r\n ],\r\n \"status_code\": 500\r\n}\r\n```\r\n\r\n##
Success\r\n\r\n```\r\n{\r\n \"risk_engine_cleanup\":
true\r\n}\r\n```\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]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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\r\n\r\n###
OpenAPI
spec\r\n\r\n\r\n\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"22f451b30df3f80974b73314c9db4c8f8a509789","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v9.0.0","Team:
SecuritySolution","backport:prev-minor","Feature:Entity
Analytics","Team:Entity
Analytics"],"number":191843,"url":"https://github.com/elastic/kibana/pull/191843","mergeCommit":{"message":"[Entity
Analytics] New API endpoint to cleanup the risk engine installation and
data (#191843)\n\n## Summary\r\n\r\n1. Create a new public API endpoint
:
`DELETE\r\n/api/risk_score/engine/dangerously_delete_data`\r\n\r\n\r\n##
Test cases Result\r\n\r\n```\r\n PASS
x-pack/plugins/security_solution/server/lib/entity_analytics/risk_engine/routes/delete.test.ts
(7.017 s)\r\n risk engine cleanup route\r\n invokes the risk engine
cleanup route\r\n ✓ should call the router with the correct route and
handler (71 ms)\r\n ✓ returns a 200 when cleanup is successful (64
ms)\r\n ✓ returns a 500 when cleanup is unsuccessful (57 ms)\r\n ✓
returns a 500 when cleanup is unsuccessful with multiple errors (53
ms)\r\n when task manager is unavailable\r\n ✓ returns a 400 when task
manager is unavailable (55 ms)\r\n when user does not have the required
privileges\r\n ✓ returns a 403 when user does not have the required
privileges (88 ms)\r\n```\r\n\r\n\r\n### API Responses\r\n\r\n## When
multiple errors encountered\r\n```\r\n{\r\n \"risk_engine_cleanup\":
false,\r\n \"errors\": [\r\n {\r\n \"seq\": 1,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: Transform with id
[risk_score_latest_transform_default] could not be found\"\r\n },\r\n
{\r\n \"seq\": 2,\r\n \"error\": \"index_not_found_exception\\n\\tRoot
causes:\\n\\t\\tindex_not_found_exception: no such index
[risk-score.risk-score-default]\"\r\n },\r\n {\r\n \"seq\": 3,\r\n
\"error\": \"index_template_missing_exception\\n\\tRoot
causes:\\n\\t\\tindex_template_missing_exception: index_template
[.risk-score.risk-score-default-index-template] missing\"\r\n },\r\n
{\r\n \"seq\": 4,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: .risk-score-mappings\"\r\n
}\r\n ],\r\n \"status_code\": 500\r\n}\r\n```\r\n\r\n##
Success\r\n\r\n```\r\n{\r\n \"risk_engine_cleanup\":
true\r\n}\r\n```\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]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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\r\n\r\n###
OpenAPI
spec\r\n\r\n\r\n\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"22f451b30df3f80974b73314c9db4c8f8a509789"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191843","number":191843,"mergeCommit":{"message":"[Entity
Analytics] New API endpoint to cleanup the risk engine installation and
data (#191843)\n\n## Summary\r\n\r\n1. Create a new public API endpoint
:
`DELETE\r\n/api/risk_score/engine/dangerously_delete_data`\r\n\r\n\r\n##
Test cases Result\r\n\r\n```\r\n PASS
x-pack/plugins/security_solution/server/lib/entity_analytics/risk_engine/routes/delete.test.ts
(7.017 s)\r\n risk engine cleanup route\r\n invokes the risk engine
cleanup route\r\n ✓ should call the router with the correct route and
handler (71 ms)\r\n ✓ returns a 200 when cleanup is successful (64
ms)\r\n ✓ returns a 500 when cleanup is unsuccessful (57 ms)\r\n ✓
returns a 500 when cleanup is unsuccessful with multiple errors (53
ms)\r\n when task manager is unavailable\r\n ✓ returns a 400 when task
manager is unavailable (55 ms)\r\n when user does not have the required
privileges\r\n ✓ returns a 403 when user does not have the required
privileges (88 ms)\r\n```\r\n\r\n\r\n### API Responses\r\n\r\n## When
multiple errors encountered\r\n```\r\n{\r\n \"risk_engine_cleanup\":
false,\r\n \"errors\": [\r\n {\r\n \"seq\": 1,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: Transform with id
[risk_score_latest_transform_default] could not be found\"\r\n },\r\n
{\r\n \"seq\": 2,\r\n \"error\": \"index_not_found_exception\\n\\tRoot
causes:\\n\\t\\tindex_not_found_exception: no such index
[risk-score.risk-score-default]\"\r\n },\r\n {\r\n \"seq\": 3,\r\n
\"error\": \"index_template_missing_exception\\n\\tRoot
causes:\\n\\t\\tindex_template_missing_exception: index_template
[.risk-score.risk-score-default-index-template] missing\"\r\n },\r\n
{\r\n \"seq\": 4,\r\n \"error\":
\"resource_not_found_exception\\n\\tRoot
causes:\\n\\t\\tresource_not_found_exception: .risk-score-mappings\"\r\n
}\r\n ],\r\n \"status_code\": 500\r\n}\r\n```\r\n\r\n##
Success\r\n\r\n```\r\n{\r\n \"risk_engine_cleanup\":
true\r\n}\r\n```\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]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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\r\n\r\n###
OpenAPI
spec\r\n\r\n\r\n\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"22f451b30df3f80974b73314c9db4c8f8a509789"}}]}]
BACKPORT-->
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
DELETE /api/risk_score/engine/dangerously_delete_dataTest cases Result
API Responses
When multiple errors encountered
Success
Checklist
Delete any items that are not applicable to this PR.
OpenAPI spec
For maintainers