Adjust license scanning code to work with static license
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 adjust the to license scanning code to work with static license catalog.
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
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.
Screenshots or screen recordings
How to set up and validate locally
- Enable the feature flag
static_licensesusing the rails console
Feature.enable(:static_licenses)
- Create a new project
- Add a
.gitlab-ci.ymlfile with the content
include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
- Go to Secure > Policies
- Click in New policy
- Select Merge request approval policy
- Using the
Rule mode
- In
Rules>WhenselectLicense Scan - Select
Newly Detectedin Status is - Verify the License list is populated
- Create a policy like
approval_policy:
- name: deny MIT License
description: ''
enabled: true
rules:
- type: license_finding
match_on_inclusion_license: true
license_states:
- newly_detected
branch_type: protected
license_types:
- MIT License
actions:
- type: require_approval
approvals_required: 1
role_approvers:
- developer
- type: send_bot_message
enabled: true
approval_settings:
block_branch_modification: true
prevent_pushing_and_force_pushing: true
prevent_approval_by_author: true
prevent_approval_by_commit_author: true
remove_approvals_with_new_commit: true
require_password_to_approve: false
fallback_behavior:
fail: closed
- Create a new MR adding an
Gemfile.lockfile with the content GEM
GEM
remote: https://rubygems.org/
specs:
rack (3.0.4.1)
PLATFORMS
arm64-darwin-22
DEPENDENCIES
rack
BUNDLED WITH
2.4.22
- Verify the MR is blocked
- Expand the License compliance MR widget and verify the MIT License is Denied
Edited by Marcos Rocha

