Update sort function in report package to also sort by name field
Proposal
The report package was updated to sort vulnerabilities by Severity, CompareKey, and Location.Dependency.Version as part of Sort vulns by Location.Dependency.Version (gitlab-org/security-products/analyzers/report!51 - merged) • Adam Cohen • 15.6. However, some vulnerabilities have the same Severity, CompareKey, and Location.Dependency.Version, which means that the sort order becomes non-deterministic.
For example, the following two vulnerabilities from security-code-scan have the same value for these fields:
- Potential Cross-Site Scripting from 'string TextBox.Text'
- Potential Cross-Site Scripting from 'string HiddenField.Value'
In order to work around the non-deterministic sorting of the above vulnerabilities, security-code-scan has added custom sorting in the integration tests.
The purpose of this issue is to update the report package to also sort vulnerabilities by the name field, so that the vulnerability order in the report is deterministic and we can remove workarounds like the one implemented by security-code-scan.
Implementation Plan
-
The sort function in the reportpackage currently sorts bySeverity,CompareKey, andLocation.Dependency.Version.We need to update the
sortfunction to sort by theNamefield if theLocation.Dependency.Versionfield doesn't exist, or is the same between two vulnerabilities. -
Add unit tests for the above behaviour. -
Release a new version of the reportpackage. -
Update security-code-scan to use the new version of the reportpackage released in step2.above. -
Remove the custom sorting from the security-code-scanintegration test.