Skip to content

When generating policy YAML, add a comment next to IDs that contains the name corresponding to the ID

Proposal

When generating policies using the UI we often end up with bits of YAML like this

  actions:
  - type: require_approval
    approvals_required: 1
    group_approvers_ids:
    - 66736050

It would be great if we had comments automatically generated for all IDs in a policy with the name that corresponds to the item. In this case we would like to see

    group_approvers_ids:
    - 66736050 # gitlab-com/gl-security/appsec/appsec-team

Same idea with the other IDs such as:

  • compliance framework labels where we'd like to see the label name.
  • project or group IDs when configuring policies
  • user ID when an individual is added as approver

This would make the policies much easier to read for the people who review the MR and for anyone who doesn't have the full context.

Verification Steps

  1. Create a security policy for a group/project

  2. Update the security policy policy.yml file with the experiments option enabled:

    Add this at the end of .gitlab/policies/policy.yml in the security policy project

    experiments:
      annotate_ids:
        enabled: true
  3. Now go to Secure => Policies and create or update a security policy with IDs in it

  4. Verify that the policy YAML is annotated - comments are added next to IDs

Edited by Imam Hossain