Skip to content

Add new states to ApprovalProjectRule vulnerability_states validation

What does this MR do and why?

During the validation of issue !397057, we realized that approval project rules for the new states added in MR !117394 were not being created.

The error happened because this validation prevented project rules with the states from being created.

This MR adds the new states to ApprovalProjectRule's validation of allowed vulnerability_states.

Related to #397057 (closed)

How to set up and validate locally

  1. Create a new project
  2. Go to /-/security/policies.
  3. Click on New Policy.
  4. Select Scan result policy.
  5. Change to yaml mode and copy one of the yaml policies below
type: scan_result_policy
name: Test new_needs_triage
description: ''
enabled: true
rules:
  - type: scan_finding
    branches: []
    scanners: []
    vulnerabilities_allowed: 0
    severity_levels:
      - critical
      - high
      - medium
      - low
      - unknown
      - info
    vulnerability_states:
      - new_needs_triage
actions:
  - type: require_approval
    approvals_required: 1
    user_approvers_ids:
      - 1
  1. Click on Configure with a merge request.

  2. Merge the new MR.

  3. Add a .gitlab-ci.yml with the content

include:
- template: Jobs/SAST.gitlab-ci.yml
test-job:
  script:
    - echo "Test Job..."
  1. Go to the project overview page
  2. Click on Web IDE
  3. Add a new ruby script file with the code
class Generic
    def run_on_system
      system("cat #{params[:path]}")
    end
  end
  1. Click on Commit & Push
  2. Click on Yes commit to a new branch
  3. Choose a branch name or accept the default one
  4. Click on Create MR
  5. Verify that MR contains the approval rule added in step 5.

Screenshot_2023-05-08_at_2.35.14_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Bala Kumar

Merge request reports

Loading