Skip to content

Enforce policy limits when policies are created in yaml mode

Summary

Users can use yaml mode in the policy editor to enable policies despite there being policy limits

Steps to reproduce

  1. Upload a GitLab Ultimate license
  2. Navigate to a group/project => Secure => Policies
  3. Create 5 enabled policies of one type and 1 disabled policy of the same type
  4. Navigate to the group/project => Secure => Policies => Select the disabled policy => Edit policy
  5. Notice the enabled radio buttons are disabled
  6. Navigate to yaml mode and enable the policy
  7. Save the policy

Example Project

https://staging.gitlab.com/govern-team-test/cnp-alert-demo/-/security/policies/Policy+with+no+description/edit?type=scan_execution_policy

What is the current bug behavior?

The policy MR is created

What is the expected correct behavior?

The policy MR is not created and an error shows

Relevant logs and/or screenshots

Scenario Screenshot
Disabled enabled radio button image
Save policy past limit with yaml mode save_policy_past_limits_small

Possible fixes

Originally we had a frontend solution where we disabled the the submit button in this case to prevent users from saving it, but we removed it because it was not pajamas compliant.

So the possible solutions are:

  1. We check the policy type count on save on the backend and throw an error
  2. We check the policy type count on save on the frontend and throw an error
  3. Re-implement the disabling of the save button
Edited by Alexander Turinske