Skip to content
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

[PM-11442] Emergency Cipher Viewing #12054

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nick-livefront
Copy link
Collaborator

@nick-livefront nick-livefront commented Nov 19, 2024

🎟️ Tracking

PM-11442

📔 Objective

The base component ngOnInit calculates the viewOnly property based on cipher edit and another property. In the case of emergency access, viewOnly should always be true so the user cannot edit or attempt to edit the cipher.

📸 Screenshots

Before After
emergency-before.mov
emergency-after.mov

🦮 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

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 73.13433% with 18 lines in your changes missing coverage. Please review.

Project coverage is 33.49%. Comparing base (7d6da0a) to head (ae25c8c).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...-history-v2/vault-password-history-v2.component.ts 57.14% 5 Missing and 1 partial ⚠️
...ncy-access/view/emergency-access-view.component.ts 45.45% 5 Missing and 1 partial ⚠️
...access/view/emergency-add-edit-cipher.component.ts 50.00% 2 Missing ⚠️
...ncy-access/view/emergency-view-dialog.component.ts 93.75% 1 Missing and 1 partial ⚠️
...ult/individual-vault/password-history.component.ts 0.00% 1 Missing ⚠️
...her-view/item-history/item-history-v2.component.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12054      +/-   ##
==========================================
+ Coverage   33.47%   33.49%   +0.02%     
==========================================
  Files        2878     2879       +1     
  Lines       89941    89982      +41     
  Branches    17116    17120       +4     
==========================================
+ Hits        30106    30142      +36     
- Misses      57455    57458       +3     
- Partials     2380     2382       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

- `ViewPasswordHistoryService` accepts a cipher id or CipherView. When a CipherView is included, the history component no longer has to fetch the cipher.
@nick-livefront
Copy link
Collaborator Author

@JaredSnider-Bitwarden @Patrick-Pimentel-Bitwarden @shane-melton

After chatting with Kyra on the QA side, we decided to also update the view modal to use the new extension-refresh version. 3ff8a60

This came with a tangental change for the password history component. Previously, the ViewPasswordHistoryService would accept a cipherId to try and fetch the cipher. This doesn't work during emergency access as permissions are little different. To accommodate, I made it so the service can also accept a full CipherView which is how the web & emergency access now utilize the service. 60e567b

@nick-livefront
Copy link
Collaborator Author

@JaredSnider-Bitwarden

Added the FIXME comment and associated ticket that we discussed offline: 0cde1e6

Copy link
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ This won't be used once the refresh flag is enabled, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is accurate!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 This may be somewhat out of scope. But I'm thinking we should probably just make the component only accept a CipherView which would let use remove all the redundant async init logic (which has likely already been done by the parent component that's opening the history view).

This would also let us simplify the viewPasswordHIstoryService by removing the generic CipherOption and different implementations. I think you've already done most of the leg work in this component so far, and I don't think we even use the CipherId variant after your changes here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, this does simplify the implementation across the board. It also makes the PasswordHistoryComponent more "view" oriented rather than containing logic to fetch the cipher.

3b68942


/**
* The ViewPasswordHistoryService is responsible for displaying the password history for a cipher.
*/
export abstract class ViewPasswordHistoryService {
abstract viewPasswordHistory(cipherId?: CipherId): Promise<void>;
export abstract class ViewPasswordHistoryService<CipherOption extends CipherId | CipherView> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Wait, how does this work for Browser? The only place that uses this service is the item-history-v2 component which will always request the CipherView variant. But, that variant will never be registered for the Browser client and should fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browser uses BrowserViewHistoryService which uses the CipherId. That is because the password history on the extension is a separate page and the cipher id is taken from the query params.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working through your previous comment and now I just hit the road block that you're mentioning here. I'm not sure how I missed this while testing. 🤔 back to the drawing board!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved by the fix in this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants