-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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]Legacy actions are deleted when user tries to save a rule and the run action interval is slower than rule run interval #157462
Comments
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Note: occurring in older versions as well. |
…e a rule and the run action interval is slower than rule run interval (#160798) ## Summary Original ticket: #157462 With these changes we fix the legacy actions data loss (on migration) issue. One of the first steps of the migration we retrieve legacy actions and immediately delete them. Then we do validation which might throw an exception and all legacy actions will be lost in this case. As a solution we will do legacy actions validation before deleting them and throwing exception in case those are broken. This means that in case legacy action is broken user will need to export the rule, fix it manually and import it again. Or just re-create it from scratch. https://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d
…e a rule and the run action interval is slower than rule run interval (elastic#160798) ## Summary Original ticket: elastic#157462 With these changes we fix the legacy actions data loss (on migration) issue. One of the first steps of the migration we retrieve legacy actions and immediately delete them. Then we do validation which might throw an exception and all legacy actions will be lost in this case. As a solution we will do legacy actions validation before deleting them and throwing exception in case those are broken. This means that in case legacy action is broken user will need to export the rule, fix it manually and import it again. Or just re-create it from scratch. https://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d (cherry picked from commit 8ca90fb)
…e a rule and the run action interval is slower than rule run interval (elastic#160798) ## Summary Original ticket: elastic#157462 With these changes we fix the legacy actions data loss (on migration) issue. One of the first steps of the migration we retrieve legacy actions and immediately delete them. Then we do validation which might throw an exception and all legacy actions will be lost in this case. As a solution we will do legacy actions validation before deleting them and throwing exception in case those are broken. This means that in case legacy action is broken user will need to export the rule, fix it manually and import it again. Or just re-create it from scratch. https://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d
…to save a rule and the run action interval is slower than rule run interval (#160798) (#162779) # Backport This will backport the following commits from `main` to `8.9`: - [[Security Solution] Legacy actions are deleted when user tries to save a rule and the run action interval is slower than rule run interval (#160798)](#160798) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2023-07-31T09:51:38Z","message":"[Security Solution] Legacy actions are deleted when user tries to save a rule and the run action interval is slower than rule run interval (#160798)\n\n## Summary\r\n\r\nOriginal ticket: https://github.com/elastic/kibana/issues/157462\r\n\r\nWith these changes we fix the legacy actions data loss (on migration)\r\nissue. One of the first steps of the migration we retrieve legacy\r\nactions and immediately delete them. Then we do validation which might\r\nthrow an exception and all legacy actions will be lost in this case.\r\n\r\nAs a solution we will do legacy actions validation before deleting them\r\nand throwing exception in case those are broken. This means that in case\r\nlegacy action is broken user will need to export the rule, fix it\r\nmanually and import it again. Or just re-create it from scratch.\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d","sha":"8ca90fbfc3f5f201e12053d9675c41b0906b8f9e","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","Team: SecuritySolution","ci:cloud-deploy","Team:Detection Engine","v8.10.0","v8.9.1"],"number":160798,"url":"https://github.com/elastic/kibana/pull/160798","mergeCommit":{"message":"[Security Solution] Legacy actions are deleted when user tries to save a rule and the run action interval is slower than rule run interval (#160798)\n\n## Summary\r\n\r\nOriginal ticket: https://github.com/elastic/kibana/issues/157462\r\n\r\nWith these changes we fix the legacy actions data loss (on migration)\r\nissue. One of the first steps of the migration we retrieve legacy\r\nactions and immediately delete them. Then we do validation which might\r\nthrow an exception and all legacy actions will be lost in this case.\r\n\r\nAs a solution we will do legacy actions validation before deleting them\r\nand throwing exception in case those are broken. This means that in case\r\nlegacy action is broken user will need to export the rule, fix it\r\nmanually and import it again. Or just re-create it from scratch.\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d","sha":"8ca90fbfc3f5f201e12053d9675c41b0906b8f9e"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160798","number":160798,"mergeCommit":{"message":"[Security Solution] Legacy actions are deleted when user tries to save a rule and the run action interval is slower than rule run interval (#160798)\n\n## Summary\r\n\r\nOriginal ticket: https://github.com/elastic/kibana/issues/157462\r\n\r\nWith these changes we fix the legacy actions data loss (on migration)\r\nissue. One of the first steps of the migration we retrieve legacy\r\nactions and immediately delete them. Then we do validation which might\r\nthrow an exception and all legacy actions will be lost in this case.\r\n\r\nAs a solution we will do legacy actions validation before deleting them\r\nand throwing exception in case those are broken. This means that in case\r\nlegacy action is broken user will need to export the rule, fix it\r\nmanually and import it again. Or just re-create it from scratch.\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/2700761/a23f5d43-3758-4ab7-8e63-bd93016e338d","sha":"8ca90fbfc3f5f201e12053d9675c41b0906b8f9e"}},{"branch":"8.9","label":"v8.9.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
This fix has been merged into |
we have validated this issue by upgrading the 8.8.0 to 8.9.0 and found that issue is still occuring . While duplicate the rule with legacy rule action there are error ❌ Moreover we are not able to add the legacy action directly on 8.9.1 directly as PR steps are not running on the 8.9 rule. Build Details:
Additional observation of 8.9.1 Direct Testing we are following this pr steps to add legacy rule action ( in our case it was slack ) to rule present on 8.9.1 by running the post_legacy action.js <alert_id> but on 8.9.1 this script is returning error and not adding the rule action to target rule id passed along the script. tried with different rule ID Screen-Cast Rules.-.Kibana.Mozilla.Firefox.2023-08-11.17-06-38.mp4 |
@e40pud may you please help @karanbirsingh-qasource to validate the fix? Thanks! |
@karanbirsingh-qasource would it be possible to validate by first creating a legacy action in 7.16 then upgrading to latest? I only ask this because even the API to create legacy actions does not fully mock out the actual behavior so the best way to test legacy actions stuff accurately is to go through the flow of creating an action in <7.16 (before the new action migration code was introduced) and then upgrading. |
@karanbirsingh-qasource It is expected that duplication does not work with the broken legacy actions. Since action is not valid there is no good solution to fix it programatically on migration. Thus, we prevent user from migrating legacy actions in such cases to avoid data loss. Any operation that triggers legacy action migration (enable, disable, rule update, rule duplicate etc.) will throw an exception about invalid actions state. |
I will have a look why scripts to create legacy actions don't work in 8.9, but as @yctercero mentioned we can always create invalid legacy actions in older kibana and upgrade it to latest. |
thanks @yctercero for the comment sure we have checked the issue by upgrading from 7.16.0 to 8.9.1 ( we have to upgrade 7.16.0 first to 7.17.2 in order to upgrade to 8.9.1) and found the issue still occuring we are getting Build Details:
Observations:
Rules.-.Kibana.Mozilla.Firefox.2023-08-15.11-31-59.mp4
Console.-.Dev.Tools.-.Elastic.Mozilla.Firefox.Private.Browsing.2023-08-15.12-01-16.mp4
Rules.-.Kibana.Mozilla.Firefox.Private.Browsing.2023-08-15.12-01-45.mp4Rule Enable Error Logs
Editing Rule Error Logs
|
All the described behaviours above are expected. The main goal is to avoid data loss (legacy actions) during the migration. Thus, we throw an exception when user tries to migrate the rule with invalid legacy actions to prevent legacy actions to be removed. There will be a known issue added to security docs elastic/security-docs#3572 saying that |
ok @e40pud thanks for looking into the observation. so can we close this issue or not and track other issue separately. |
I would say yes. Thank you for performing thorough testing! |
Describe the bug:
Kibana/Elasticsearch Stack version:
Original install method (e.g. download page, yum, from source, etc.):
Functional Area (e.g. Endpoint management, timelines, resolver, etc.):
Initial setup
User must have a rule with one legacy action ( rule run interval should be 5 minutes or more) and a legacy action injected using this PR steps
Steps to reproduce:
Current behavior:
Expected behavior:
Screen recording:
REC-20230512113308.mp4
Any additional context (logs, chat logs, magical formulas, etc.):
-This bug will eventually be fixed once this task is done: #155502
The text was updated successfully, but these errors were encountered: