-
Notifications
You must be signed in to change notification settings - Fork 594
feat: ESQL query validation against Elastic cluster #4955
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
base: main
Are you sure you want to change the base?
Conversation
@@ -1432,15 +1432,14 @@ def get_packaged_integrations( | |||
# if both exist, rule tags are only used if defined in definitions for non-dataset packages | |||
# of machine learning analytic packages | |||
|
|||
rule_integrations = meta.get("integration", []) | |||
if rule_integrations: | |||
for integration in rule_integrations: |
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.
simple style fix, replacing if
condition with a more robust default value condition via
rule_integrations = meta.get("integration") or []
@@ -1754,7 +1753,7 @@ def parse_datasets(datasets: list[str], package_manifest: dict[str, Any]) -> lis | |||
else: | |||
package = value | |||
|
|||
if package in list(package_manifest): | |||
if package in package_manifest: |
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.
small style fix
detection_rules/rule_validators.py
Outdated
|
||
log(f"Got query columns: {', '.join(query_column_names)}") | ||
|
||
# FIXME: validate the dynamic columns |
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 columns returned from the cluster must be validated against the input mapping, and the dynamic fields checked for validity.
at the moment (before any field validation) the test marks 33 rules out of 75 as invalid. The tests were executed against a vanilla local The many errors are most probably because of the bugs in the code, so I expect the number of invalid rules to go down after those are fixed. full log
|
Updated to include initial dynamic field validation. This will parse the schema(s) for dynamic fields and perform some initial formatting check. It checks if the field has a proper prefix as described in #4909, and if the field is based on a field that is present in the schema. However, additional validation will be needed if we want to validate the proper types for ES|QL function and operator return values. https://www.elastic.co/docs/reference/query-languages/esql/esql-functions-operators Additionally, a number of the errors seen in the above testing are due to schema updates that do not have the required fields. For instance. Next steps are:
Note after discussion with @Mikaayenson we determined that the sub-field of the dynamic query does not need to have ecs enforcement here. E.g. For |
Pull Request
Issue link(s):
Summary - What I changed
How To Test
.detection-rules-cfg.yml
) or from the environment variablesChecklist
bug
,enhancement
,schema
,maintenance
,Rule: New
,Rule: Deprecation
,Rule: Tuning
,Hunt: New
, orHunt: Tuning
so guidelines can be generatedmeta:rapid-merge
label if planning to merge within 24 hoursContributor checklist