Skip to content

Commit 28f3e05

Browse files
Add check for not rule_id
1 parent 0f8c53e commit 28f3e05

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
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

0 commit comments

Comments
 (0)