-
Notifications
You must be signed in to change notification settings - Fork 119
Add Support for Multiple Kibana Security Detection Rule Types #1292
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
Conversation
💚 CLA has been signed |
Co-authored-by: nick-benoit <163016768+nick-benoit@users.noreply.github.com>
…examples Co-authored-by: nick-benoit <163016768+nick-benoit@users.noreply.github.com>
The trickiest part of this PR is sorting out
The api gives back this error if both are included:
|
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.
Pretty excellent first pass here, added a bunch of comments around using some shared utils and how we've generally tried to structure things but this is looking good.
IMO we should cover all the rule types in this PR, but I could be convinced they can be added in a follow up. We do need to cover them to consider the issue 'done' though.
Looking at the acceptance test failures: The 7.17 test is failing because an expected index doesn't exist yet. I guess it wouldn't be hard to create another 7.x specific test which also first created the index, but I'm not sure it's worthwhile given it's 7.x. The 8.10 test looks like we're getting a different response from Kibana in that version. Definitely worth investigating, but given 8.10 is 2 years old I don't think it's unreasonable to skip the test in 8.10 and mention in the docs that the resource isn't compatible with 8.10. |
…feedback Co-authored-by: nick-benoit <163016768+nick-benoit@users.noreply.github.com>
@copilot Please support all detection rule types defined in https://www.elastic.co/docs/api/doc/kibana/group/endpoint-security-detections-api This will require adding updating the schema in |
I'm implementing support for all detection rule types. I've updated the schema to support all 8 rule types (query, eql, esql, machine_learning, new_terms, saved_query, threat_match, threshold) with their specific fields, and I'm working on updating the models to handle creation and updates for each type. This is a significant change that requires updating the create, update, and read logic for all rule types. I'll commit the progress once the implementation is complete and tested. |
Co-authored-by: nick-benoit <163016768+nick-benoit@users.noreply.github.com>
Co-authored-by: Toby Brain <toby.brain@elastic.co>
Co-authored-by: Toby Brain <toby.brain@elastic.co>
Co-authored-by: Toby Brain <toby.brain@elastic.co>
…vider-elasticstack into copilot/fix-1290-2
Co-authored-by: Toby Brain <toby.brain@elastic.co>
Either skip check for required fields or use utils.IsKnown
Co-authored-by: Toby Brain <toby.brain@elastic.co>
Co-authored-by: Toby Brain <toby.brain@elastic.co>
internal/kibana/security_detection_rule/models_machine_learning.go
Outdated
Show resolved
Hide resolved
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 with one minor nit. Happy to get those addressed in a follow up PR though if you wanted to get this merged/released.
} | ||
|
||
// Helper function to update data view ID from API response | ||
func (d *SecurityDetectionRuleData) updateDataViewIdFromApi(ctx context.Context, dataViewId *kbapi.SecurityDetectionsAPIDataViewId) diag.Diagnostics { |
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.
The following few functions return diags that will always be empty. We should likely just remove the return value altogether.
…vider-elasticstack into copilot/fix-1290-2
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 post meta removal
* origin/main: Add Support for Multiple Kibana Security Detection Rule Types (elastic#1292) chore(deps): update module github.com/golangci/golangci-lint to v2.5.0 (elastic#1348) chore(deps): update golang:1.25.1 docker digest to d709837 (elastic#1347) fix(deps): update module github.com/hashicorp/terraform-plugin-mux to v0.21.0 (elastic#1349)
PR Description: Implement Kibana Security Detection Rule Resource
Overview
This PR implements the
elasticstack_kibana_security_detection_rule
resource, addressing issue #523. This adds support for managing Kibana security detection rules through Terraform, enabling users to create, update, and manage various types of security rules including query, EQL, ESQL, machine learning, new terms, saved query, threat match, and threshold rules.See
examples/resources/elasticstack_kibana_security_detection_rule/resource.tf
as a usage example. More widespread examples for each rule type can be found in the acceptance tests (security_detection_rule/acc_test.go
)File Structure
Notes
While all rule types are currently supported by this resource there are some dependent resources that are not yet supported. Notably:
Support for both of should be included in the next milestone release however.