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-13014] - Add CanToggleStatus property to PolicyRepsonseModel based on Policy Validators #4940

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

Conversation

jrmccannon
Copy link
Contributor

@jrmccannon jrmccannon commented Oct 24, 2024

🎟️ Tracking

PM-13014

📔 Objective

This will add a CanToggleStatus flag to the PolicyResponseModel to inform clients on whether or not they will be allowed to change the status of the policy (enable/disable). This is using the new PolicyValidator#ValidateAsync methods to determine if it can be changed. This is limited to Single Org Policy for now.

⏰ 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 Oct 24, 2024

Logo
Checkmarx One – Scan Summary & Details2a5db573-3126-490a-b004-d1c75c6f529f

New Issues

Severity Issue Source File / Package Checkmarx Insight
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 548 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 573 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 455 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 418 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 568 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 871 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 853 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 59
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 106
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 238
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 678
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 264
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 345
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 362
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 75
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 145
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/PoliciesController.cs: 42
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/PoliciesController.cs: 62
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 469
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 832
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 534
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 723
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 705
LOW Log_Forging /src/Api/AdminConsole/Controllers/ProvidersController.cs: 72
LOW Log_Forging /src/Api/AdminConsole/Controllers/ProvidersController.cs: 72
LOW Log_Forging /src/Api/AdminConsole/Controllers/ProvidersController.cs: 72

@jrmccannon jrmccannon marked this pull request as ready for review October 24, 2024 20:24
@jrmccannon jrmccannon requested a review from a team as a code owner October 24, 2024 20:24
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 20 lines in your changes missing coverage. Please review.

Project coverage is 42.57%. Comparing base (2abd37d) to head (2503021).

Files with missing lines Patch % Lines
...e/Models/Response/Helpers/PolicyDetailResponses.cs 0.00% 6 Missing ⚠️
...Api/AdminConsole/Controllers/PoliciesController.cs 63.63% 3 Missing and 1 partial ⚠️
...e/Models/Api/Response/PolicyDetailResponseModel.cs 50.00% 4 Missing ⚠️
...inConsole/Public/Controllers/PoliciesController.cs 0.00% 3 Missing ⚠️
...icies/PolicyValidators/SingleOrgPolicyValidator.cs 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4940   +/-   ##
=======================================
  Coverage   42.56%   42.57%           
=======================================
  Files        1387     1389    +2     
  Lines       64653    64678   +25     
  Branches     5936     5940    +4     
=======================================
+ Hits        27521    27536   +15     
- Misses      35908    35916    +8     
- Partials     1224     1226    +2     

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

throw new ArgumentException($"'{nameof(policy)}' must be of type '{nameof(PolicyType.SingleOrg)}'.", nameof(policy));
}

return new PolicyDetailResponseModel(policy, await hasVerifiedDomainsQuery.HasVerifiedDomainsAsync(policy.OrganizationId));
Copy link
Member

@eliykat eliykat Nov 1, 2024

Choose a reason for hiding this comment

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

I think the bool needs to be inverted:

  • has verified domains => can't toggle state
  • does not have verified domains => can toggle state

(Probably a drawback of a bool that defaults to true, I didn't realise that when I suggested the naming. But no need to spend more time on it.)

Copy link
Member

Choose a reason for hiding this comment

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

No changes required, but I am interested in the decision to use an extension method here vs. a static method on the class itself. I can make some guesses but would like to hear your thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

Api request/response models live in the Api project.

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