Skip to content

Commit 0d690b3

Browse files
Clear passwords that don't decrypt (microsoft#159506)
If a password is not decrypted properly, then it should be removed from the secret storage because it's essentially dead. Fixes microsoft#151654
1 parent 1715e06 commit 0d690b3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/vs/workbench/api/browser/mainThreadSecretState.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
6565
if (value.extensionId === extensionId) {
6666
return value.content;
6767
}
68-
} catch (e) {
69-
this.logService.error(e);
70-
throw new Error('Cannot get password');
68+
} catch (parseError) {
69+
this.logService.error(parseError);
70+
71+
// If we can't parse the decrypted value, then it's not a valid secret so we should try to delete it
72+
try {
73+
await this.credentialsService.deletePassword(fullKey, key);
74+
} catch (e) {
75+
this.logService.error(e);
76+
}
77+
78+
throw new Error('Unable to parse decrypted password');
7179
}
7280
}
7381

0 commit comments

Comments
 (0)