Use SoftwareLicenses catalogue to load license lists and persist spdx_identifier
What does this MR do and why?
We want to read the license information from the Gitlab::SPDX::Catalogue and remove the Software Licenses table as proposed in this issue.
This MR
- Adds the
all_license_namestoGitlab::SPDX::Catalogueand updates theSecurityOrchestrationHelperto load the license names from the catalog if the feature flagstatic_licensesis enabled. - Persist the
software_license_spdx_identifierusing the information from the::Gitlab::SPDX::Catalogue. Thesoftware_license_spdx_identifiershould be persisted even ifstatic_licensesis disabled to prepare our database for thesoftware_licensestable removal. It seems we missed this part in MR. We might need to run the migration in this MR again after merging this MR and before enabling thestatic_licensesfeature flag.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
- Related to #497969 (closed)
- Related to #523022 (closed)
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.
How to set up and validate locally
- Create a new project
- Enable the feature flag
static_licensesand disable the feature flagcustom_software_license
Feature.enable(:static_licenses)
Feature.disable(:custom_software_license)
- Go to Secure > Policies
- Click on New policy
- Select Merge request approval policy
- In
RulesSelect License Scanning - Verify the licenses are available in
Select license types. - Select a license from the list and merge the policy
- Verify the
software_license_spdx_identifierwas persisted in the database
SoftwareLicensePolicy.last
#<SoftwareLicensePolicy:0x000000031acd7478
id: 38048,
project_id: 1166,
software_license_id: 25514,
classification: "denied",
created_at: Mon, 03 Feb 2025 17:10:13.928118000 UTC +00:00,
updated_at: Mon, 03 Feb 2025 17:10:13.928118000 UTC +00:00,
scan_result_policy_id: 836,
custom_software_license_id: nil,
approval_policy_rule_id: 144,
software_license_spdx_identifier: "3D-Slicer-1.0">
Edited by Marcos Rocha