Clear passwords that don't decrypt (#159506)

If a password is not decrypted properly, then it should be removed from the secret storage because it's essentially dead.

Fixes #151654
This commit is contained in:
Tyler James Leonhardt 2022-08-29 15:33:03 -07:00 committed by GitHub
parent 1715e06bb2
commit 0d690b3a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -65,9 +65,17 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
if (value.extensionId === extensionId) {
return value.content;
}
} catch (e) {
this.logService.error(e);
throw new Error('Cannot get password');
} catch (parseError) {
this.logService.error(parseError);
// If we can't parse the decrypted value, then it's not a valid secret so we should try to delete it
try {
await this.credentialsService.deletePassword(fullKey, key);
} catch (e) {
this.logService.error(e);
}
throw new Error('Unable to parse decrypted password');
}
}