Fix MR widget loading indefinitely when there is an SBoM without Dependency Scanning attributes
What does this MR do and why?
This bug happens then there is an sbom that does not produce dependency_scanning results, and no other dependency scanning report in the pipeline. We have a redis optimization to reduce the number of database queries executing when polling. It blocks the database checks from executing until a redis key is set for the report. That key is being set if an SBoM produces results, but if it doesn't then the report is shown as parsing indefinitely.
Detailed explanation:
- The widget expects there to be
dependency_scanningresults if there is a cyclonedx artifact and begins polling. - We have a redis optimization implemented in !151358 (merged) to reduce the amount of database queries executed when polling. It causes report status to always return
:parsinguntil::Ci::CompareSecurityReportsService.set_security_report_type_to_readyis called. This is only called when executing StoreGroupedScansService. - Sbom-based dependency scanning goes through this code path.
StoreGroupedSbomScansServiceinherits fromStoreGroupedScansService, so it does execute this method. However, the problem arises from thefile_typewhich is set here as the keyartifact.security_report.type.to_s. Ifartifact.security_reportreturnsnilor ifartifact.security_report.typeiscontainer_scanning, then thedependency_scanningreports are never marked as ready.
References
- Bug issue: #568889 (closed)
- Request for help: https://gitlab.com/gitlab-com/request-for-help/-/issues/3359
- MR that introduced the bug: !186603 (merged)
- MR that introduced the redis optimization: !151358 (merged)
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
-
Clone this project and push it to gdk (this will automatically create the project):
git clone git@gitlab.com:gitlab-org/govern/threat-insights-demos/verification-projects/issue-568889.git cd issue-568889 git remote add gdk ssh://git@<gdk_hostname>:2222/<user>/issue-568889.git git push -u gdk main git checkout feature git push -u gdk feature -
Run a pipeline on
main -
Open a merge request merging
featureintomain -
The merge request widget should show results once reports are done processing. Before, it would load indefinitely.
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.