doc/user/compliance/license_approval_policies.md
{{< details >}}
{{< /details >}}
{{< history >}}
license_scanning_policies.license_scanning_policies removed.{{< /history >}}
Use license approval policies to specify criteria that determines when approval is required before a merge request can be merged.
License approval policies apply only to protected target branches.
The following video provides an overview of these policies.
<div class="video-fallback"> See the video: <a href="https://www.youtube.com/watch?v=34qBQ9t8qO8">Overview of GitLab License Approval Policies</a>. </div> <figure class="video-container"> <iframe src="https://www.youtube-nocookie.com/embed/34qBQ9t8qO8" frameborder="0" allowfullscreen> </iframe> </figure>License approval policies rely on the output of a dependency scanning job to verify that requirements have been met. If dependency scanning has not been properly configured, and therefore no dependency scanning jobs ran related to an open MR, the policy has no data with which to verify the requirements. When security policies are missing data for evaluation, by default they fail closed and assume the merge request could contain vulnerabilities. You can opt out of the default behavior with the fallback_behavior property and set policies to fail open. A policy that fails open has all invalid and unenforceable rules unblocked.
To ensure enforcement of your policies, you should enable dependency scanning on your target development projects. You can achieve this a few different ways:
.gitlab-ci.yml files or enable it using a security configuration.License approval policies require license information from GitLab-supported packages.
Create a license approval policy to enforce license compliance.
To create a license approval policy:
The following types of criteria can be used to determine which licenses are "approved" or "denied" and require approval.
The following types of criteria can be used to determine whether or not approval is required based on the licenses that exist in the default branch:
If a license is found that violates the license approval policy, it blocks the merge request and instructs the developer to remove it. The merge request cannot be merged until the denied license is removed unless an eligible approver for the license approval policy approves the merge request.
A loading spinner is displayed in the following scenarios:
The license compliance widget polls every few seconds for updated results. When the pipeline is complete, the first poll after pipeline completion triggers the parsing of the results. This can take a few seconds depending on the size of the generated report.
The final state is when a successful pipeline run has been completed, parsed, and the licenses displayed in the widget.
unknown licensesLicense approval policies can block merge requests due to unknown licenses in some
scenarios.
[!note] Package-level exclusions using PURLs in the
licensesfield do not work withunknownlicenses. Thelicensesfield supports SPDX license names matching only, andunknownis not a valid SPDX license name. If you configure a deniedunknownlicense with a PURL exclusion, the exclusion is ignored during merge request approval evaluation, and the merge request is still blocked. The pipeline Licenses tab appears to respect the exclusion, but the merge request approval widget does not. These views use different evaluation paths.
This can happen in any of the following situations:
To address this issue:
unknown licenses, or review out-of-policy licenses generated by the GitLab
security bot.If you need to temporarily allow merging with unknown licenses:
unknown to the list of allowed licenses.unknown from the allowed licenses list to
maintain proper license compliance.Always consult with your legal team when dealing with license compliance issues, especially when handling unknown licenses.