-
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
[Security Solution] Makes rule_source
a required field in RuleResponse
#193636
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested importing a rule where rule_source does not exist and then exporting that same rule. The exported rule has the rule_source property. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Just one question about a possible redundant conversion.
@@ -66,5 +67,6 @@ export const internalRuleToAPIResponse = ( | |||
actions: [...actions, ...(systemActions ?? [])], | |||
// Execution summary | |||
execution_summary: executionSummary ?? undefined, | |||
rule_source: snakecaseKeys(normalizedRuleParams.ruleSource, { deep: true }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't rule_source
already being converted by commonParamsCamelToSnake
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xcrzx It does, this was more of a typing thing as commonParamsCamelToSnake
takes a type of BaseRuleParams
which still declares rule_source
as optional so it doesn't fit the expected return type in this file (rule_source
might be undefined). My other idea was to cast with a custom type when we spread the common params into this object, that might be better since it's not actually performing logic twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the clarification. We might need a separate type to represent normalized rule parameters where rule_source
is required. That way, we can make commonParamsCamelToSnake
a generic function that works with both standard rule parameters and normalized ones.
I'll leave it up to you, both approaches work for me!
552d5f3
to
7a39293
Compare
b8c8252
to
68e85e2
Compare
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @dplumlee |
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11221182473 |
…onse` (elastic#193636) **Resolves elastic#180270 ## Summary Sets `rule_source` to be a required field in the `RuleResponse` type ### Checklist Delete any items that are not applicable to this PR. - [ ] [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 ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 484f95e)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…eld in `RuleResponse` (#193636) (#195303) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Makes `rule_source` a required field in `RuleResponse` (#193636)](#193636) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Davis Plumlee","email":"56367316+dplumlee@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-07T17:56:12Z","message":"[Security Solution] Makes `rule_source` a required field in `RuleResponse` (#193636)\n\n**Resolves https://github.com/elastic/kibana/issues/180270**\r\n\r\n## Summary\r\n\r\nSets `rule_source` to be a required field in the `RuleResponse` type\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ]\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### 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)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"484f95e7335a5b8d8df0d8c321d2b2e74db668a8","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Detections and Resp","Team: SecuritySolution","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","v8.16.0","backport:version"],"title":"[Security Solution] Makes `rule_source` a required field in `RuleResponse`","number":193636,"url":"https://github.com/elastic/kibana/pull/193636","mergeCommit":{"message":"[Security Solution] Makes `rule_source` a required field in `RuleResponse` (#193636)\n\n**Resolves https://github.com/elastic/kibana/issues/180270**\r\n\r\n## Summary\r\n\r\nSets `rule_source` to be a required field in the `RuleResponse` type\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ]\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### 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)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"484f95e7335a5b8d8df0d8c321d2b2e74db668a8"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193636","number":193636,"mergeCommit":{"message":"[Security Solution] Makes `rule_source` a required field in `RuleResponse` (#193636)\n\n**Resolves https://github.com/elastic/kibana/issues/180270**\r\n\r\n## Summary\r\n\r\nSets `rule_source` to be a required field in the `RuleResponse` type\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [ ]\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### 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)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"484f95e7335a5b8d8df0d8c321d2b2e74db668a8"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com>
Resolves #180270
Summary
Sets
rule_source
to be a required field in theRuleResponse
typeChecklist
Delete any items that are not applicable to this PR.
For maintainers