-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-25458] Add error handling stubs & logging for critical decrypt paths #16284
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
base: main
Are you sure you want to change the base?
Conversation
New Issues (5)Checkmarx found the following issues in this Pull Request
Fixed Issues (2041)Great job! The following issues were fixed in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16284 +/- ##
=======================================
Coverage 37.45% 37.45%
=======================================
Files 3352 3352
Lines 95228 95248 +20
Branches 14395 14395
=======================================
+ Hits 35668 35679 +11
- Misses 57987 57996 +9
Partials 1573 1573 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ients into km/decrypt-failure-handling
|
console.log( | ||
"[CollectionAdminView/fromCollectionResponse] Failed to decrypt the collection name", | ||
e, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log( | |
"[CollectionAdminView/fromCollectionResponse] Failed to decrypt the collection name", | |
e, | |
); | |
console.error( | |
"[CollectionAdminView/fromCollectionResponse] Failed to decrypt the collection name", | |
e, | |
); |
// Note: This should be replaced by the owning team with appropriate, domain-specific behavior. | ||
// eslint-disable-next-line no-console | ||
console.error("[TokenService] Error decrypting access token", e); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Note: This should be replaced by the owning team with appropriate, domain-specific behavior. | |
// eslint-disable-next-line no-console | |
console.error("[TokenService] Error decrypting access token", e); | |
throw e; | |
// Note: This should be replaced by the owning team with appropriate, domain-specific behavior. | |
this.logService.error("[TokenService] Error decrypting access token", e); | |
throw e; |
Looks like logService is available here.
@@ -36,10 +36,12 @@ export abstract class EncryptService { | |||
abstract decryptString(encString: EncString, key: SymmetricCryptoKey): Promise<string>; | |||
/** | |||
* Decrypts an EncString to a Uint8Array | |||
* @throws IMPORTANT: This throws if decryption fails. If decryption failures are expected to happen, | |||
* the callsite should log where the failure occurred, and handle it by domain specifc logic (e.g. show a UI error). | |||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Shouldn't this be on decryptString
?
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error("[EncString Generic Decrypt] failed to decrypt encstring", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the context
input parameter to the log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vault changes look good
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-25458
📔 Objective
There is currently a set of bugs that is hard to track down, and blocks vault initialization. This has two causes:
Each callsite has to appropriately handle the public contract. In this case, the PR adds stubs that at least log an error and the callsite for debugging, and re-throw. This can be replaced by the owning teams, once they handle the errors appropriately with domain specific logic. That is left out of this PR since I cannot make assumptions about what the appropriate behavior is. Roughly, it should not block the app from loading (probably), and set appropriate UI values, while at the same time ensuring default values don't leak back into being re-encrypted, when an item is edited.
Alternatively, most of the covered code is also being migrated to the SDK, so we can drop the TS code entirely, and handle in rust, which has much nicer tooling. But we do want the debuggability in the meantime to fix existing issues.
📸 Screenshots
⏰ 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