Skip to content

Commit 44c9984

Browse files
[Bug] [DAC] Kibana Export Rules Rule Name Filter Exports All Rules (#4917)
* Add check for not rule_id (cherry picked from commit 0cb1e59)
1 parent f19b757 commit 44c9984

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

detection_rules/kbwrap.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ def kibana_export_rules( # noqa: PLR0912, PLR0913, PLR0915
282282
if rule_name:
283283
found = RuleResource.find(filter=f"alert.attributes.name:{rule_name}") # type: ignore[reportUnknownMemberType]
284284
rule_id = [r["rule_id"] for r in found] # type: ignore[reportUnknownVariableType]
285+
if not rule_id:
286+
click.echo(
287+
f"No rules found to export matching the provided name '{rule_name}' "
288+
f"using filter 'alert.attributes.name:{rule_name}'"
289+
)
290+
return []
285291
query = (
286292
export_query
287293
if not custom_rules_only

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "detection_rules"
3-
version = "1.3.12"
3+
version = "1.3.13"
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"

0 commit comments

Comments
 (0)