Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy IPv4-prefix HMAC lookup path for security event IP matching in fxa-shared, now that all relevant rows are expected to be written using the post-FXA-13433 format.
Changes:
- Replace
whereIn(securityEvents.ipAddrHmac, [...])with a single-value equality predicate infindByUidAndIP. - Replace
whereIn(securityEvents.ipAddrHmac, [...])with a single-value equality predicate infindByUidAndIPAndVerifiedLogin. - Delete the unused
ipHmacLegacyhelper and inline the one-offBuffer.from(ipHmacKey)usage.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
nshirley
approved these changes
Aug 14, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Because
findByUidAndIPandfindByUidAndIPAndVerifiedLoginmatched both the new and the old HMAC withwhereIn.INlist never matches anything.This pull request
whereInwithandWhereonsecurityEvents.ipAddrHmacinfindByUidAndIPandfindByUidAndIPAndVerifiedLogin.ipHmacLegacyand the doc comment above it that named this ticket as the cleanup.Buffer.from(ipHmacKey)local, which only existed so two HMAC calls could share it.createalready callsipHmacthis way.Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-13667
Checklist
Put an
xin the boxes that applyHow to review (Optional)
packages/fxa-shared/db/models/auth/security-event.tsis the only file touched.sanitizeIp,ipHmac, the.limit(20), and the callers infxa-auth-server/lib/db.tsare all unchanged. The method signatures do not change, so no caller needs an edit.Screenshots (Optional)
Other information (Optional)
No test changes. Nothing exercised
ipHmacLegacy, and the onlysecurity-eventunit tests coversanitizeIp, which this leaves alone. Those 13 tests pass.One style note for reviewers: every other clause in these two queries uses
.where, and in Knex.andWhereis the same method. I used.andWherebecause the ticket asks for it by name. Say the word if you would rather see.wherefor consistency with the file.Verification I ran locally:
npx nx lint fxa-sharedpasses.npx tsc -p packages/fxa-shared/tsconfig.json --noEmitreports 45 errors. They are all Stripe API mismatches underlibs/paymentsandpackages/fxa-shared/payments, and none are indb/models/auth. This is a deletion from a widely consumed package, so the type check matters: it confirms nothing downstream depended on the removed helper.