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] Avoid exporting execution_summary field #150097

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

maximpn
Copy link
Contributor

@maximpn maximpn commented Feb 1, 2023

Summary

It fixes a problem of exporting execution_summary field while exporting detection rules which was introduce in #147035. Presence of that field make importing of just exported rule failing.

Tests to cover this fix will come in a separate PR.

@maximpn maximpn added release_note:fix backport:skip This commit does not require backporting Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team v8.7.0 labels Feb 1, 2023
@maximpn maximpn self-assigned this Feb 1, 2023
@maximpn maximpn force-pushed the fix-exporting-rules branch from 70697ff to 065ec29 Compare February 2, 2023 08:35
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

  • 💔 Build #104868 failed 70697ff8bfc5dc29d8767a4fc2a45d398b2ea8cd

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

cc @maximpn

@maximpn maximpn marked this pull request as ready for review February 2, 2023 11:10
@maximpn maximpn requested a review from a team as a code owner February 2, 2023 11:10
@maximpn maximpn requested a review from xcrzx February 2, 2023 11:10
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@banderror banderror added release_note:skip Skip the PR/issue when compiling release notes bug Fixes for quality problems that affect the customer experience Feature:Rule Management Security Solution Detection Rule Management area and removed release_note:fix labels Feb 2, 2023
Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! 👍

Comment on lines +121 to +124
const rule = internalRuleToAPIResponse(matchingRule, legacyActions[matchingRule.id]);

// Fields containing runtime information shouldn't be exported. It causes import failures.
delete rule.execution_summary;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's extract this into a function with a clear name, e.g. transformRuleToExportableFormat or something like that

@maximpn maximpn merged commit 3c14f00 into elastic:main Feb 2, 2023
maximpn added a commit that referenced this pull request Mar 10, 2023
**Relates to:** elastic/security-team#5339, #150097, #150553

## Summary

This PR fixes all rules exporting functionality which started exporting unintentionally runtime fields like `execution_summary`. This way it lead to inability to import just exported rules if as minimum one of them executed just once.

On top of this the PR contains functional and Cypress tests to cover the fix.

## TODO

- [ ] get rid of `await waitForEventLogExecuteComplete()` in functional tests
- [ ] allow `getNewRule()` to rewrite its defaults

### Checklist

- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [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
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 10, 2023
**Relates to:** elastic/security-team#5339, elastic#150097, elastic#150553

## Summary

This PR fixes all rules exporting functionality which started exporting unintentionally runtime fields like `execution_summary`. This way it lead to inability to import just exported rules if as minimum one of them executed just once.

On top of this the PR contains functional and Cypress tests to cover the fix.

## TODO

- [ ] get rid of `await waitForEventLogExecuteComplete()` in functional tests
- [ ] allow `getNewRule()` to rewrite its defaults

### Checklist

- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [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

(cherry picked from commit 6b62ae2)
kibanamachine added a commit that referenced this pull request Mar 10, 2023
# Backport

This will backport the following commits from `main` to `8.7`:
- [[Security Solution] Fix exporting all rules
(#152900)](#152900)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2023-03-10T17:23:48Z","message":"[Security
Solution] Fix exporting all rules (#152900)\n\n**Relates to:**
elastic/security-team#5339,
#150097,
https://github.com/elastic/kibana/pull/150553\r\n\r\n##
Summary\r\n\r\nThis PR fixes all rules exporting functionality which
started exporting unintentionally runtime fields like
`execution_summary`. This way it lead to inability to import just
exported rules if as minimum one of them executed just once.\r\n\r\nOn
top of this the PR contains functional and Cypress tests to cover the
fix.\r\n\r\n## TODO\r\n\r\n- [ ] get rid of `await
waitForEventLogExecuteComplete()` in functional tests\r\n- [ ] allow
`getNewRule()` to rewrite its defaults\r\n\r\n### Checklist\r\n\r\n- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials\r\n- [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","sha":"6b62ae2adfead5ece8b47c0909ab58c67f3f1adb","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection
Rules","backport:prev-minor","Feature:Rule
Import/Export","v8.8.0"],"number":152900,"url":"https://github.com/elastic/kibana/pull/152900","mergeCommit":{"message":"[Security
Solution] Fix exporting all rules (#152900)\n\n**Relates to:**
elastic/security-team#5339,
#150097,
https://github.com/elastic/kibana/pull/150553\r\n\r\n##
Summary\r\n\r\nThis PR fixes all rules exporting functionality which
started exporting unintentionally runtime fields like
`execution_summary`. This way it lead to inability to import just
exported rules if as minimum one of them executed just once.\r\n\r\nOn
top of this the PR contains functional and Cypress tests to cover the
fix.\r\n\r\n## TODO\r\n\r\n- [ ] get rid of `await
waitForEventLogExecuteComplete()` in functional tests\r\n- [ ] allow
`getNewRule()` to rewrite its defaults\r\n\r\n### Checklist\r\n\r\n- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials\r\n- [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","sha":"6b62ae2adfead5ece8b47c0909ab58c67f3f1adb"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152900","number":152900,"mergeCommit":{"message":"[Security
Solution] Fix exporting all rules (#152900)\n\n**Relates to:**
elastic/security-team#5339,
#150097,
https://github.com/elastic/kibana/pull/150553\r\n\r\n##
Summary\r\n\r\nThis PR fixes all rules exporting functionality which
started exporting unintentionally runtime fields like
`execution_summary`. This way it lead to inability to import just
exported rules if as minimum one of them executed just once.\r\n\r\nOn
top of this the PR contains functional and Cypress tests to cover the
fix.\r\n\r\n## TODO\r\n\r\n- [ ] get rid of `await
waitForEventLogExecuteComplete()` in functional tests\r\n- [ ] allow
`getNewRule()` to rewrite its defaults\r\n\r\n### Checklist\r\n\r\n- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials\r\n- [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","sha":"6b62ae2adfead5ece8b47c0909ab58c67f3f1adb"}}]}]
BACKPORT-->

Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
**Relates to:** elastic/security-team#5339, elastic#150097, elastic#150553

## Summary

This PR fixes all rules exporting functionality which started exporting unintentionally runtime fields like `execution_summary`. This way it lead to inability to import just exported rules if as minimum one of them executed just once.

On top of this the PR contains functional and Cypress tests to cover the fix.

## TODO

- [ ] get rid of `await waitForEventLogExecuteComplete()` in functional tests
- [ ] allow `getNewRule()` to rewrite its defaults

### Checklist

- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience Feature:Rule Management Security Solution Detection Rule Management area release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants