Skip to content

Commit 9f7d150

Browse files
committed
bug(securityEvent): Add missing security event names to db
Because: - We're missing some security event names from some events in the db - And we're missing some security event names in the model - And some names have mismatching id This commit: - Updates all security event names in 'fxa.securityEventNames' that are missing - Aligns all values on the model to match the db as source of truth
1 parent 3fcb903 commit 9f7d150

5 files changed

Lines changed: 38 additions & 12 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
3+
-- Bump these to your next migration numbers
4+
CALL assertPatchLevel('175');
5+
6+
INSERT INTO securityEventNames (name) VALUES
7+
('account.password_upgrade_success'),
8+
('account.password_upgraded'),
9+
('account.recovery_phone_setup_failed'),
10+
('account.mfa_send_otp_code'),
11+
('account.mfa_verify_otp_code_success'),
12+
('account.mfa_verify_otp_code_failed');
13+
14+
UPDATE dbMetadata SET value = '176' WHERE name = 'schema-patch-level';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
--
3+
-- -- Remove only the rows this migration inserted.
4+
-- DELETE FROM securityEventNames WHERE name = 'account.password_upgrade_success';
5+
-- DELETE FROM securityEventNames WHERE name = 'account.password_upgraded';
6+
-- DELETE FROM securityEventNames WHERE name = 'account.recovery_phone_setup_failed';
7+
-- DELETE FROM securityEventNames WHERE name = 'account.mfa_send_otp_code';
8+
-- DELETE FROM securityEventNames WHERE name = 'account.mfa_verify_otp_code_success';
9+
-- DELETE FROM securityEventNames WHERE name = 'account.mfa_verify_otp_code_failed';
10+
--
11+
-- UPDATE dbMetadata SET value = '175' WHERE name = 'schema-patch-level';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"level": 175
2+
"level": 176
33
}

packages/fxa-auth-server/lib/routes/recovery-phone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ class RecoveryPhoneHandler {
631631
if (!replacedSuccess) {
632632
await this.glean.twoStepAuthPhoneReplace.failure(request);
633633
this.statsd.increment('account.recoveryPhone.changePhoneNumber.failure');
634-
await recordSecurityEvent('account.recovery_phone_replace_failed', {
634+
await recordSecurityEvent('account.recovery_phone_replace_failure', {
635635
db: this.db,
636636
request,
637637
});

packages/fxa-shared/db/models/auth/security-event.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@ export const EVENT_NAMES: Record<string, number> = {
4747
'account.recovery_codes_created': 33,
4848
'account.recovery_codes_signin_complete': 34,
4949
'account.must_reset': 35,
50-
'account.recovery_phone_reset_password_success': 36,
50+
'account.recovery_phone_reset_password_complete': 36,
5151
'account.recovery_phone_reset_password_failed': 37,
52-
'account.password_upgrade_success': 38,
53-
'account.password_upgraded': 39,
54-
'account.recovery_phone_setup_failed': 40,
55-
'account.recovery_phone_replace_failed': 41,
56-
'account.recovery_phone_replace_complete': 42,
57-
'account.recovery_phone_reset_password_complete': 43,
58-
'account.mfa_send_otp_code': 44,
59-
'account.mfa_verify_otp_code_success': 45,
60-
'account.mfa_verify_otp_code_failed': 46,
52+
'account.recovery_phone_replace_complete': 38,
53+
'account.recovery_phone_replace_failure': 39,
54+
'account.two_factor_replace_success': 40,
55+
'account.two_factor_replace_failure': 41,
56+
'account.password_upgrade_success': 42,
57+
'account.password_upgraded': 43,
58+
'account.recovery_phone_setup_failed': 44,
59+
'account.mfa_send_otp_code': 45,
60+
'account.mfa_verify_otp_code_success': 46,
61+
'account.mfa_verify_otp_code_failed': 47,
6162
} as const;
6263

6364
export type SecurityEventNames = keyof typeof EVENT_NAMES;

0 commit comments

Comments
 (0)