bitwarden / sdk

Bitwarden SDK.
Other
205 stars 37 forks source link

Fix save_credential failing when the selected cipher doesn't have a Passkey #831

Closed dani-garcia closed 3 weeks ago

dani-garcia commented 3 weeks ago

🎟️ Tracking

📔 Objective

The current call to get_selected_credential inside save_credential will try to fetch and decrypt the ciphers FIDO2 credentials, and error if they are not there.

This can only happen when creating a new Passkey, so instead of calling get_selected_credential we just get the value from the lock. The other places where get_selected_credential is used is in update_credential and right at the end of the assertion, register and authenticate operations, so those should be safe.

⏰ Reminders before review

🦮 Reviewer guidelines

github-actions[bot] commented 3 weeks ago

Logo Checkmarx One – Scan Summary & Detailsf2279d40-f563-4a0d-bb3e-bc48fa0ad283

No New Or Fixed Issues Found

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 59.23%. Comparing base (85bfa59) to head (0167bcc).

Files Patch % Lines
...ates/bitwarden/src/platform/fido2/authenticator.rs 0.00% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #831 +/- ## ========================================== - Coverage 59.27% 59.23% -0.04% ========================================== Files 186 186 Lines 12421 12428 +7 ========================================== Hits 7362 7362 - Misses 5059 5066 +7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dani-garcia commented 3 weeks ago

I also thought about entirely renaming the variable from selected_credential to selected_cipher here, knowing that the value doesn't necessarily need to contain a credential.

I didn't do it in this PR so we could get it resolved quickly but it might be worth considering.