Skip to content

Fix scan approval when user does not have edit approval rule permission

Sashi Kumar Kumaresan requested to merge sk/fix-383593 into master

What does this MR do and why?

Addresses #383593 (closed)

This MR fixes a bug in scan result policy where the user, who updated the latest policy, was used to create approval_project_rules. When the user does not have permission to create approval rules, the service fails which results in the approval rules not being created.

This change adds skip_authorization param to ApprovalRules::CreateService that ignores permission check so that the scan result policy can create approval rules without failure.

How to set up and validate locally

  1. Create a project and enable security scans for this project (like include Security/Container-Scanning.gitlab-ci.yml template and use nginx:1.18.0 with DOCKER_IMAGE as a variable)
  2. Create a security policy project for this project
  3. Add new user as a member of the security policy project created in step 1. with Developer role
  4. As the user created in step 3. create new Scan Result Policy and merge the MR to apply the policy
  5. In project created in step 1. create new MR that will change the DOCKER_IMAGE variable set in gitlab-ci.yml file to something else (like nginx:1.17.0)
  6. Observer applied approval rules in the MR

MR acceptance checklist

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

Merge request reports