This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix potential leak of per-room profiles when the user dir is rebuilt. #10981
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5ee9fef
Conceal local user nicknames when rebuilding dir
4e69df4
Remove duplicated code from test_initial
b9254eb
Move `is_public` before updating sharing tables
b10d6a4
Don't bother creating a set from dict keys
e6880b7
Changelog
f20d78c
Don't hit the private branch if room is public and users_with_profile…
118eecf
Fix indentation
abd943a
Docstrings
7ea8188
Improved comments(?)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,7 @@ def _get_next_batch( | |
room_id | ||
) | ||
|
||
# TODO this leaks per-room profiles! | ||
users_with_profile = await self.get_users_in_room_with_profiles(room_id) | ||
# Throw away users excluded from the directory. | ||
users_with_profile = { | ||
|
@@ -241,8 +242,11 @@ def _get_next_batch( | |
or await self.should_include_local_user_in_dir(user_id) | ||
} | ||
|
||
# Update each user in the user directory. | ||
# Upsert a user_directory record for each remote user we see. | ||
# (Local users are processed in `_populate_user_directory_users`.) | ||
for user_id, profile in users_with_profile.items(): | ||
if self.hs.is_mine_id(user_id): | ||
continue | ||
Comment on lines
+247
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be worth adding a comment here to explain why it's important to skip local users here. |
||
await self.update_profile_in_user_dir( | ||
user_id, profile.display_name, profile.avatar_url | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be in conflict with the newsfile 🤔
I think I don't really understand what the TODO means. How does it leak them?
Perhaps it's ok if you're going to be updating this soon, but otherwise a few more words in this comment might be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll expand the comment. For completeness here:
get_users_in_room_with_profiles
reads from theroom_memberships
table. That contains adisplay_name
andavatar_url
specific to this room (it doesn't read from theprofiles
table). With my change, we no longer upsertuser_directory
anduser_directory_search
rows for local users in this function, but we do continue to do so for remote users.I meant the TODO as a marker to track where the data we don't want to leak comes from.