Repository navigation
[Rule Tuning] Fix quoted KQL wildcards in four rules - #7216
LiamCarPer wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Generally I think this PR is fine, but the tests in tests/test_specific_rules.py can be simpler. You do not need a custom walk_ast() function. You can use can iterate over the object like this instead:
for node in rule.contents.data.ast:
...
Also, given that quoted "*" for literals may be desired, we may not want to have direct tests for this in the python test cases, it might be better served by using RTAs (as opposed to having to maintain a list of rules we want/do not want to test).
Unquote wildcard values in KQL queries so the patterns match as wildcards instead of literal asterisks, as reported in elastic#7214. Escape literal colons and embedded quotes where the values are now unquoted, and add regression tests asserting these values parse as Wildcard nodes.
Address review feedback: the KQL AST can be iterated directly and a hardcoded rule list is brittle. The rule changes remain covered by the existing rule validation suite; RTA coverage is the better follow-up.
afca985 to
79dbb24
Compare
|
Thanks @eric-forte-elastic — I removed the rule-specific test class and the custom |
Issue link(s): Fixes #7214
Summary - What I changed
KQL treats
*inside double quotes as a literal character, so several prebuilt rule queries contained wildcard-looking values that could never match as patterns. This PR moves the wildcards outside the quoted values in the four affected rules:rules/network/initial_access_splunk_postgres_recovery_body_injection.toml— unquotes theurl.pathrecovery endpoint gate, thehttp.request.body.contentfilename/database markers, and the two status-400url.pathvalues. Embedded quotes are escaped as\".rules/cross-platform/impact_destructive_aws_cli_execution_by_genai_agent.toml— unquotes theprocess.args--dry-run*,--help*,-help*, and--version*exclusions.rules/cross-platform/discovery_cloud_offensive_framework_execution.toml— unquotes the*site-packages/pip*exclusion arm.rules/windows/persistence_webshell_detection.toml— unquotes the WAMP Apache parent path, escaping the literal:asE\:/....I also bumped
updated_dateto2026/11/22for each tuned rule and rebased the branch onto currentmain.Per review feedback, I removed the rule-specific AST test from
tests/test_specific_rules.py. The KQL AST can be iterated directly, and a hardcoded list of rules would be brittle; RTA coverage is the better long-term place for this. The rule changes are covered by the existing rule validation suite.How To Test
The
PYTHONPATH=prefix only clears a local ROS pytest plugin that otherwise fails to load; it does not affect the repository code under test.Checklist
bug,enhancement,schema,maintenance,Rule: New,Rule: Deprecation,Rule: Tuning,Hunt: New, orHunt: Tuningso guidelines can be generated — I could not apply labels from the fork (GitHub returns 403, maintainer/admin rights required); please addRule: Tuning.meta:rapid-mergelabel if planning to merge within 24 hoursContributor checklist