Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSC3862: event_match (almost) anything #3862

Closed
wants to merge 10 commits into from

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Aug 5, 2022

Signed-off-by: Johannes Marbach <johannesm@element.io>
@Johennes Johennes changed the title MSC0000: event_match (almost) anything MSC3862: event_match (almost) anything Aug 5, 2022
Signed-off-by: Johannes Marbach <johannesm@element.io>
@turt2live turt2live added push proposal A matrix spec change proposal kind:maintenance MSC which clarifies/updates existing spec needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Aug 5, 2022
Signed-off-by: Johannes Marbach <johannesm@element.io>
proposals/3862-event-match-almost-anything.md Outdated Show resolved Hide resolved
proposals/3862-event-match-almost-anything.md Outdated Show resolved Hide resolved

- Strings are converted into lowercase (this already happens today)
- `true` / `false` become `"true"` / `"false"`
- Integers such as `123` become `"123"`
Copy link
Member

Choose a reason for hiding this comment

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

We should clarify that it's a requirement to encode "as written" or whatever terminology is required to say that encoding to 123e^7 is invalid (as some int-to-string functions like to do on large numbers).

Copy link
Member

Choose a reason for hiding this comment

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

An added concern is I don't think any amount of documentation will save us from folks using language-specific features to encode numbers, which can easily lead to improper notation. The implementation likely wouldn't notice until it's too late, and generally cause the same sorts of problems we saw with Canonical JSON: implementations differing in how strict they are to the spec, leading to mismatched notifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should clarify that it's a requirement to encode "as written" or whatever terminology is required to say that encoding to 123e^7 is invalid (as some int-to-string functions like to do on large numbers).

This made me think, what if somebody used the exponential form in the JSON? E.g. should "pattern": 123e7 be converted into "123e7"?

Copy link
Member

Choose a reason for hiding this comment

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

I don't believe it's allowable by Canonical JSON, but if it is then ugh/yay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, you're right. It isn't. I've added a corresponding sub-bullet to explain the conversion.

proposals/3862-event-match-almost-anything.md Outdated Show resolved Hide resolved
proposals/3862-event-match-almost-anything.md Outdated Show resolved Hide resolved
@@ -0,0 +1,106 @@
# MSC3862: event_match (almost) anything
Copy link
Member

Choose a reason for hiding this comment

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

From a client perspective, I don't think either this MSC or #3758 is particularly troublesome, though personally I do lean more towards this MSC as it shows what push rules "should" be: matches on events irrespective of data type (there's no reason to punish someone for "42" when they meant 42, at least not in this subsystem). However, the appeal of a clean slate to "fix" push rules with 3758 is equally as high.

Both are equally complex to implement and would be considered a breaking change: here, clients won't agree with servers on what the notification counts are (not that they do already...[1]), and with 3758 it's a whole new condition type. In essence, both MSCs would be writing a new condition type into the client code-wise.

[1]Element Android for instance doesn't handle keyword notifications, leading to nasty surprises when the user moves from mobile to desktop.

Copy link
Member

Choose a reason for hiding this comment

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

matches on events irrespective of data type (there's no reason to punish someone for "42" when they meant 42, at least not in this subsystem)

Do you really think so? It seems to me that this sort of "sloppy" matching could lead to things like #2223, where the push rules end up matching something different to the rest of the system. (That was the cause of security vulnerabilities in synapse and matrix-js-sdk.)

Copy link
Member

Choose a reason for hiding this comment

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

I think my primary concern with #3758 is that a new push rule condition type might be more likely to break clients than extending the existing one. If @turt2live's opinion, as a client developer, is that there's not much to choose, my inclination is to go with the more complete, and more elegant, #3758.

Copy link
Member

@ara4n ara4n Sep 1, 2022

Choose a reason for hiding this comment

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

I also prefer #3758, as it avoids casting everything to strings, and the dotted notation is more powerful.

Copy link
Member

Choose a reason for hiding this comment

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

matches on events irrespective of data type (there's no reason to punish someone for "42" when they meant 42, at least not in this subsystem)

Do you really think so? It seems to me that this sort of "sloppy" matching could lead to things like #2223, where the push rules end up matching something different to the rest of the system. (That was the cause of security vulnerabilities in synapse and matrix-js-sdk.)

It's not a strong opinion, tbh. For things like notifications it'd be a nice-to-have to support typeless matches, leaving the type validation for elsewhere (whether an event can be rendered, etc). It has been the cause of some security vulnerabilities, but push rules in general are an open avenue for multiple different kinds of implementation-specific attack to begin with. It would be a challenge to keep the "sloppiness" to the push rules though: maintaining a higher standard for other subsystems to counteract the typelessness is not traditionally something that's gone well.

proposals/3862-event-match-almost-anything.md Show resolved Hide resolved
@Johennes
Copy link
Contributor Author

Johennes commented Feb 6, 2023

Closing this since #3758 is moving ahead.

@Johennes Johennes closed this Feb 6, 2023
@turt2live turt2live added the obsolete A proposal which has been overtaken by other proposals label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:maintenance MSC which clarifies/updates existing spec needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. obsolete A proposal which has been overtaken by other proposals proposal A matrix spec change proposal push
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants