Add predefined search for TOTP entries
This PR implements a predefined search to find all TOTP entries, addressing the feature request for a dedicated OTP page similar to Google Authenticator.
Changes Made
Core Functionality
-
Added
is:totpsearch support inEntrySearcherthat leverages the existingEntry::hasTotp()method -
Added "TOTP Entries" predefined search in
TagModelfollowing the same pattern as existing searches like "Expired" and "Weak Passwords"
Implementation Details
The implementation follows the established patterns in the codebase:
// EntrySearcher now supports case-insensitive TOTP search
} else if (term.word.compare("totp", Qt::CaseInsensitive) == 0) {
found = entry->hasTotp();
break;
}
// TagModel includes new predefined search
<< qMakePair(tr("TOTP Entries"), QString("is:totp"));
User Experience
Users can now:
- Select "TOTP Entries" from the predefined searches in the left sidebar
- Use
is:totpsearch query directly in the search bar - Use
!is:totpto exclude TOTP entries from results - Case-insensitive search (
is:TOTPworks the same asis:totp)
Testing
Added comprehensive test coverage in TestEntrySearcher::testTotpSearch() that validates:
- Positive matching (entries with TOTP are found)
- Negative matching (entries without TOTP are excluded)
- Case-insensitive search functionality
- Exclusion operator support
Code Quality
- Minimal changes: Only 4 lines of production code added
-
Follows existing patterns: Uses the same structure as
is:expiredandis:weaksearches -
Translatable: Uses
tr()function for internationalization - Well-tested: Includes focused unit tests
This provides users with the requested dedicated view for TOTP entries, making it easy to manage two-factor authentication codes within KeePassXC.
Fixes #9362.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Change this from is:totp to has:totp. This will require you to introduce a new "has" prefix for EntrySearcher.
Change this from
is:totptohas:totp. This will require you to introduce a new "has" prefix for EntrySearcher.
Done. Changed from is:totp to has:totp and introduced the new "has" prefix for EntrySearcher. The implementation adds a new Field::Has enum value and moves the TOTP search logic to the new case while maintaining the existing "is" prefix for other searches like "expired" and "weak". All tests and predefined searches have been updated accordingly. Commit: a9a4176
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
224.0.0.251esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
Codecov Report
:x: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 63.87%. Comparing base (3c7c3b0) to head (8773d49).
:warning: Report is 67 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/core/EntrySearcher.cpp | 71.43% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #12199 +/- ##
===========================================
- Coverage 63.87% 63.87% -0.00%
===========================================
Files 369 369
Lines 38935 38943 +8
===========================================
+ Hits 24866 24871 +5
- Misses 14069 14072 +3
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.