doc/user/application_security/policies/enforcement/_index.md
You can create a new security policy for each project or group, but duplicating the same policy settings across multiple top-level groups can be time-consuming and present compliance challenges. Before you create a policy, you should know whether the policy should be:
You can enforce policies in multiple ways:
When designing policies:
To enforce policies to meet your requirements, consider the following factors:
To maximize policy coverage, link a security policy project to the highest organizational units that achieves your objectives: groups, subgroups, or projects. A policy is enforced on the organizational units it's linked to, and all their descendent subgroups and their projects. Enforcement at the highest point minimizes the number of security policies required, minimizing the management overhead.
You can use policy inheritance to incrementally roll out policies. For example, when rolling out a new policy, you can enforce it on a single project, then conduct testing. If the tests pass, you can then remove it from the project and enforce it on a group, moving up the hierarchy until the policy is enforced on all applicable projects.
Policies enforced on an existing group or subgroup are automatically enforced in any new subgroups and projects created under them, provided that:
[!note] GitLab.com users can enforce policies against their top-level group or across subgroups, but cannot enforce policies across GitLab.com top-level groups. GitLab Self-Managed administrators can enforce policies across multiple top-level groups in their instance.
The following example illustrates two groups and their structure:
Alpha group (contains code projects)
Security and compliance group (contains security policy projects)
Assuming no policies are enforced, consider the following examples:
{{< history >}}
security_policies_policy_scope. Enabled by default.security_policies_policy_scope removed.{{< /history >}}
You can refine a policy's scope by:
You can apply these refinements together in the same policy. However, exclusion takes precedence over inclusion.
Separation of duties is vital to successfully implementing policies. Design policies that achieve the necessary compliance and security requirements while supporting development workflows.
When implementing separation of duties:
To enforce a security policy project on a group, subgroup, or project, you must have either:
manage_security_policy_link permission.The Owner role and custom roles with the manage_security_policy_link permission follow the standard hierarchy rules across groups, subgroups, and projects:
| Organization unit | Group owner or group manage_security_policy_link permission | Subgroup owner or subgroup manage_security_policy_link permission | Project owner or project manage_security_policy_link permission |
|---|---|---|---|
| Group | {{< yes >}} | {{< no >}} | {{< no >}} |
| Subgroup | {{< yes >}} | {{< yes >}} | {{< no >}} |
| Project | {{< yes >}} | {{< yes >}} | {{< yes >}} |