-
Notifications
You must be signed in to change notification settings - Fork 522
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
[FR] Add support for dataviews in the rule schema #3510
[FR] Add support for dataviews in the rule schema #3510
Conversation
….com:elastic/detection-rules into 2096-fr-kibana-updates-supporting-data-views
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.
🚀
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.
Hi @Mikaayenson 👋
Thanks for the tag. Currently there are no limitations on the rule creation api in kibana for index
XOR data_view_id
. If a data_view_id
field is present on a rule, regardless of whether an index
property is defined on that rule, the default action for that rule will be to query the data view associated with that id. You can test this for yourself via the following script and sample rule (pulled + modified from here):
$ cat post_rule.sh
#!/bin/sh
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
#
set -e
./check_env_variables.sh
# Uses a default if no argument is specified
RULES=(${@:-./rules/queries/query_with_rule_id.json})
# Example: ./post_rule.sh
# Example: ./post_rule.sh ./rules/queries/query_with_rule_id.json
# Example glob: ./post_rule.sh ./rules/queries/*
for RULE in "${RULES[@]}"
do {
[ -e "$RULE" ] || continue
curl -s -k \
-H 'Content-Type: application/json' \
-H 'kbn-xsrf: 123' \
-H 'elastic-api-version: 2023-10-31' \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X POST ${KIBANA_URL}${SPACE_URL}/api/detection_engine/rules \
-d @${RULE} \
| jq -S .;
} &
done
wait
$ cat rules/queries/simplest_query.json
{
"name": "Simplest Query",
"description": "Simplest query with the least amount of fields required",
"risk_score": 1,
"severity": "high",
"type": "query",
"query": "user.name: root or user.name: admin",
"index": ["myfakeindex*"],
"data_view_id": "myfakedataviewid"
}
Happy to approve the PR since this is probably something you want to ensure doesn't happen for the rules developed here but just wanted to clarify the exact logic from the API.
Thanks! I updated to remove the explicit check for both fields. |
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
(cherry picked from commit 8724077)
Issues
Resolves #2096
Summary
Add's support for Data Views within the rule schema data class. We're adding the field so that users can manage their custom rules with this field as an alternative to using the
index
field.Note: We do not validate the
data_view_id
as the inputs are arbitrary and configured in Elastic Security.Additional Context:
index
field is not supplied.Testing
Details
Details
Details