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

Recovery: Fix backup change detection not working in rust #12160

Closed
wants to merge 5 commits into from

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Jan 19, 2024

Fixes element-hq/element-web#26792

React sdk was still making usage of client#getKeyBackupEnabled() that is deprecated and failing in rust stack.
That would cause the following dialog to not show up:

  • When the backup is deleted from another session
    image

  • When backup is reset from another session
    image

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

🐛 Bug Fixes

@BillCarsonFr BillCarsonFr added T-Task Refactoring, enabling or disabling functionality, other engineering tasks T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems and removed T-Task Refactoring, enabling or disabling functionality, other engineering tasks labels Jan 19, 2024
@@ -1675,7 +1675,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
let haveNewVersion: boolean | undefined;
let newVersionInfo: IKeyBackupInfo | null = null;
// if key backup is still enabled, there must be a new backup in place
if (cli.getKeyBackupEnabled()) {
const backupEnabled = (await cli.getCrypto()!.getActiveSessionBackupVersion()) !== null;
Copy link
Member

Choose a reason for hiding this comment

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

Could you just put a Boolean() cast here if the variable is called backupEnabled, or if it's staying as string | null, maybe call the variable backupVersion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Udpated. The logic has changed a bit also.

@@ -66,7 +65,7 @@ export default class NewRecoveryMethodDialog extends React.PureComponent<IProps>
const hackWarning = <p className="warning">{_t("encryption|new_recovery_method_detected|warning")}</p>;

let content: JSX.Element | undefined;
if (MatrixClientPeg.safeGet().getKeyBackupEnabled()) {
if (this.props.newVersionInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

this.props.newVersionInfo is of type IKeyBackupInfo. Won't that always be truthy?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this code was a bit confusing and I added a bit more.

So I looked at what it was doing, and updated it to make a bit more sense.
So the idea is that when we detect that the backup is removed/updated we want to notify the user.
I don't think it was that usefull to make a difference if the new backup is trusted or not as anyhow it was offering the option to go to settings. And from settings you can do what you want.

So basically there are 2 cases:

  • There is no backup anymore: Shows the dialog to setup a new one as a shortcut or go to settings
  • There is a new backup: Shows the dialog that notifies you with an option to open the settings.

I added playwrigth tests to test it for rust crypto.
Unfortunatly the detection of change on legacy crypto is harder to trigger.. I disabled the test for legacy for now.

I think that if we really want this feature, we should do it better and improve the code to detect backup changes

Copy link
Member Author

Choose a reason for hiding this comment

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

The other option would be to remove that feature until we have clearer requirements

@BillCarsonFr
Copy link
Member Author

Closing for now as the requirements are not clear enough, and the current solution only partially detect changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ElementR | Element R doesn't warn the user when the key backup has been deleted or reset from another session
3 participants