8000 [PM-19383] add admin endpoint, fix typecasting error by BTreston · Pull Request #5681 · bitwarden/server · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PM-19383] add admin endpoint, fix typecasting error #5681

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

Merged
merged 4 commits into from
May 5, 2025

Conversation

BTreston
Copy link
Contributor
@BTreston BTreston commented Apr 21, 2025

🎟️ Tracking

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

📔 Objective

Fixes admins not being able to manage attachments

Clients Pr: bitwarden/clients#14363

📸 Screenshots

Screen.Recording.2025-04-21.at.2.47.39.PM.mov

⏰ 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 Apr 21, 2025

Logo
Checkmarx One – Scan Summary & Details7ab6103b-776d-4138-955b-e3900c667888

New Issues (1)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Billing/Controllers/PayPalController.cs: 52
detailsMethod PostIpn at line 52 of /src/Billing/Controllers/PayPalController.cs gets a parameter from a user request from PostIpn. This parameter value...
ID: BGMwzS5JLhvHYQGU%2B3b8je5dzAA%3D
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/AdminConsole/Controllers/OrganizationIntegrationConfigurationController.cs: 22
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationIntegrationController.cs: 23
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationIntegrationController.cs: 54
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationIntegrationConfigurationController.cs: 81
MEDIUM CSRF /src/Api/AdminConsole/Controllers/SlackIntegrationController.cs: 47

Copy link
codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 47.18%. Comparing base (b38c752) to head (d001e1d).
Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
src/Api/Vault/Controllers/CiphersController.cs 0.00% 11 Missing ⚠️
...re/Vault/Services/Implementations/CipherService.cs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5681      +/-   ##
==========================================
+ Coverage   46.85%   47.18%   +0.32%     
==========================================
  Files        1615     1633      +18     
  Lines       73587    74207     +620     
  Branches     6622     6683      +61     
==========================================
+ Hits        34482    35015     +533     
- Misses      37660    37740      +80     
- Partials     1445     1452       +7     

☔ 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.

@BTreston BTreston requested a review from r-tome April 22, 2025 17:27
@BTreston BTreston changed the title add admin endpoint, fix typecasting error [PM-19383] add admin endpoint, fix typecasting error Apr 22, 2025
@@ -891,7 +891,7 @@ private async Task<DeleteAttachmentResponseData> DeleteAttachmentAsync(Cipher ci

// Update the revision date when an attachment is deleted
cipher.RevisionDate = DateTime.UtcNow;
await _cipherRepository.ReplaceAsync((CipherDetails)cipher);
await _cipherRepository.ReplaceAsync(cipher);
Copy link
Contributor

Choose a reason for hiding this comment

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

Was a runtime error occurring because of the cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes:

Bit.Api.Utilities.ExceptionHandlerFilterAttribute[0]
      Unable to cast object of type 'Bit.Core.Vault.Entities.Cipher' to type 'Bit.Core.Vault.Models.Data.CipherDetails'.
      System.InvalidCastException: Unable to cast object of type 'Bit.Core.Vault.Entities.Cipher' to type 'Bit.Core.Vault.Models.Data.CipherDetails'.
         at Bit.Core.Vault.Services.CipherService.DeleteAttachmentAsync(Cipher cipher, MetaData attachmentData) in /Users/brandontreston/development/server/src/Core/Vault/Services/Implementations/CipherService.cs:line 894

I'll investigate this a bit more and see what we need here and why a Cipher object is just working here.

Copy link
Contributor Author
@BTreston BTreston Apr 23, 2025

Choose a reason for hiding this comment

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

At a first glance, it seems to be because Cipher is a superclass of CipherOrganizationDetails => CipherDetails. It works because it still has the data we need to be able to update the Cipher in the DB. Only concern here is that it leaves a {} in the DB after delete instead of null. Not sure how big an issue that really is though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Without the cast I'm now getting an error trying to delete an attachment from the web vault.

I'm jumping in an out of meetings for a majority of my day today so I haven't had a chance to dig into why yet.
cc: @shane-melton @gbubemismith

Screenshot 2025-04-24 at 10 14 18 AM

Copy link
Contributor Author
@BTreston BTreston Apr 25, 2025

Choose a reason for hiding this comment

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

This is fixed in this commit. It's odd that we retrieve this object that is a CipherDetails object but we're passing it to methods explicitly expecting Cipher only to seemingly "cast" it back to its original type. Might be a 🌱 for a refactor (out of scope for this).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for looking into it! I agree there is some oddity here. I'm able to delete attachments from password manager now ✅

r-tome
r-tome previously approved these changes Apr 24, 2025
r-tome
r-tome previously approved these changes Apr 28, 2025
nick-livefront
nick-livefront previously approved these changes Apr 28, 2025
@BTreston BTreston dismissed stale reviews from nick-livefront and r-tome via 1b69081 April 29, 2025 20:24
@BTreston BTreston merged commit e2f0ddf into main May 5, 2025
53 checks passed
@BTreston BTreston deleted the ac/pm-19383-admins-unable-to-delete-attachments branch May 5, 2025 17:36
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
0