Skip to content

Commit 2ff2965

Browse files
Enhance Readability of validation check failures (#4299)
1 parent 28ffebb commit 2ff2965

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

detection_rules/rule_validators.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from semver import Version
1818

1919
import kql
20+
import click
2021

2122
from . import ecs, endgame
2223
from .config import CUSTOM_RULES_DIR, load_current_package_version, parse_rules_config
@@ -371,7 +372,9 @@ def validate(self, data: "QueryRuleData", meta: RuleMeta, max_attempts: int = 10
371372
# auto add the field and re-validate
372373
self.auto_add_field(validation_checks["stack"], data.index_or_dataview[0])
373374
else:
374-
raise ValueError(f"Error in both stack and integrations checks: {validation_checks}")
375+
click.echo(f"Stack Error Trace: {validation_checks["stack"]}")
376+
click.echo(f"Integrations Error Trace: {validation_checks["integrations"]}")
377+
raise ValueError("Error in both stack and integrations checks")
375378

376379
else:
377380
break

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "detection_rules"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
description = "Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine."
55
readme = "README.md"
66
requires-python = ">=3.12"

tests/test_python_library.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_eql_in_set(self):
5555
""",
5656
},
5757
}
58-
expected_error_message = r"Error in both stack and integrations checks:.*Unable to compare ip to string.*"
58+
expected_error_message = r"Error in both stack and integrations checks"
5959
with self.assertRaisesRegex(ValueError, expected_error_message):
6060
rc.load_dict(eql_rule)
6161
# Change to appropriate destination.address field

0 commit comments

Comments
 (0)