Skip to content

Expose securityPolicyProject for project or group in GraphQL API

What does this MR do and why?

This MR exposes securityPolicyProject for project or group in GraphQL API.

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

Project Group
CleanShot_2024-01-24_at_18.34.40_2x CleanShot_2024-01-24_at_18.33.34_2x

How to set up and validate locally

  1. Create a new group
  2. Visit Secure -> Policies and create a group policy. The security policy project will be created automatically with it. Sample policy YAML:
    type: scan_result_policy
    name: Test policy
    description: ''
    enabled: true
    rules:
      - type: any_merge_request
        branch_type: protected
        commits: any
    actions:
      - type: require_approval
        approvals_required: 1
        role_approvers:
          - developer
  3. Query GraphQL (/-/graphql-explorer):
    query {
      namespace: group(fullPath: "<group-path>") {
        id
        securityPolicyProject {
          name
          fullPath
          openMergeRequestsCount
        }
      }
    }
  4. Create a new project
  5. Visit Secure -> Policies and create a project policy. The security policy project will be created automatically with it. Sample policy YAML:
    type: scan_result_policy
    name: Test policy
    description: ''
    enabled: true
    rules:
      - type: any_merge_request
        branch_type: protected
        commits: any
    actions:
      - type: require_approval
        approvals_required: 1
        role_approvers:
          - developer
  6. Query GraphQL (/-/graphql-explorer):
    query {
      namespace: project(fullPath: "<project-path>") {
        id
        securityPolicyProject {
          name
          fullPath
          openMergeRequestsCount
        }
      }
    }

Related to #414988 (closed)

Edited by Martin Čavoj

Merge request reports