refactor(convert): make the Backend trait fully IR-native - #363
Merged
Conversation
Port text_convert_value_str / text_convert_field_eq_str to read the faithful IrPattern (wildcard-aware, original case) and an explicit IrStrOp instead of a parser SigmaString + modifier slice. These are the rendering building blocks for the IR-native Backend leaves; the wiring follows.
Add convert_field_str/num/bool/null/regex/cidr/compare_op and convert_keyword_str/num consuming IrPattern/IrStrOp/CompareOp with no parser types. Default impls reconstruct the equivalent SigmaString/modifiers and delegate to the existing parser-typed leaves, so every backend is IR-native for free (byte-identical); backends override these next to drop the parser dependency.
convert_rule now lowers the whole rule to HIR and converts detections, items, keywords, array matches, and conditional blocks from the faithful IR (ir_convert dispatch on IrMatcher). PostgreSQL JSONB array matching and Fibratus's list/regex/cidr collapse are ported to IR natively; value rendering delegates to the existing leaves via the default IR-native leaf impls, so PG/LynxDB/Fibratus goldens stay byte-identical. Adds IrMatcher:: Regex.cased so backends can pick a case-sensitive regex operator (eval ignores it), and maps IR lowering errors to the historical convert error kinds.
Remove every parser-typed method from the Backend trait and its implementations. Detection and condition walks run over the lowered IrRule, and value leaves consume the faithful HIR: convert_field_str over IrStrOp + wildcard-aware IrPattern, convert_field_regex with RegexFlags, convert_field_compare_op with CompareOp, and convert_keyword_str / convert_keyword_num. Backends render from the pattern directly, so none of them touch rsigma-parser to emit a value match. Drop the now-dead parser dispatch (condition.rs, the default_convert_* helpers) and the SigmaString-based text helpers. PostgreSQL, LynxDB, and Fibratus golden outputs stay byte-identical.
This was referenced Jul 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Routes
rsigma-convertentirely through the intermediate representation. A rule is lowered toIrRuleonce, both the detection and condition walks run over the HIR, and theBackendtrait's value leaves consume the faithful matcher model with no parser types.What changed
Backendtrait is parser-free. Value leaves are IR-native:convert_field_str(field, IrStrOp, &IrPattern, case_insensitive)over a wildcard-aware, original-case patternconvert_field_regex(field, pattern, RegexFlags)convert_field_compare_op(field, CompareOp, value)convert_keyword_str(&IrPattern)/convert_keyword_num(f64)convert_field_eq_num/eq_bool/eq_null/eq_cidr,convert_field_exists,convert_field_eq_query_expr,convert_field_refIrDetection/IrConditionviaconvert_ir_detection/convert_ir_detection_item. PostgreSQL keeps its JSONB array-match override and Fibratus keeps its multi-valuere/cidr/ string-list collapse, both ported toIrMatcher.condition.rs, thedefault_convert_detection/default_convert_detection_itemhelpers and their multi-value paths, and theSigmaString-basedtext_convert_value_str/text_convert_field_eq_strfree helpers.Compatibility
PostgreSQL, LynxDB, and Fibratus golden outputs are byte-identical. Full suite (3086 tests) passes;
clippy --all-targets --all-features -D warnings,fmt --check,cargo doc, and the docs site build/validate are green.Builds on #360 and #362.
xref #346