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][Rules Management] Fix importing rules with connectors from one space to another #193471

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marshallmain
Copy link
Contributor

Summary

Fixes a bug where importing a rule fails with a connector into a space where (1) the connector already exists, and (2) the existing connector was exported and re-imported from another space. The import logic in this scenario effectively tries to convert the action ID on the rule import twice. The second conversion attempt tries to use the old action ID to look up the correct new action ID in a map, however, in this test scenario the action ID has already been updated by legacy SO ID migration logic and there is no map entry with the new ID as a key. The result is that the second attempt sets the action ID to undefined, resulting in an import failure.
image

Repro Steps

  1. Download the export file below and change the extension back to .ndjson from .json (github does not allow .ndjson files
    rules_export.json
  2. Import the rule and connector into a space (default is fine)
  3. Create a new space
  4. Import the rule and connector into the new space
  5. Import the rule and connector into the new space again, but check the Overwrite existing connectors with conflicting action "id" box. Observe the failure.

Integration test forthcoming

@elasticmachine
Copy link
Contributor

elasticmachine commented Sep 19, 2024

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 19, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #2 / importRuleActionConnectors should import multiple rules with connectors successfully even if they were exported from different namespaces by generating destinationIds and replace the old actionIds with them
  • [job] [logs] Jest Tests #2 / importRuleActionConnectors should import multiple rules with connectors successfully even if they were exported from different namespaces by generating destinationIds and replace the old actionIds with them
  • [job] [logs] Jest Tests #2 / importRuleActionConnectors should import one rule with connector successfully even if it was exported from different namespaces by generating destinationId and replace the old actionId with it
  • [job] [logs] Jest Tests #2 / importRuleActionConnectors should import one rule with connector successfully even if it was exported from different namespaces by generating destinationId and replace the old actionId with it
  • [job] [logs] FTR Configs #104 / Rules Management - Rule import export API @ess @serverless @skipInServerlessMKI import_rules importing rules with an index @skipInServerless migrate pre-8.0 action connector ids should be imported into the non-default space importing a non-default-space 7.16 rule with a connector made in the non-default space should result in a 200
  • [job] [logs] FTR Configs #104 / Rules Management - Rule import export API @ess @serverless @skipInServerlessMKI import_rules importing rules with an index @skipInServerless migrate pre-8.0 action connector ids should be imported into the non-default space importing a non-default-space 7.16 rule with a connector made in the non-default space should result in a 200

Metrics [docs]

✅ unchanged

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants