DS using SBOM feature creates dangling Security::Scan records

Summary

When analyzing production data we've detected that a growing number of Security::Scan records are left in a :created: state, which is not supposed to happen.

These seem to be primarily coming from Dependency Scanning using SBOM feature, that consider a CycloneDX report as a security report, but a broader DB analysis could be conducted to verify potential other problems.

This problem creates waste of resource by growing unnecessarily the security scan table.

This also inflates the Security Scan metrics which relies on counting these records, independently from their status.

More details

When a "security job" completes, we create Security::Scan records in a created state but only process the reports when all security jobs have completed. This includes SBOM reports that potentialy contains the GitLab Taxonomy, making them capable of being analyzed by the DS using SBOM beta feature, doing a live DS scan on sbom report parsing. However, whether or not the SBOM report is compatible can't be known at that time but only when effectively processing the report and parsing them.

These "created" report should thus be deleted by this logic when processing reports. However the remove_dangling_dependency_scans method is apparently not called as these sbom report artifacts have a blank security report here and the caller skips them.

Steps to reproduce

Example Project

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Patch release information for backports

If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.

Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.

High-severity bug remediation

To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.