Closed Bug 2068865 Opened 2 months ago Closed 2 months ago

Implement rust credit card storage adapter

Categories

(Toolkit :: Form Autofill, task, P3)

task

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: dimi, Assigned: dimi)

References

(Blocks 1 open bug)

Details

Attachments

(2 external files)

No description provided.

Present the AutofillRecords credit card interface over the Application Services
autofill Store, so it can later back FormAutofillStorage.getCreditCards().
Nothing constructs it yet.

Shaped after RustAutofillAddressStorage: the same method surface in the same
order, and the same two pure module-level conversion functions either side of
it. What differs follows from the Rust credit card schema rather than from a
different design.

The number is stored encrypted and only its last four digits in the clear, so
this store derives the masked cc-number on read where the JSON store stores it
and derives the ciphertext instead. #stripComputedFields and #encryptNumber are
the two ends of that, and they sit where CreditCardsBase puts them: the stored
record is decrypted before it can be merged from, and the merged record is
validated, because a number the caller did not restate arrives from the stored
side. update() recomputes before writing, as the JSON store does before it
saves -- normalizeFields derives cc-type from the number, so an edit that did
not carry one would otherwise clear the stored type.

#stripComputedFields drops the mask before it tries to restore the number, and
puts it back only on a decryption that succeeded. scrubEncryptedData() blanks
cc_number_enc and leaves cc_number_last_4, so a record can hold a mask with no
number behind it; keeping that mask through the merge would encrypt it and
store it as the card number.

The encryption is interim. It uses OSKeyStore, the same mechanism and the same
key as the JSON store's cc-number-encrypted, so a number written here is
readable by every existing consumer and no new key is introduced; the store
treats cc_number_enc as an opaque string on every path this adapter uses. The
Application Services key API is deliberately unused: nothing in the tree
consumes it, and who owns that key is being settled separately.

isStoredCreditCardField() excludes the fields derived on read, cc-type and
cc-number among them, so a later comparison against the JSON store does not read
a changed detection table or a rebuilt mask as an unfaithful copy. Only the last
four digits survive, so that mask is rebuilt at a fixed width and a 14- or
15-digit card reads back wider than it was written.

The store has no bulk import, no tombstone import, no delete-all and no bridged
sync engine for credit cards, and no column for billingAddressGUID, so unlike
the address adapter this one has no addManyWithMeta(), addManyTombstones(),
wipe() or bridgedEngine(). A migration and a sync engine need those from
application-services first.

test_rust_autofill_credit_card_adapter.js covers the round trip with the number
encrypted and read back masked, an edit that does not restate the number, one
that replaces it, an update after a scrub, and get() telling a missing record
from an unreadable one.

Brings in the credit card bulk-import APIs P2 needs: add_credit_card_with_meta,
add_many_credit_cards_with_meta, update_credit_card_with_meta,
add_many_credit_card_tombstones and delete_all_credit_cards. They mirror the
address with-meta API, so an application copying a credit card collection into
this store keeps each record's guid, timestamps and change counter rather than
having the store generate them. Autofill also now sanitizes timestamps from
untrusted sources, as logins did in bug 2066257.

The revision this replaces, 5a011ab3, was a feature branch tip rather than a
commit on main. Both of its code changes are on main verbatim, so returning to
main reverts nothing. The other eight commits in the delta are unrelated to this
work: the logins half of bug 2066257, an ads-client refactor and its new
blocks request parameter, an address time_last_modified fix, and refreshed
search-config dumps.

No new crates, so Cargo.lock only gains the types dependency logins picked up.
The regenerated bindings add autofill doc comments and the ads-client field, and
the UniFFI function table moves only for the autofill methods added here.

Attachment #9635865 - Attachment description: WIP: Bug 2068865 - Add the Rust credit card storage adapter r=joschmidt,#credential-management-reviewers → Bug 2068865 - P2. Add the Rust credit card storage adapter r=joschmidt
Attachment #9635865 - Attachment description: Bug 2068865 - P2. Add the Rust credit card storage adapter r=joschmidt → Bug 2068865 - Add the Rust credit card storage adapter r=joschmidt
Pushed by dlee@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4b4f1cc5a102 https://hg.mozilla.org/integration/autoland/rev/a157c2c3f114 Add the Rust credit card storage adapter r=joschmidt,credential-management-reviewers
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
Blocks: 2071247
Blocks: 2074007
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: