Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "detection_rules"
version = "1.5.3"
version = "1.5.4"
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."
readme = "README.md"
requires-python = ">=3.12"
Expand Down
24 changes: 24 additions & 0 deletions tests/test_all_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,30 @@ def test_ml_integration_jobs_exist(self):
f"The following ({len(failures)}) rules are missing a valid `machine_learning_job_id`:\n{err_msg}"
)

def test_preserve_upstream_protected_rule_id_name(self):
"""
Ensure upstream referenced rule IDs and rule names remain unchanged
"""
protected_rules = {"9a1a2dae-0b5f-4c3d-8305-a268d404c306": "Endpoint Security (Elastic Defend)"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for posterity, do we expect there to be substantially more protected rules, or generally is this a small list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically for now 1 and may be a growing small list or not.

Initially I had checked to see if we wanna make all the rule_id immutable. But since there are no upstream impacts choose to stick to only rule that is referenced by its ID here https://github.com/elastic/kibana/blob/3f7184698faea27158fb47f397c35fec909a4ce3/x-pack/solutions/security/plugins/security_solution/common/detection_engine/constants.ts#L38


failures: list[str] = []
for rule_id, rule_name in protected_rules.items():
try:
if rule_name != self.rc.id_map[rule_id].name:
failures.append(
f"Protected rule_id {rule_id} name modified from '{rule_name}' to '{self.rc.id_map[rule_id].name}' - review upstream impact"
)
except KeyError:
failures.append(
f"Protected rule: {rule_name} rule_id: {rule_id} missing/modified - review upstream impact"
)

if failures:
fail_msg = """
The following protected prebuilt rules have missing/modified rule IDs or names \n
"""
self.fail(fail_msg + "\n".join(failures))


class TestRuleTiming(BaseRuleTest):
"""Test rule timing and timestamps."""
Expand Down
Loading