Static Reachability multiple languages cause behaviour duplication
Summary
Static Reachability (SR) enriches SBOMs for each supported language. The same SBOM can contain multiple languages (e.g. TypeScript and JavaScript). The current SR flow creates duplicate SBOM outputs and multiple completion logs that are unclear. This is not detrimental to results, but it's confusing and may have consequences due to output duplication.
Detailed flow
Static reachability enriches SBOMs for every supported language in sbomenrichers.go:
// Enrich SBOMs
enrichedSBOMs := make([]cyclonedx.SBOM, 0, len(srSupportedSBOMs))
for _, enricher := range enrichers {
if err := enricher.EnrichSBOMs(); err != nil {
return nil, fmt.Errorf("language %v: %s", enricher.Language(), err)
}
enrichedSBOMs = append(enrichedSBOMs, enricher.GetSBOMs()...)
}
This makes sense as the same SBOM may contain files of different types, supported by different enrichers and flows (e.g. JavaScript (.js) and TypeScript (.ts) files may be found in the same SBOM whilst requiring different flows).
This results in at least one duplication issue where we see multiple completion logs in the output indicating different numbers of in_use files. (e.g. first and second output with no language indication)
The returned result is a list of SBOMs, enriched and not. Since different enrichers may enrich the same SBOM, this may result in the returned list containing the same SBOM multiple times.
The result is that we create multiple SBOM output files in main.go that contain the exact same content. This is not detrimental as far as can be seen, but it's confusing and may have consequences.
Steps to reproduce
Example Project
Example job - see duplicate output SBOMs (that are identical) and multiple completion logs: first and second
What is the current bug behavior?
Duplicate outputs and behaviour when multiple languages in one SBOM.
What is the expected correct behavior?
There should be one enriched output SBOM per lock file, even if multiple languages are addressed. We should either coalesce logs for in_use components or indicate the relevant language for each log.
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.