Prepare GLAS diff-based scan data for rails frontend
Summary
This issue ensures that for GLAS diff-based scans (indicated by the partial_scan_mode column in the security_scans table, added in #543636 (closed)), backend only passes new and existing vulnerabilities to the frontend.
See the Hide Fixed Vulnerabilities section of this document for the full context.
See MVC: Enable Diff-Based Scanning in MRs for Fast... (&17758 - closed) on how this issue fits in the whole plan.
References
Main diff-based scanning epic: Faster Advanced SAST: Diff-based scanning in MRs (&16790 - closed)
MVC implementation epic: MVC: Enable Diff-Based Scanning in MRs for Fast... (&17758 - closed)
Implementation Plan For MR widget API changes
- Update
Security::FindingsFinderto:- Add a new
partial_scanparameter - Modify the
lateral_relationto filter bypartial_scanto return findings from a partial scan. See example query.
- Add a new
- Update
Ci::CompareSecurityReportsServiceand check if:- Pipeline has Partial scans and/or Full scans, use
Security::FindingsFinderto query for both full scan findings and partial scan findings. - Pipeline only has full scan, only query for full scan findings.
- Note that both queries will return up to 25 findings.
- Pipeline has Partial scans and/or Full scans, use
- Update
Gitlab:Ci::Reports::Security::SecurityFindingsReportsComparerto:- Add a
added_partialmethod. - Exclude partial scan findings from fixed_findings
- Add a
- Update
Vulnerabilities::FindingReportsComparerEntityto include anadded_partialin the api request
MR Security Widget
Add a new added_partial filed to the security report API:
{
...
"added": [] // For full scan findings
"added_partial": [] // For partial scan findings
...
}
frontend issue: Display GLAS diff-based scan in MR security widget (#543638 - closed)
Pipeline Security Tab
- backend issue: Prepare GLAS diff-based scan data for rails fro... (#554927 - closed) • Ugo Nnanna Okeadu
- frontend issue: Display GLAS diff-based scan in pipeline securi... (#543639 - closed) • Savas Vedova • 18.5
Verification steps
Existing verification project: https://gitlab.com/gitlab-org/govern/threat-insights-demos/verification-projects/partial-scans
-
Create a new project
-
Enable the
vulnerability_partial_scansfeature flag on the project -
Add this
.gitlab-ci.ymlusing a merge request:sast: stage: test script: wget https://gitlab.com/gitlab-org/gitlab/-/raw/5d7bc4e75ae688b968a6debc0b8f62e7eb1f54d1/ee/spec/fixtures/security_reports/master/gl-sast-report-differential.json artifacts: reports: sast: gl-sast-report-differential.json rules: - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH -
Go to
/<project>/-/merge_requests/1/security_reports?type=sast&partial_scan=truetwice (the first time enqueues reactive caching). The partial scan results should show.Verification project: https://gitlab.com/gitlab-org/govern/threat-insights-demos/verification-projects/partial-scans/-/merge_requests/1/security_reports?type=sast&partial_scan=true
-
Send this graphql query:
query enabledScans($fullPath: ID!, $pipelineIid: ID!) { project(fullPath: $fullPath) { id pipeline(iid: $pipelineIid) { id enabledSecurityScans { ready apiFuzzing clusterImageScanning containerScanning coverageFuzzing dast dependencyScanning sast secretDetection } enabledPartialSecurityScans { ready apiFuzzing clusterImageScanning containerScanning coverageFuzzing dast dependencyScanning sast secretDetection } } } }variables:
{ "fullPath": "gitlab-org/govern/threat-insights-demos/verification-projects/partial-scans", "pipelineIid": 3 }It should return the following response:
{ "data": { "project": { "id": "gid://gitlab/Project/74018706", "pipeline": { "id": "gid://gitlab/Ci::Pipeline/2012021717", "enabledSecurityScans": { "ready": true, "apiFuzzing": false, "clusterImageScanning": false, "containerScanning": false, "coverageFuzzing": false, "dast": false, "dependencyScanning": false, "sast": true, "secretDetection": false }, "enabledPartialSecurityScans": { "ready": true, "apiFuzzing": false, "clusterImageScanning": false, "containerScanning": false, "coverageFuzzing": false, "dast": false, "dependencyScanning": false, "sast": true, "secretDetection": false } } } }, "correlationId": "3b31cf8c152ec5b8ad39132838f65953" }