-
- Downloads
Do not accept pattern_type from user input in push rules. (#15088)
Internally the push rules module uses a `pattern_type` property for `event_match` conditions (and `related_event_match`) to mark the condition as matching the current user's Matrix ID or localpart. This is leaky to the Client-Server API where a user can successfully set a condition which provides `pattern_type` instead of `pattern` (note that there's no benefit to doing this -- the user can just use their own Matrix ID or localpart instead). When serializing back to the client the `pattern_type` property is converted into a proper `pattern`. The following changes are made to avoid this: * Separate the `KnownCondition::EventMatch` enum value into `EventMatch` and `EventMatchType`, each with their own expected properties. (Note that a similar change is made for `RelatedEventMatch`.) * Make it such that the `pattern_type` variants serialize to the same condition kind, but cannot be deserialized (since they're only provided by base rules). * As a final tweak, convert `user_id` vs. `user_localpart` values into an enum.
Showing
- changelog.d/15088.bugfix 1 addition, 0 deletionschangelog.d/15088.bugfix
- rust/benches/evaluator.rs 3 additions, 6 deletionsrust/benches/evaluator.rs
- rust/src/push/base_rules.rs 48 additions, 87 deletionsrust/src/push/base_rules.rs
- rust/src/push/evaluator.rs 71 additions, 84 deletionsrust/src/push/evaluator.rs
- rust/src/push/mod.rs 94 additions, 9 deletionsrust/src/push/mod.rs
- tests/push/test_push_rule_evaluator.py 27 additions, 0 deletionstests/push/test_push_rule_evaluator.py
Loading
Please register or sign in to comment