-
Notifications
You must be signed in to change notification settings - Fork 927
[PM-27657] KDF silent update with MasterPasswordUnlock data #6113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @andrebispo5's task —— View job Code Review Complete ✓I've reviewed the changes in this PR that add KDF silent update support for the Summary of ChangesThe PR modifies the Files Changed:
Critical Issues❌ Incomplete Test Coverage (Severity: High) The test at line 1868 only verifies that Missing Test Case: There should be a dedicated test method that specifically unlocks the vault using
Current Issue: The existing test Suggested Test Structure@Test
fun `unlockVault with MasterPasswordUnlock should update KDF to minimums if needed`() = runTest {
// Test setup with InitUserCryptoMethod.MasterPasswordUnlock
// ...
val result = vaultLockManager.unlockVault(
userId = USER_ID,
initUserCryptoMethod = InitUserCryptoMethod.MasterPasswordUnlock(
password = masterPassword,
masterPasswordUnlock = mockMasterPasswordUnlockData
),
// ... other params
)
assertEquals(VaultUnlockResult.Success, result)
coVerify(exactly = 1) {
kdfManager.updateKdfToMinimumsIfNeeded(password = masterPassword)
}
}Suggested ImprovementsThe verification at line 1868 is placed in a test that uses Recommendation: Either:
💡 Code Quality (Priority: Low) The However, the implementation at line 260-285 ( Suggested Refactoringprivate fun extractPasswordOrNull(initUserCryptoMethod: InitUserCryptoMethod): String? =
when (initUserCryptoMethod) {
is InitUserCryptoMethod.Password -> initUserCryptoMethod.password
is InitUserCryptoMethod.MasterPasswordUnlock -> initUserCryptoMethod.password
else -> null
}
private suspend fun updateKdfIfNeeded(initUserCryptoMethod: InitUserCryptoMethod) {
val password = extractPasswordOrNull(initUserCryptoMethod) ?: return
// ... existing implementation
}
private suspend fun hashAndStoreMasterPassword(...) {
val password = extractPasswordOrNull(initUserCryptoMethod) ?: return
// ... existing implementation
}This would make the code more maintainable and reduce the risk of the two implementations diverging. Good Practices Observed✓ Exhaustive Action Items
Coverage Report AnalysisThe Codecov report shows 77.78% patch coverage with 2 lines missing coverage at |
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6113 +/- ##
==========================================
- Coverage 84.82% 84.81% -0.02%
==========================================
Files 721 735 +14
Lines 52824 53144 +320
Branches 7667 7676 +9
==========================================
+ Hits 44808 45074 +266
- Misses 5328 5379 +51
- Partials 2688 2691 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-27657
📔 Objective
This pull request updates the logic for updating KDF (Key Derivation Function) settings in the vault lock management code to support additional authentication methods, and ensures that the corresponding unit test is updated to reflect this change. The main focus is to allow KDF updates when unlocking with either the standard password or the master password unlock method.
Vault lock management improvements:
VaultLockManagerImplto support KDF updates for bothInitUserCryptoMethod.PasswordandInitUserCryptoMethod.MasterPasswordUnlockby extracting the password from either method and passing it tokdfManager.updateKdfToMinimumsIfNeeded.Testing improvements:
VaultLockManagerTestto explicitly callkdfManager.updateKdfToMinimumsIfNeededwith the master password unlock init method, ensuring the new logic is covered by tests.⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes