License scanning of CycloneDX files (ULTIMATE)

  • Introduced in GitLab 15.9 for GitLab SaaS with two flags named license_scanning_sbom_scanner and package_metadata_synchronization. Both flags are disabled by default and both flags must be enabled for this feature to work.
  • Enabled in GitLab 15.10 for GitLab SaaS.
  • Introduced in GitLab 15.10 for self-managed GitLab with two flags named license_scanning_sbom_scanner and package_metadata_synchronization, both of which must be enabled for this feature to work. The flags are disabled by default due to the initial performance load when the license database is first imported. Work to improve performance is being tracked in issue 397670.
  • Enabled in GitLab 15.11 for self-managed GitLab.

To detect the licenses in use, License Compliance relies on running the Dependency Scanning CI Jobs, and analyzing the CycloneDX Software Bill of Materials (SBOM) generated by those jobs. Other 3rd party scanners may also be used as long as they produce a CycloneDX file with a list of dependencies for one of our supported languages. This method of scanning is also capable of parsing and identifying over 500 different types of licenses, as defined in the SPDX list. Licenses not in the SPDX list are reported as "Unknown". License information can also be extracted from packages that are dual-licensed, or have multiple different licenses that apply.

Enable license scanning

Prerequisites:

From the .gitlab-ci.yml file, remove the deprecated line Jobs/License-Scanning.gitlab-ci.yml, if it's present.

Supported languages and package managers

License scanning is supported for the following languages and package managers:

Language Package Manager
.NET NuGet
C#
C Conan
C++
Go Go
Java Gradle
Maven
JavaScript and TypeScript npm
pnpm
yarn
PHP Composer
Python setuptools
pip
Pipenv
Poetry
Ruby Bundler
Scala sbt

The supported files and versions are the ones supported by Dependency Scanning.

License expressions

GitLab has limited support for composite licenses. License compliance can read multiple licenses, but always considers them combined using the AND operator. For example, if a dependency has two licenses, and one of them is allowed and the other is denied by the project policy, GitLab evaluates the composite license as denied, as this is the safer option. The ability to support other license expression operators (like OR, WITH) is tracked in this epic.

Blocking merge requests based on detected licenses

Users can require approval for merge requests based on the licenses that are detected by configuring a license approval policy.

Running in an offline environment

For self-managed GitLab instances in an environment with limited, restricted, or intermittent access to external resources through the internet, some adjustments are required to successfully scan CycloneDX reports for licenses. For more information, see the offline quick start guide.

Troubleshooting

A CycloneDX file is not being scanned and appears to provide no results

Ensure that the CycloneDX file adheres to the CycloneDX JSON specification. This specification does not permit duplicate entries. Projects that contain multiple SBOM files should either report each SBOM file up as individual CI report artifacts or they should ensure that duplicates are removed if the SBOMs are merged as part of the CI pipeline.

You can validate CycloneDX SBOM files against the CycloneDX JSON specification as follows:

$ docker run -it --rm -v "$PWD:/my-cyclonedx-sboms" -w /my-cyclonedx-sboms cyclonedx/cyclonedx-cli:latest cyclonedx validate --input-version v1_4 --input-file gl-sbom-all.cdx.json

Validating JSON BOM...
BOM validated successfully.