Fix License Compliance widget link on MR from forked project
What does this MR do and why?
This MR fixes incorrect links in the License Compliance widget for MRs originating from forked projects.
Currently, the widget generates license links using the upstream project path, even though the pipeline runs in the forked project. As a result, clicking the "Used by N package" or "Full report" link leads to a 404.
This MR updates the logic to ensure the generated link points to the correct, source project namespace (i.e. the fork), so users are directed to a valid pipeline license report.
Extras:
- Slightly refactored widget entity tests
References
Linked Issue: #503498 (closed)
Screen recordings
| Before | After |
|---|---|
| before-license-widget-link.webm | after-license-widget-link.webm |
How to set up and validate locally
Prerequisites:
- Local GDK instance with Ultimate License enabled.
Steps:
-
Set up License Approval Policy in GDK
- Go to the group where you want to enable the policy, e.g.:
http://gdk.test:3000/gitlab-org - In the left sidebar go to
Security->Policies - Click
New policy, then selectMerge request approval policy. - Switch to YAML mode.
- Paste the contents from this sample policy:
➡️ license-policy.yml. - Click
Configure with a merge request. follow the prompts, and merge the MR into your security policies project.
- Go to the group where you want to enable the policy, e.g.:
-
Create Test Project
- In the same group (e.g., gitlab-org), create a new empty project.
-
Fork and Prepare the Project
- Fork the newly created project into the same group.
- In the fork, create a new branch.
- Add the contents from the following repo to that branch:
➡️ sbom-liscense-upload. - Commit and push the changes.
- Create a Merge Request
-
Validate License Compliance Widget Links
- Click on "Full Report" and "Used by 1 package" links and ensure they lead to 404 Page.
- Check out your GDK GitLab project into this MR branch:
fix-license-fork-project-pipeline-link. - Restart GDK rails service:
gdk restart rails-web. - Click on "Full Report" and "Used by 1 package" again and ensure they lead to the respective MR pipeline.
-
Additional Validation: Create MR from Source Project (No Fork)
- In the original project, create a new branch directly.
- Copy or reuse the same contents from the
sbom-license-uploadexample. - Open MR from this new branch -> into the
mainbranch of the same project. - Wait for the pipeline to complete.
- Verify that in the "Full Report" and "Used by 1 package" links behave as expected.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Albina Yusupova
