Skip to content

Unify custom_rule_attributes into custom_attributes#27

Merged
mostafa merged 2 commits into
mainfrom
feat/unify-custom-attributes
Apr 18, 2026
Merged

Unify custom_rule_attributes into custom_attributes#27
mostafa merged 2 commits into
mainfrom
feat/unify-custom-attributes

Conversation

@mostafa
Copy link
Copy Markdown
Member

@mostafa mostafa commented Apr 17, 2026

Merges the two per-rule dictionaries into a single custom_attributes field on SigmaRule and CorrelationRule, typed as HashMap<String, serde_yaml::Value> to preserve nested structures and non-string values. Mirrors pySigma's single custom_attributes dict.

Sources, applied in order (last-write-wins):

  1. Arbitrary top-level YAML keys not in the standard Sigma schema.
  2. Entries of the optional top-level custom_attributes: mapping.
  3. Pipeline SetCustomAttribute transformations, applied after parsing.

Follow-on changes:

  • MatchResult and CorrelationResult expose a single custom_attributes: Arc<HashMap<String, serde_json::Value>> (renamed from custom_rule_attributes).
  • apply_custom_attributes in the correlation engine and all rsigma.* readers now look up serde_yaml::Value::as_str().
  • Pipeline SetCustomAttribute stores Value::String(...).
  • Parser tests cover the explicit-block override of arbitrary keys; compiler tests cover pipeline overriding the rule YAML.

BREAKING: custom_rule_attributes is removed from the public AST and runtime types. Code reading rule.custom_attributes must now treat values as serde_yaml::Value (use .as_str() to recover the old string view). Since #26 was merged recently and not released, this is okay.

xref #20 (comment)

@fwosar I'd appreciate your review! 🙏

Merges the two per-rule dictionaries into a single `custom_attributes`
field on `SigmaRule` and `CorrelationRule`, typed as
`HashMap<String, serde_yaml::Value>` to preserve nested structures and
non-string values. Mirrors pySigma's single `custom_attributes` dict.

Sources, applied in order (last-write-wins):

1. Arbitrary top-level YAML keys not in the standard Sigma schema.
2. Entries of the optional top-level `custom_attributes:` mapping.
3. Pipeline `SetCustomAttribute` transformations, applied after parsing.

Follow-on changes:
- `MatchResult` and `CorrelationResult` expose a single
  `custom_attributes: Arc<HashMap<String, serde_json::Value>>`
  (renamed from `custom_rule_attributes`).
- `apply_custom_attributes` in the correlation engine and all
  `rsigma.*` readers now look up `serde_yaml::Value::as_str()`.
- Pipeline `SetCustomAttribute` stores `Value::String(...)`.
- Parser tests cover the explicit-block override of arbitrary keys;
  compiler tests cover pipeline overriding the rule YAML.

BREAKING: `custom_rule_attributes` is removed from the public AST and
runtime types. Code reading `rule.custom_attributes` must now treat
values as `serde_yaml::Value` (use `.as_str()` to recover the old
string view).
@mostafa mostafa self-assigned this Apr 17, 2026
@mostafa mostafa marked this pull request as ready for review April 17, 2026 23:16
@mostafa mostafa merged commit 365da47 into main Apr 18, 2026
8 checks passed
@mostafa mostafa deleted the feat/unify-custom-attributes branch April 18, 2026 08:44
@fwosar
Copy link
Copy Markdown
Contributor

fwosar commented Apr 18, 2026

Looks good to me :)

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