Skip to content

Get branches from rules using rule_index for security policy

What does this MR do?

Addresses #337537 (closed)

The schedule rule type in Security Orchestration Policies accepts branches field for which the policy is expected to be applied. But currently, the scheduled scan execution does not consider branches and the policy is applied only to the default branch of the project.

Screenshots or Screencasts (strongly suggested)

Policy with branches

Screenshot_2021-08-06_at_3.06.23_PM

Branches in project

Screenshot_2021-08-06_at_3.05.54_PM

Pipeline

Screenshot_2021-08-06_at_3.05.38_PM

How to setup and validate locally (strongly suggested)

  1. Clone and create a project from https://gitlab.com/sashi_kumar/security-orchestration-policies
  2. Enable security_orchestration_policies_configuration for the target project for which the scan policies should be enabled by doing:
Feature.enable(:security_orchestration_policies_configuration, Project.find(<target_project.id>))
  1. Go to Security & Compliance -> Scan Policies for the target project
  2. Select Edit policy project and select the policy project (security-orchestration-policies) that was created in step 1 and click save
  3. Make sure the branches mentioned in the policy exist in the project
  4. Wait for few minutes (>10mins) to see the scheduled scan triggered for the branches specified.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Sashi Kumar Kumaresan

Merge request reports

Loading