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-11162] Assign To Collections Permission Update #11367

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

Conversation

Jingo88
Copy link
Contributor

@Jingo88 Jingo88 commented Oct 2, 2024

🎟️ Tracking

PM-11162

📔 Objective

Only users with Can Edit permissions will be allowed to Assign To Collections. If the user has Can Edit Except Password they should not see Assign To Collections in the menu of the item row.

📸 Screen Recording

PM-11162.mov

Desktop Permissions

PM-11162-Desktop.mov

Screenshot of CLI error when trying to add collection to Can Edit Except PW item

PM-11162-cli-throw-error

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

@Jingo88 Jingo88 requested a review from a team as a code owner October 2, 2024 18:52
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 33.19%. Comparing base (0377775) to head (b94ee53).
Report is 26 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...lt/components/vault-items/vault-items.component.ts 0.00% 4 Missing ⚠️
...mponents/vault-items/vault-cipher-row.component.ts 0.00% 1 Missing ⚠️
libs/common/src/vault/models/view/cipher.view.ts 0.00% 1 Missing ⚠️
...nts/item-details/item-details-section.component.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11367      +/-   ##
==========================================
+ Coverage   33.16%   33.19%   +0.03%     
==========================================
  Files        2779     2780       +1     
  Lines       86228    86417     +189     
  Branches    16421    16472      +51     
==========================================
+ Hits        28597    28688      +91     
- Misses      55365    55443      +78     
- Partials     2266     2286      +20     

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

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Logo
Checkmarx One – Scan Summary & Detailsacff5776-e0cc-4b89-ae14-8bbab38f11af

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html: 19 Attack Vector
MEDIUM Client_Privacy_Violation /libs/tools/send/send-ui/src/send-form/components/options/send-options.component.ts: 52 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45

Copy link
Member

@shane-melton shane-melton left a comment

Choose a reason for hiding this comment

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

The change to vault-items looks good!

However, we need to make a similar change to the item-details-section.component for the new CipherForm. It also allows users to modify a cipher's collections without the "Assign To Collections" dialog so we need to adjust that component to disable the collections control when !cipher.viewPassword

@Jingo88 Jingo88 added the needs-qa Marks a PR as requiring QA approval label Oct 2, 2024
return org.id === this.originalCipherView.organizationId;
});

const filteredCollections = this.originalCipherView.collectionIds.find((id) => {
Copy link
Member

Choose a reason for hiding this comment

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

⚠️ this.originalCipherView can be null when creating a new cipher and this will throw.

filteredCollections?.length > 0 ||
(this.originalCipherView.edit && this.originalCipherView.viewPassword)
) {
this.showCollectionsControl = true;
Copy link
Member

Choose a reason for hiding this comment

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

⚠️ We only want to disable the collection control when they don't have access to assign to other collections. Disabling allows the user to still see what its assigned to, otherwise there is no way to view that information.

Copy link
Member

Choose a reason for hiding this comment

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

🎨 I think we can put a check in the initFromExistingCipher method after the call to updateCollectionOptions() to check if originalCipher.edit && originalCipher.viewPassword. If that is false then we should call this.itemDetailsForm.controls.collectionIds.disable() which will prevent the user from changing the value.

Then we wouldn't need to modify the updateCollectionOptions() method.

@@ -191,7 +191,10 @@ export class VaultItemsComponent {
}

const organization = this.allOrganizations.find((o) => o.id === cipher.organizationId);
return (organization.canEditAllCiphers && this.viewingOrgVault) || cipher.edit;
return (
Copy link
Member

Choose a reason for hiding this comment

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

💭 I noticed this returned value is used by the vault-cipher-row.component to show the attachments button. I don't think we want to disable that with when viewPassword == false so we may need to introduce a new option specifically for assigning collections (e.g. canAssignCollections)

@Jingo88 Jingo88 requested a review from a team as a code owner October 14, 2024 19:31
@Jingo88 Jingo88 requested a review from eliykat October 14, 2024 19:31
this.canAssignCollections = true;
}

this.organizationService.get$(cipher.organizationId).subscribe((org) => {
Copy link
Member

Choose a reason for hiding this comment

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

This observable is not unsubscribed.

Comment on lines 72 to 73
if (cipher?.organizationId == null) {
this.canAssignCollections = true;
Copy link
Member

Choose a reason for hiding this comment

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

I don't follow this - if the cipher isn't in an organization, you can't assign it to a collection.

Copy link
Member

Choose a reason for hiding this comment

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

@shane-melton this is the file that tagged me for a review, but I think this would fall under Vault ownership under the team boundaries we discussed. Do you agree? If so I can just rubber stamp this review once Vault have approved, but if you could then move it into Vault ownership that would be really helpful.

Also, I was trying to figure out how this is used. I found it in desktop, but there's also a subclass in web which appears unused: https://github.com/bitwarden/clients/blob/main/apps/web/src/app/vault/individual-vault/collections.component.ts#L1.

}

this.organizationService.get$(cipher.organizationId).subscribe((org) => {
this.canAssignCollections = org.canEditAllCiphers || (cipher.edit && cipher.viewPassword);
Copy link
Member

@eliykat eliykat Oct 16, 2024

Choose a reason for hiding this comment

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

org.canEditAllCiphers checks admin permissions. Do we recognise admin permissions from the individual vault on desktop? I thought we only recognised admin permissions in the Admin Console, regardless of client.

Copy link
Member

@eliykat eliykat Oct 16, 2024

Choose a reason for hiding this comment

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

Also, a canAssignToCollections() getter on CipherView might be a useful abstraction, but that's very much your call.

Copy link
Contributor Author

@Jingo88 Jingo88 Oct 16, 2024

Choose a reason for hiding this comment

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

Ah apologies! All this was a first draft in my brain and I was going to come back to it after working on some CLI stuff.

Thanks for the review, it was super helpful and got me reducing a ton of that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-qa Marks a PR as requiring QA approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants