Referesh vulnerability_statistics following SAST Resolution of no-longer-detected vulnerability
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
In the vulnerability ingestion process, when a vulnerability is no longer detected, it should be automatically resolved if and only if there is a vulnerability management policy to do that.
However, it appears that this is not the case, and that vulnerabilities are automatically resolved even without the policy configured.
Furthermore, when such a vulnerability is automatically resolved, the vulnerability_statistics table isn't updated with the new decreased counter.
Steps to reproduce
- Create a new project.
- Make sure no policy is configured.
- Push a report with N vulnerabilities.
- See that there are N vulnerabilities in the vulnerability report page.
- See that the
vulnerability_statisticstable has a row with N vulnerabilities. - Delete one vulnerability from the report and push it.
- See that there are still N vulnerabilities in the vulnerability report page, but now the one we deleted is resolved (it might take a refresh or two until this happens).
- See that the
vulnerability_statisticstable the counters weren't updated
Example Project
What is the current bug behavior?
- The vulnerability is auto-resolved even without a policy
- The counters aren't affected by the resolved vulnerability
What is the expected correct behavior?
- The vulnerability shouldn't be auto-resolved
- If it is, the counters should reflect this.
Relevant logs and/or screenshots
Screen_Recording_2025-04-03_at_11.09.25
Output of checks
This bug happens on GitLab.com
In my test, I showed it in a gdk project, but @gkatz1 and I noticed it in prod when verifying this issue.
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
Update Vulnerabilities::MarkDroppedAsResolvedWorker to call Vulnerabilities::Statistics::AdjustmentWorker.perform_async([project.id])