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-15621] Add support for handling multiple CommandResult validators. #5475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JimmyVo16
Copy link
Contributor

🎟️ Tracking

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

📔 Objective

  1. Add a method to make handling multiple CommandResult validators easier.
  2. Add test coverage.

Testing

This code is not wired up, but we have good test coverage for it.

⏰ 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

@JimmyVo16 JimmyVo16 self-assigned this Mar 6, 2025
Copy link

sonarqubecloud bot commented Mar 6, 2025

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Logo
Checkmarx One – Scan Summary & Details1dcc2d48-18f2-40d8-9460-d887d8c3ea5e

New Issues (2)

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 id. This pa...
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 orgId. This...
Attack Vector
Fixed Issues (3)

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/Controllers/CollectionsController.cs: 171
MEDIUM CSRF /src/Api/Public/Controllers/CollectionsController.cs: 87

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.50%. Comparing base (bea0d0d) to head (9281b86).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5475      +/-   ##
==========================================
+ Coverage   44.48%   44.50%   +0.01%     
==========================================
  Files        1533     1534       +1     
  Lines       71073    71093      +20     
  Branches     6379     6383       +4     
==========================================
+ Hits        31619    31639      +20     
  Misses      38087    38087              
  Partials     1367     1367              

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

@JimmyVo16 JimmyVo16 requested review from a team and jrmccannon March 7, 2025 14:48
jrmccannon
jrmccannon previously approved these changes Mar 7, 2025
Copy link
Member

@eliykat eliykat left a comment

Choose a reason for hiding this comment

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

I like it, just some minor feedback.


public static class CommandResultValidator
{
public static CommandResult ExecuteValidators(Func<CommandResult>[] validators)
Copy link
Member

Choose a reason for hiding this comment

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

"Run synchronous validators, then run async validators" is probably going to be a pretty common pattern. I suggest a combined interface, like ExecuteValidatorsAsync(Func<CommandResult>[], Func<Task<CommandResult>>[]) which can just handle it all for you. That itself would be asynchronous but doesn't matter as long as it's guaranteed to run synchronous validators first.


namespace Bit.Core.Validators;

public static class CommandResultValidator
Copy link
Member

@eliykat eliykat Mar 10, 2025

Choose a reason for hiding this comment

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

I know you two have discussed this so I may be out of the loop, but CommandResultValidator is an odd name to me. You're validating the inputs of the command, not the result. CommandRequestValidator, or just CommandValidator?

Copy link
Contributor

Choose a reason for hiding this comment

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

Jimmy and I talked about this and we are POC'ing some stuff now about this.

Mostly around the difference between Commands and Validators. There are a few more POC PRs we're putting together to try to get some common types out for everyone to look at.

@jrmccannon jrmccannon dismissed their stale review March 10, 2025 14:11

Reworking somethings. Don't want it to accidentally get merged without others evaluating it.

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.

3 participants