-
Notifications
You must be signed in to change notification settings - Fork 496
Fix automatic data reset on for users affected by encryption issues (EXPOSUREAPP-3313, EXPOSUREAPP-3335) #1433
Fix automatic data reset on for users affected by encryption issues (EXPOSUREAPP-3313, EXPOSUREAPP-3335) #1433
Conversation
Marked as |
…eption`. This causes us to continue with `KeyException` which then fails the message matching test. As the underlying Tink code throws the GeneralSecurityException first, we check the type of the last exception.
They may not have read the dialog message completely or want to re-read it.
76d89dc
to
e4e2280
Compare
I rebased this against 1.5.x. I added an additional test case case and changed the explanation dialog behavior slightly. Before doing on device tests, please review the code and test cases again. withSecurityCatch {
try {
factory.create(ENCRYPTED_SHARED_PREFERENCES_FILE)
// ################
throw KeyException(
"Permantly failed to instantiate encrypted preferences",
SecurityException(
"Could not decrypt key. decryption failed",
GeneralSecurityException("decryption failed")
)
)
// ################
} catch (e: Exception) {
if (encryptionErrorResetTool.tryResetIfNecessary(e)) {
Timber.w("We could recovery from this error via reset. Now retrying.")
factory.create(ENCRYPTED_SHARED_PREFERENCES_FILE)
} else {
throw e
}
}
} |
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
@BMItter will also review this PR, as it is not testable for our testers. |
LGTM, also toast handling i.o, exception handling i.o |
The automatic data reset for users affected by #642 does unfortunately not match☹️ .
We overlooked that
KeyException
is a subclass ofGeneralSecurityException
.This causes us to abort early and continue with
KeyException
which then fails the error message matching test.As the underlying Tink code throws the GeneralSecurityException first and should have no further causes, I've changed the code to not iterate, but directly pick the last exception in the list of causes.
Test
This can't be easily tested on device.
Understand the original exception flow in the stracktrace provided by a user and confirm that this is now fixed and the unit test correctly covers this case.