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-18088] Implement LimitItemDeletion permission checks for all cipher operations #5476

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

Conversation

r-tome
Copy link
Contributor

@r-tome r-tome commented Mar 7, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-18088

📔 Objective

Update CipherService and CiphersController to enforce the new LimitItemDeletion organization setting across all cipher operations when the feature flag is enabled.

Apply permission checks to single and bulk operations for Delete, SoftDelete, and Restore.

Refactor CiphersController to always retrieve CipherDetails, as the Manage property on NormalCipherPermissions must be checked when LimitItemDeletion is enabled.

Add unit tests to verify the new logic and ensure existing functionality works correctly when the feature flag is disabled.

⏰ 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

Copy link
Contributor

github-actions bot commented Mar 7, 2025

Logo
Checkmarx One – Scan Summary & Detailsea12ea84-75f7-4fab-a504-f7077b08ac97

New Issues (6)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationDomainController.cs: 94
detailsMethod Verify at line 94 of /src/Api/AdminConsole/Controllers/OrganizationDomainController.cs gets a parameter from a user request from orgId. This...
Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationDomainController.cs: 94
detailsMethod Verify at line 94 of /src/Api/AdminConsole/Controllers/OrganizationDomainController.cs gets a parameter from a user request from id. This pa...
Attack Vector
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 222
detailsMethod UpdateAuthRequestAsync at line 222 of /src/Core/Auth/Services/Implementations/AuthRequestService.cs sends user information outside the appli...
Attack Vector
LOW Log_Forging /src/Api/Tools/Controllers/SendsController.cs: 156
detailsMethod Post at line 156 of /src/Api/Tools/Controllers/SendsController.cs gets user input from element model. This element’s value flows through the...
Attack Vector
LOW Log_Forging /src/Api/Tools/Controllers/SendsController.cs: 166
detailsMethod PostFile at line 166 of /src/Api/Tools/Controllers/SendsController.cs gets user input from element model. This element’s value flows through...
Attack Vector
LOW Log_Forging /src/Api/Tools/Controllers/SendsController.cs: 272
detailsMethod Put at line 272 of /src/Api/Tools/Controllers/SendsController.cs gets user input from element model. This element’s value flows through the ...
Attack Vector
Fixed Issues (5)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/Controllers/CollectionsController.cs: 143
MEDIUM CSRF /src/Api/Public/Controllers/CollectionsController.cs: 87
MEDIUM CSRF /src/Api/Controllers/CollectionsController.cs: 171
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 217
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38

Copy link

codecov bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 78.33333% with 26 lines in your changes missing coverage. Please review.

Project coverage is 44.61%. Comparing base (6510f2a) to head (7e344d0).

Files with missing lines Patch % Lines
src/Api/Vault/Controllers/CiphersController.cs 59.25% 18 Missing and 4 partials ⚠️
...re/Vault/Services/Implementations/CipherService.cs 93.93% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5476      +/-   ##
==========================================
+ Coverage   44.52%   44.61%   +0.09%     
==========================================
  Files        1538     1538              
  Lines       70582    70667      +85     
  Branches     6316     6327      +11     
==========================================
+ Hits        31426    31531     +105     
+ Misses      37810    37786      -24     
- Partials     1346     1350       +4     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@r-tome r-tome force-pushed the ac/pm-18088/update-authorization-checks-to-use-new-methods branch from ce387d0 to 450f058 Compare March 10, 2025 15:56
Base automatically changed from ac/pm-18088/update-authorization-checks-to-use-new-methods to main March 11, 2025 10:10
r-tome added 6 commits March 11, 2025 10:16
…re flag support

- Add new method `CanDeleteOrRestoreCipherAsAdminAsync` in CiphersController
- Update NormalCipherPermissions to support more flexible cipher type checking
- Modify CipherService to use new permission checks with feature flag
- Refactor test methods to support new permission logic
- Improve authorization checks for organization cipher management
- Update CiphersController to use GetByIdAsync with userId
- Modify NormalCipherPermissions to remove unnecessary type casting
- Update ICipherService and CipherService method signatures to use CipherDetails
- Remove redundant type checking in CipherService methods
- Improve type consistency in cipher-related operations
…lag scenarios

- Add test methods for DeleteAdmin with edit and manage permission checks
- Implement tests for LimitItemDeletion feature flag scenarios
- Update test method names to reflect more precise permission conditions
- Improve test coverage for admin cipher deletion with granular permission handling
- Implement test methods for PutRestoreAdmin and PutRestoreManyAdmin
- Add scenarios for owner and admin roles with LimitItemDeletion feature flag
- Cover permission checks for manage and edit permissions
- Enhance test coverage for single and bulk cipher restore admin operations
- Verify correct invocation of RestoreAsync and RestoreManyAsync methods
…cking

- Remove unnecessary assertions for null checks
- Simplify mocking setup for cipher repository and service methods
- Clean up redundant type and data setup in test methods
- Improve test method clarity by removing extraneous code
…delete operations

- Implement test methods for RestoreAsync with org admin override and LimitItemDeletion feature flag
- Add scenarios for checking manage and edit permissions during restore operations
- Extend test coverage for DeleteAsync with similar permission and feature flag checks
- Enhance SoftDeleteAsync tests with org admin override and permission validation
- Improve test method names to reflect precise permission conditions
@r-tome r-tome force-pushed the ac/pm-18088/update-authorization-checks-to-use-new-methods-2 branch from 8109339 to 01452d4 Compare March 11, 2025 10:16
…delete operations

- Extend test methods for RestoreManyAsync with various permission scenarios
- Add test coverage for personal and organization ciphers in restore operations
- Implement tests for RestoreManyAsync with LimitItemDeletion feature flag
- Add detailed test scenarios for delete and soft delete operations
- Improve test method names to reflect precise permission and feature flag conditions
@r-tome r-tome changed the title Implement enhanced cipher deletion and restore permissions with featu… [PM-18088] Implement LimitItemDeletion permission checks for all cipher operations Mar 11, 2025
@r-tome r-tome marked this pull request as ready for review March 11, 2025 11:26
@r-tome r-tome requested a review from a team as a code owner March 11, 2025 11:26
@r-tome r-tome requested a review from nick-livefront March 11, 2025 11:26
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.

1 participant