Read child pipeline SBOMs in license approval policy evaluation
What does this MR do and why?
Stacked on !260721 (merged) (!260721 (merged)) — review only the top two commits; retarget to master after !260721 (merged) merges.
latest_comparison_pipeline_with_sbom_reports picks the target branch pipeline when it or one of its child pipelines has an SBOM (software bill of materials) report. The target branch report then read only that pipeline's own builds. When the default branch generates its SBOM in a child pipeline, the target report is empty. License approval rules with newly_detected license states then treat every license in the merge request as new, so licenses already on the target branch block merges.
The target report now includes SBOM reports from child pipelines in the same project.
The second commit fixes the source side. Every pipeline in a parent-child hierarchy runs the evaluation when it finishes, and each read only its own SBOM reports, so the last pipeline to finish decided the result. A parent pipeline with its own SBOM that finished after its child passed the rule and cleared the violation the child had raised. Every pipeline in the hierarchy now evaluates the root pipeline and its same-project child pipelines, and evaluation waits until the root pipeline is complete, so the finish order no longer changes the result.
The change is behind the license_policy_child_pipeline_sboms feature flag (gitlab_com_derisk, default off) because it changes policy enforcement.
References
- Resolves #632877
- Rollout: #632878
- Builds on !260721 (merged) (reuses its
self_and_project_descendants:scanner option)
Screenshots or screen recordings
No screenshot: backend change to approval rule evaluation; see validation output.
How to set up and validate locally
- Create a group-level approval policy with a
license_findingrule:license_states: [newly_detected],match_on_inclusion_license: true,license_types: [BSD-3-Clause], require 1 approval. - Set the project's
license_configuration_sourcetosbom. - Use a default branch whose CycloneDX SBOM is produced in a child pipeline (
trigger: include: child.yml,strategy: depend) and already contains a BSD-3-Clause component. - Open a no-op merge request. It requires 1 approval.
- In the Rails console, enable the flag and re-run the pipeline:
Feature.enable(:license_policy_child_pipeline_sboms) - The merge request no longer requires approval.
| Case | Flag off | Flag on |
|---|---|---|
| License already on the target branch, SBOM in a child pipeline (no-op MR) | approvals_required=1, violation failed, blocked | approvals_required=0, no violation, mergeable |
| License already on the target branch, SBOM in the parent pipeline (control) | 0, none, mergeable | 0, none, mergeable |
| New denied license, SBOM in a child pipeline | 1, failed, blocked | 1, failed, blocked |
| New denied license in the child SBOM, parent also has an SBOM, parent evaluated last | 0, none, mergeable | 1, failed, blocked |
| Same, child evaluated last | 1, failed, blocked | 1, failed, blocked |
All rows were also checked with merge request and merged results pipelines for the new-license cases, and with the parent and child evaluated in both orders; with the flag on every result matched the expected outcome in both orders.
Specs on the top commit: update_license_approvals_service_spec, sync_license_scanning_rules_service_spec, license_violation_checker_spec, license_scanning_spec, sbom_scanner_spec, pipeline_helper_spec and EE pipelines_controller_spec, 0 failures. The new execute-level examples in update_license_approvals_service_spec fail with either change reverted.
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.
Reviewable LOC: 40 (plus 90 in tests)
Context for LLM agents
- Rejected: changing
SbomScanner's default for all callers. That also changes the pipeline Licenses tab, which has its own flag in !260721 (merged), and the MR license compliance widget, which this MR leaves unchanged. - Invariant: every pipeline in a hierarchy must evaluate the same report set (root plus same-project descendants), or the last pipeline to finish overwrites the others' result.
- Invariant: the target report must read the same pipeline set that
MergeRequest#latest_comparison_pipeline_with_sbom_reportsused to select it. That method counts child pipelines' SBOMs. - Scope is same-project child pipelines only (
self_and_project_descendants). - Flag group: group::policy management.