@@ -88,27 +88,27 @@ def test_eql_in_set_valid_address(self) -> None:
8888
8989
9090class TestEQLSequencePerIntegration (BaseRuleTest ):
91- """Tests for per-stage EQL validation against the correct integration.package schema."""
91+ """Tests for per-subquery EQL validation against the correct integration.package schema."""
9292
9393 def test_sequence_valid_per_package (self ) -> None :
94- """Test that a sequence with stages from different packages validates correctly."""
94+ """Test that a sequence with subquerys from different packages validates correctly."""
9595 rc = RuleCollection ()
9696 query = """
9797 sequence with maxspan=30m
9898 [any where event.dataset == "azure.identity_protection"] by azure.identityprotection.properties.user_principal_name
9999 [any where event.dataset == "azure.auditlogs"] by azure.auditlogs.properties.initiated_by.user.userPrincipalName
100100 """
101101 rule = {
102- "metadata" : mk_metadata (["azure" ], comments = "Per-stage integration validation" ),
102+ "metadata" : mk_metadata (["azure" ], comments = "Per-subquery integration validation" ),
103103 "rule" : mk_rule (
104104 name = "EQL sequence per integration test" ,
105105 rule_id = "1b6e2f77-8e1f-4f8d-9f72-1d8e5f3e5f11" ,
106- description = "Validate per-stage integration.package schemas." ,
106+ description = "Validate per-subquery integration.package schemas." ,
107107 risk_score = 40 ,
108108 query = query ,
109109 ),
110110 }
111- # Should load without error because each stage validates against its own package schema
111+ # Should load without error because each subquery validates against its own package schema
112112 rc .load_dict (rule )
113113
114114 def test_sequence_invalid_join_field_wrong_package (self ) -> None :
@@ -120,15 +120,56 @@ def test_sequence_invalid_join_field_wrong_package(self) -> None:
120120 [any where event.dataset == "azure.identity_protection"] by azure.auditlogs.properties.initiated_by.user.userPrincipalName
121121 """
122122 bad_rule = {
123- "metadata" : mk_metadata (["azure" ], comments = "Per-stage integration validation" ),
123+ "metadata" : mk_metadata (["azure" ], comments = "Per-subquery integration validation" ),
124124 "rule" : mk_rule (
125125 name = "EQL sequence per integration test" ,
126126 rule_id = "1b6e2f77-8e1f-4f8d-9f72-1d8e5f3e5f11" ,
127- description = "Validate per-stage integration.package schemas." ,
127+ description = "Validate per-subquery integration.package schemas." ,
128128 risk_score = 40 ,
129129 query = query ,
130130 ),
131131 }
132- # Expect failure: join field belongs to a different package than the stage dataset
132+ # Expect failure: join field belongs to a different package than the subquery dataset
133+ with self .assertRaisesRegex (ValueError , r"Error in both stack and integrations checks" ):
134+ rc .load_dict (bad_rule )
135+
136+ def test_sequence_across_integrations_valid (self ) -> None :
137+ """Sequence uses azure and crowdstrike datasets; each subquery validates against its own integration."""
138+ rc = RuleCollection ()
139+ query = """
140+ sequence with maxspan=30m
141+ [any where event.dataset == "azure.auditlogs"] by azure.auditlogs.properties.initiated_by.user.userPrincipalName
142+ [any where event.dataset == "crowdstrike.fdr"] by process.executable
143+ """
144+ rule = {
145+ "metadata" : mk_metadata (["azure" , "crowdstrike" ], comments = "Cross-integration per-subquery validation" ),
146+ "rule" : mk_rule (
147+ name = "EQL sequence across integrations valid" ,
148+ rule_id = "2a3b4c55-1234-4f8d-9f72-1d8e5f3e5f11" ,
149+ description = "Validate sequence subquerys across azure and crowdstrike integrations." ,
150+ risk_score = 35 ,
151+ query = query ,
152+ ),
153+ }
154+ rc .load_dict (rule )
155+
156+ def test_sequence_across_integrations_invalid_crowdstrike_subquery_azure_field (self ) -> None :
157+ """CrowdStrike subquery incorrectly uses an azure join field, which should fail validation."""
158+ rc = RuleCollection ()
159+ query = """
160+ sequence with maxspan=30m
161+ [any where event.dataset == "azure.auditlogs"] by azure.auditlogs.properties.initiated_by.user.userPrincipalName
162+ [any where event.dataset == "crowdstrike.fdr"] by azure.auditlogs.properties.initiated_by.user.userPrincipalName
163+ """
164+ bad_rule = {
165+ "metadata" : mk_metadata (["azure" , "crowdstrike" ], comments = "Cross-integration per-subquery validation" ),
166+ "rule" : mk_rule (
167+ name = "EQL sequence across integrations invalid" ,
168+ rule_id = "2a3b4c55-1234-4f8d-9f72-1d8e5f3e5f12" ,
169+ description = "CrowdStrike subquery incorrectly uses an azure join field." ,
170+ risk_score = 35 ,
171+ query = query ,
172+ ),
173+ }
133174 with self .assertRaisesRegex (ValueError , r"Error in both stack and integrations checks" ):
134175 rc .load_dict (bad_rule )
0 commit comments