-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
siem-detection-engine-rule-status migration could cause failed upgrade #116423
Comments
Pinging @elastic/security-solution (Team: SecuritySolution) |
Note: we also have a test harness for testing migrations https://docs.elastic.dev/kibana-dev-docs/tutorials/testing-plugins#integration-testing It's very similar to your existing e2e test except that it uses the import API instead of esArchiver, might not add much value to convert the existing tests but just an FYI |
@rudolf, that's a great catch! Thank you so much 🙏
Just curious - why theoretically? 🙂
I didn't know about it! Super helpful, thank you. Will take a closer look. |
This could only happen if there was a document with an |
Yeah the test harness should catch this specific bug. The harness basically just spins up Elasticsearch and Kibana like FTR would. You then supply outdated saved objects which it will import into Kibana/Elasticsearch using the Saved Objects Import API. When saved objects are imported we apply migrations to them so during this step we will exercise the migration logic. Because the migrated objects are written to Elasticsearch, if there's a field left after the migration for which there's no mapping it will cause this bug to surface. After importing, the test harness will use the Saved Objects export API to export the objects so that you test can assert that they have the right shape after the migration. One limitation is that your saved object type should be importable/exportable but I believe after 8.0 most types should already be importable/exportable. Another thing to be aware of is import/export hooks will be applied so if a type has these hooks it could change the data in a way that's not directly related to the saved object migration. |
I had a look at #112869 which is very similar, but in this case the I see comments that this saved object type is deprecated so maybe it's highly unlikely that we ever make any changes until we remove the whole thing but I just want to flag it. |
I also didn't know this test harness existed, so thanks for sharing @rudolf! 🙂
That said, this SO isn't exposed in the SOM UI, so we won't be able to leverage it here. We're planning to remove this SO entirely in early 8.x out in favor of leveraging the rule execution log, but good to know either way 👍.
Yeah I spoke to @FrankHassanabad about this during implementation and he mentioned he ended up keeping it around for certain compatibility reasons iirc, but noted that there shouldn't be any reason it couldn't be removed. There were less usages of |
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
…Id is not a string (#117962) ## Summary Resolves #116423, and adds an e2e test catching this behavior as we can't test via the migration test harness since the `siem-detection-engine-rule-status` SO isn't exposed within the SO Manager UI. Also adds note with regards to changes necessary once core issue #115153 is resolved. See https://github.com/elastic/kibana/pull/114585/files#r729620927. Note: existing `find_statuses`/`find_rules` integration tests will fail once fixed, so no additional tests necessary. ### Checklist Delete any items that are not applicable to this PR. - [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
…Id is not a string (elastic#117962) ## Summary Resolves elastic#116423, and adds an e2e test catching this behavior as we can't test via the migration test harness since the `siem-detection-engine-rule-status` SO isn't exposed within the SO Manager UI. Also adds note with regards to changes necessary once core issue elastic#115153 is resolved. See https://github.com/elastic/kibana/pull/114585/files#r729620927. Note: existing `find_statuses`/`find_rules` integration tests will fail once fixed, so no additional tests necessary. ### Checklist Delete any items that are not applicable to this PR. - [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
…Id is not a string (elastic#117962) ## Summary Resolves elastic#116423, and adds an e2e test catching this behavior as we can't test via the migration test harness since the `siem-detection-engine-rule-status` SO isn't exposed within the SO Manager UI. Also adds note with regards to changes necessary once core issue elastic#115153 is resolved. See https://github.com/elastic/kibana/pull/114585/files#r729620927. Note: existing `find_statuses`/`find_rules` integration tests will fail once fixed, so no additional tests necessary. ### Checklist Delete any items that are not applicable to this PR. - [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
…Id is not a string (#117962) (#118038) ## Summary Resolves #116423, and adds an e2e test catching this behavior as we can't test via the migration test harness since the `siem-detection-engine-rule-status` SO isn't exposed within the SO Manager UI. Also adds note with regards to changes necessary once core issue #115153 is resolved. See https://github.com/elastic/kibana/pull/114585/files#r729620927. Note: existing `find_statuses`/`find_rules` integration tests will fail once fixed, so no additional tests necessary. ### Checklist Delete any items that are not applicable to this PR. - [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 Co-authored-by: Garrett Spong <[email protected]>
…n alertId is not a string (#117962) (#118040) * [SecuritySolution][Detections] Fixes rule status migration when alertId is not a string (#117962) ## Summary Resolves #116423, and adds an e2e test catching this behavior as we can't test via the migration test harness since the `siem-detection-engine-rule-status` SO isn't exposed within the SO Manager UI. Also adds note with regards to changes necessary once core issue #115153 is resolved. See https://github.com/elastic/kibana/pull/114585/files#r729620927. Note: existing `find_statuses`/`find_rules` integration tests will fail once fixed, so no additional tests necessary. ### Checklist Delete any items that are not applicable to this PR. - [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 * Fixes typecheck in test Co-authored-by: Garrett Spong <[email protected]> Co-authored-by: Garrett Spong <[email protected]>
If
alertId
is not a string we don't remove thealertId
https://github.com/elastic/kibana/blob/7.16/x-pack/plugins/security_solution/server/lib/detection_engine/rules/legacy_rule_status/legacy_migrations.ts#L55
However, since there is no mapping for
alertId
this could theoretically cause the migration to fail withmapping set to strict, dynamic introduction of [alertId] within [siem-detection-engine-rule-status] is not allowed
Related #114585
A more defensive approach would be to always remove alertId:
(Sorry for missing this during our code review of the PR 😅 )
The text was updated successfully, but these errors were encountered: