fix(sigma): preserve ATR regex case semantics - #520
Conversation
|
Reviewed. Approve on the substance — one follow-up below that is about the engine, not about this PR. The premise checks out, and the blast radius is larger than the description saysI verified the claim independently rather than taking it:
So "case-insensitive by default, with an explicit opt-out" is the written contract, and the exporter was reading the absence of inline Worth putting a number on it, because the PR body undersells this. I counted rules whose conditions carry no inline Every downstream Sigma consumer has been getting case-sensitive matching on more than a third of the corpus, against an engine that is case-insensitive on all of it. That is not a cosmetic export detail; it is weaker detection than ATR advertises, in an artifact other projects consume. I would put that number in the PR body — it is the strongest argument for merging this. One finding, for a follow-up rather than this PRThe engine does not honour and the
So on that condition format, This does not block the PR, for two reasons: no rule currently sets
(1) is the honest one and probably a small change. It is also the kind of thing better raised as its own issue than bolted onto this PR. On the verificationRunning the suite on untouched The conflict handling — MergeHolding for @eeee2345 on the merge itself, since rule-affecting exports are his call. Nothing in the code is blocking from my side. |
Summary
field|re|ieven when the source pattern has no inline(?i)case_sensitive: trueopt-out by emittingfield|recase_sensitive: trueplus inlineideterministic: the schema field wins, the inlineiis removed, and conversion emits a warningRefs #331. This intentionally does not close the issue: pyATR's silent regex compile failures and the remaining variable-width-lookbehind rules are separate follow-ups.
Context and scope
#509 fixed the JavaScript-only Unicode escapes. #510 and #511 preserve case semantics in the PyRIT digest, but do not change
generate-sigma.py; this PR addresses only the Sigma-export subsection of #331.The repository's rule-writing guide still recommends adding inline
(?i), while the schema and runtime define regex matching as case-insensitive by default unlesscase_sensitive: true. This PR does not change that broader authoring guidance.No rules, pyATR code, workflows, generated examples, or dependency files are changed.
Verification
python -m pytest scripts/test_generate_sigma.py -q -k 'not test_re2_dialect_rewrites_unicode_escapes': 18 passed, 1 deselectedupstream/main: 15 passed, the same 1 failure\\u{...}after \u{...} is JavaScript-only, so ten rules never compiled outside the TS engine #509 replaced those escapes with literalscontent|retocontent|re|igit diff --checkThe standalone Python converter suite is not currently wired into PR GitHub Actions; adding that CI integration is outside this focused change.