Use License Scanning Service in License Compliance page
Why are we doing this work
The backend needs to be changed so that the License Compliance page uses the License Scanning Service.
Further details
License Compliance page is handled by LicensesController#index which uses SCA::LicenseCompliance, and Pipeline#license_scanning_report.
The other controller actions are used to create and update license policies, and they don't need to be updated.
Proposal 1 ✅
Change Pipeline#license_scanning_report so that it gets a Ci::Reports::LicenseScanning::Report using the LicenseScanningService. The LicenseScanningService is initialized with the pipeline and its project.
Also, change Project#license_compliance so that it no longer relies on latest_pipeline_with_reports to get the default value for its argument. Instead, make LicenseScanningService responsible for finding the latest pipeline that provides the data it needs.
Proposal 2 ❌
Update LicenseCompliance#license_scanning_report so that it gets a Ci::Reports::LicenseScanning::Report using the LicenseScanning::ExportReportService class.
- Create an
ExportReportServiceclass insideee/app/services/license_scanning/export_report_service.rb. TheExportReportServiceis initialized with the pipeline and its project. - Update
SCA::LicenseCompliance#license_scanning_reportso that it fetches the report usingLicenseScanning::ExportService#execute.
Relevant links
Technical evaluation: #377688 (comment 1133318031)
Non-functional requirements
-
Documentation: -
Feature flag: -
Performance: -
Testing:
Implementation plan
- Update the
Pipeline#license_scanning_reportmethod so that it returns aCi::Reports::LicenseScanning::Reportusing the::Gitlab::LicenseScanning::ArtifactScannerclass.- This will require a public method on the class -
#reportthat will fetch the report.
- This will require a public method on the class -
- Change
Project#license_complianceso that it no longer relies onlatest_pipeline_with_reportsto get the default value for its argument. Make the::Gitlab::LicenseScanning::BaseScannerinterface responsible for finding the latest pipeline that provides the data it needs. This method should be named in a manner that omitsreportse.g.#latest_pipeline.- The name purposefully omits
reportsso that the data source is abstracted away since the data can come from either SBoM components licenses or an artifact. - Using a method within the
::Gitlab::LicenseScanning::BaseScannerinterface gives the advantage of having the feature flag logic within one area.
- The name purposefully omits
Verification steps
SET to review existing E2E tests, update if required to functionally test, being mindful of shifting left if covered by lower level testing.