-
Notifications
You must be signed in to change notification settings - Fork 251
Logins: Breach Alerts #7127
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
Logins: Breach Alerts #7127
Conversation
65b3c0b to
1924a2e
Compare
bendk
left a comment
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.
Looks good to me. I had a couple suggestions, but nothing blocking. I don't need to re-review.
components/logins/src/schema.rs
Outdated
| db.execute_batch("SELECT timeLastBreachAlertDismissed FROM loginsL") | ||
| .unwrap(); | ||
| db.execute_batch("SELECT timeLastBreachAlertDismissed FROM loginsM") | ||
| .unwrap(); |
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.
Now's probably a good time to add a schema upgrade test like the one suggest has:
application-services/components/suggest/src/schema.rs
Lines 1013 to 1018 in eea8d80
| fn test_all_upgrades() { | |
| let db_file = | |
| MigratedDatabaseFile::new(SuggestConnectionInitializer::default(), V16_SCHEMA); | |
| db_file.run_all_upgrades(); | |
| db_file.assert_schema_matches_new_database(); | |
| } |
It should be fairly easy, the only real work is finding an older version of the schema to use as the base. We could just use v2 for that.
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.
There was already a specific schema upgrade test for version 2 (test_upgrade_v1), which I had previously only extended for the new schema, but which I have now generalized and simplified and adapted to the style of the test from Suggest.
That's a great improvement, thanks for the hint!
ba20613 to
2730114
Compare
Extend the Logins API with breach-related metadata and queries, migrate the database to version 3, and add primitives to record breaches, evaluate potential exposure, and track alert dismissals. Heap-allocate login struct in LocalLogin::Alive and ignore the enum size warning for the `BulkResultEntry`.
This PR adds Breach Alert support to the Logins component by extending the Logins API and introducing breach-related metadata and queries. It includes a database migration to version 3 and provides the necessary primitives for consumers (e.g. Firefox Desktop) to record breaches, evaluate potential exposure, and track alert dismissals.
New
Loginpropertiestime_of_last_breachSystem time in milliseconds corresponding to the breach’s
BreachDate.time_last_breach_alert_dismissedSystem time in milliseconds indicating when the user dismissed the breach alert.
Additional
LoginStoreAPI methodsrecord_breach(id, timestamp)Stores a known breach date for a login.
In Firefox Desktop this is updated once per session from Remote Settings.
reset_all_breaches()Removes all recorded breaches for all logins (i.e. sets
time_of_last_breachtonull).is_potentially_breached(id)Determines whether a login’s password is potentially breached, based on the breach date and the time of the last password change.
record_breach_alert_dismissal(id)Records that the user dismissed the breach alert for a login using the current time.
record_breach_alert_dismissal_time(id, timestamp)Records that the user dismissed the breach alert for a login at a specific time. This is primarily useful for testing or when syncing dismissal times from other devices. For normal usage, prefer
record_breach_alert_dismissalwhich automatically uses the current time.is_breach_alert_dismissed(id)Determines whether a breach alert has been dismissed, based on the breach date and the alert dismissal timestamp.
Pull Request checklist
[ci full]to the PR title.