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

Fix overly generous matching of pushkin app IDs, introduced in 0.5.0 #269

Merged
merged 6 commits into from
Dec 6, 2021

Conversation

squahtx
Copy link
Contributor

@squahtx squahtx commented Nov 5, 2021

Addresses #255 together with #268 #281 and #270.

Prevent dots (.) from being interpreted as wildcards.
Only use pushkins which match the entire app ID, rather than a
substring.

@squahtx squahtx requested a review from a team as a code owner November 5, 2021 12:47
Prevent dots (.) from being interpreted as wildcards.
Only use pushkins which match the entire app ID, rather than a
substring.
sygnal/http.py Outdated
# otherwise, find any pushkins whose appid patterns match
pushkins = []
for pushkin_appid, pushkin in self.sygnal.pushkins.items():
pattern = glob_to_regex(pushkin_appid, ignore_case=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like it would be nice to precompile these, but it's less easy than the other case so I guess it depends on how ugly you think that'd be. (It also short-circuits to doing a direct check in the dict for the exact app ID, so I don't know how commonly this case is hit.)

Copy link
Contributor Author

@squahtx squahtx Nov 5, 2021

Choose a reason for hiding this comment

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

pushkin_appid is the same as pushkin.name in the other PR. I'm thinking of doing a refactor to have pushkins cache their compiled patterns and add Pushkin.matches_appid(str).
(Why do we have two spellings of appid and app_id in the code?)

The exact app ID match both incorrect and correct at the same time. appid is a literal while pushkin_appid is a pattern. It just so happens that ? matches a literal ? and * matches a literal *.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the patterns to be explicitly cached on startup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have two spellings of appid and app_id in the code?

because life is hard and different people think different things about collapsing 'id' into the same word or not /shrug

reivilibre
reivilibre previously approved these changes Nov 8, 2021
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

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

Mypy's sad, otherwise looks good.

@squahtx
Copy link
Contributor Author

squahtx commented Nov 10, 2021

Mypy's sad, otherwise looks good.

It'll be because it needs #268 to be merged first.

@squahtx
Copy link
Contributor Author

squahtx commented Dec 3, 2021

Nothing's really changed since the last review. It's only a merge from main followed by a switch to matrix-python-common.

@squahtx squahtx merged commit 90b47be into main Dec 6, 2021
@squahtx squahtx deleted the squah/fix_pushkin_matching branch December 6, 2021 11:39
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