Skip to content

List invalid policies

Marcos Rocha requested to merge mc_rocha-list-invalid-policies into master

What does this MR do and why?

This MR updates the Policies API to return the policies with deprecated properties. Listing invalid policies will help users update them.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Policy with deprecated properties are visible in the policy list

Screenshot_2024-04-24_at_2.22.46_PM

Screenshot_2024-04-24_at_2.23.03_PM

How to set up and validate locally

If you have a project with a policy using match_on_inclusion or newly_detected

  1. Go the Secure > Policies
  2. The invalid policy should be on the list

If you don't have a project with a invalid policy

  1. Create a new project
  2. Go to Secure > Policies
  3. Click on New policy
  4. Select Merge request approval policy
  5. Change to .yaml mode
  6. Copy the yaml below:
type: approval_policy
name: 'policy with deprecated properties'
description: ''
enabled: true
actions:
  - type: require_approval
    approvals_required: 1
    role_approvers:
      - developer
rules:
  - type: license_finding
    branches: []
    match_on_inclusion_license: true
    license_types:
      - Mozilla Public License 1.0
    license_states:
      - detected
  1. Click on Configure with a merge request

  2. Merge the new MR to add the policy

  3. After merging the policy, in the security policy project, go to Repository

  4. Click on gitlab/security-policies

  5. click on policy.yml

  6. Edit the policy to

---
approval_policy:
- name: policy with deprecated properties
  description: ''
  enabled: true
  actions:
  - type: require_approval
    approvals_required: 1
    role_approvers:
    - developer
  rules:
  - type: license_finding
    branches: []
    match_on_inclusion: true
    license_types:
    - Mozilla Public License 1.0
    license_states:
    - newly_detected
  1. Create a merge request and merge the policy
  2. Go back to the project created on step 1
  3. Go to Secure > Policies and check if the invalid policy is on the list
Edited by Marcos Rocha

Merge request reports

Loading