Skip to content

[PM-32401] fix: Prevent copy TOTP autofill action for non-premium accounts#2479

Merged
matt-livefront merged 1 commit intomainfrom
matt/PM-32401-autofill-copy-totp
Mar 24, 2026
Merged

[PM-32401] fix: Prevent copy TOTP autofill action for non-premium accounts#2479
matt-livefront merged 1 commit intomainfrom
matt/PM-32401-autofill-copy-totp

Conversation

@matt-livefront
Copy link
Copy Markdown
Collaborator

@matt-livefront matt-livefront commented Mar 24, 2026

🎟️ Tracking

PM-32401

📔 Objective

Similar to #2467

This handles the case where a cipher is missing a username or password and autofill can't be performed. From the vault list, a user is given the option of copying individual fields from within a cipher. If the cipher contains a TOTP key, but the user doesn't have premium (or the org doesn't use TOTP), the "Copy TOTP" code option shouldn't be available in the menu.

📸 Screenshots

Before After
before after

@matt-livefront matt-livefront requested a review from a team as a code owner March 24, 2026 15:13
@matt-livefront matt-livefront added ai-review Request a Claude code review t:bug Change Type - Bug labels Mar 24, 2026
@github-actions github-actions bot added the app:password-manager Bitwarden Password Manager app context label Mar 24, 2026
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 24, 2026

Claude finished @matt-livefront's task in 2m 38s —— View job


Code Review: PM-32401 Prevent copy TOTP autofill action for non-premium accounts

  • Gather context and review PR changes
  • Review VaultRepository.swift changes
  • Review AutofillHelper.swift changes
  • Review test coverage
  • Post review findings

Summary

Clean PR — no issues found. The implementation correctly prevents the "Copy TOTP" option from appearing in the autofill menu for non-premium users when a cipher is missing a username or password.

Key changes reviewed:

  1. VaultRepository.swift — Added !totp.isEmpty guard to prevent empty TOTP strings from being treated as valid keys. Good defensive check.
  2. AutofillHelper.swift — Core fix: replaced the direct TOTP key check with the premium-aware getTOTPKeyIfAllowedToCopy method in handleMissingValueForAutofill, making it consistent with how TOTP access is gated elsewhere. The method is now correctly async to support this.
  3. Tests — Adequate coverage added for both the empty TOTP key case in VaultRepositoryTests and the non-premium / error paths in AutofillHelperTests.

The approach aligns well with the prior fix in #2467 and follows the existing patterns in the codebase. LGTM!

@github-actions
Copy link
Copy Markdown
Contributor

Logo
Checkmarx One – Scan Summary & Details292d9a16-6437-4d31-9658-c7610a0f31a8

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 96.61017% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.87%. Comparing base (e8ba73f) to head (b2f70cb).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...wardenShared/UI/Vault/Helpers/AutofillHelper.swift 90.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2479   +/-   ##
=======================================
  Coverage   86.86%   86.87%           
=======================================
  Files        1846     1846           
  Lines      163165   163208   +43     
=======================================
+ Hits       141741   141784   +43     
  Misses      21424    21424           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matt-livefront matt-livefront merged commit 6e510d6 into main Mar 24, 2026
22 checks passed
@matt-livefront matt-livefront deleted the matt/PM-32401-autofill-copy-totp branch March 24, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants