Skip to content

feat: support one-to-many in field_name_mapping#40

Merged
mostafa merged 1 commit intotimescale:mainfrom
fwosar:one-to-many-field-name-mapping
Apr 27, 2026
Merged

feat: support one-to-many in field_name_mapping#40
mostafa merged 1 commit intotimescale:mainfrom
fwosar:one-to-many-field-name-mapping

Conversation

@fwosar
Copy link
Copy Markdown
Contributor

@fwosar fwosar commented Apr 26, 2026

Match pySigma's FieldMappingTransformation: a single source field name in field_name_mapping can now map to a list of alternative target field names. When more than one alternative is supplied, the matched detection item is replaced with an OR-conjunction over the alternatives. If the surrounding AllOf selection has other items, they're preserved across each branch via a Cartesian expansion so AND/OR semantics stay correct.

Wire-compatible at the YAML layer: existing mapping: {a: b} pipelines continue to parse: parse_string_or_list_mapping accepts both string and list values per key. Transformation::FieldNameMapping's value type changes from HashMap<String, String> to HashMap<String, Vec<String>>, which is a source-level break for any direct in-Rust constructors.

Correlation rules consume only the first listed alternative for group_by, aliases mapping values, and threshold field as those positions are inherently scalar and OR semantics aren't expressible there. Other field-name transforms (field_name_prefix, field_name_suffix, field_name_prefix_mapping, field_name_transform) remain conceptually 1:1; they wrap their single result internally.

Tests: 3 new unit tests covering AnyOf expansion, Cartesian product when multiple items expand, and the single-alternative fast path; 2 new end-to-end YAML integration tests.

@fwosar fwosar requested a review from mostafa as a code owner April 26, 2026 20:52
Copy link
Copy Markdown
Member

@mostafa mostafa left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! 🙏

The only blockers to merging this PR are:

  1. Formatting of the code.
  2. Upper bound warning for the cartesian_product function.

Comment thread crates/rsigma-eval/src/pipeline/transformations.rs
@fwosar fwosar force-pushed the one-to-many-field-name-mapping branch from c115e1a to 71d1ccc Compare April 27, 2026 09:32
Match pySigma's FieldMappingTransformation: a single source field name in `field_name_mapping` can now map to a list of alternative target field names. When more than one alternative is supplied, the matched detection item is replaced with an OR-conjunction over the alternatives. If the surrounding `AllOf` selection has other items, they're preserved across each branch via a Cartesian expansion so AND/OR semantics stay correct.

Wire-compatible at the YAML layer: existing `mapping: {a: b}` pipelines continue to parse — `parse_string_or_list_mapping` accepts both string and list values per key. `Transformation::FieldNameMapping`'s value type changes from `HashMap<String, String>` to `HashMap<String, Vec<String>>`, which is a source-level break for any direct in-Rust constructors.

Correlation rules consume only the first listed alternative for `group_by`, `aliases` mapping values, and threshold `field` — those positions are inherently scalar and OR semantics aren't expressible there. Other field-name transforms (`field_name_prefix`, `field_name_suffix`, `field_name_prefix_mapping`, `field_name_transform`) remain conceptually 1:1; they wrap their single result internally.

Tests: 3 new unit tests covering AnyOf expansion, Cartesian product when multiple items expand, and the single-alternative fast path; 2 new end-to-end YAML integration tests.
@fwosar fwosar force-pushed the one-to-many-field-name-mapping branch from 71d1ccc to 2a4eeed Compare April 27, 2026 11:49
@fwosar
Copy link
Copy Markdown
Contributor Author

fwosar commented Apr 27, 2026

Signed the commit now to meet your merge requirements. :)

@mostafa mostafa merged commit 68817ad into timescale:main Apr 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants