Skip to content

Set vulnerability as dismissed when there is dismissal feedback

What does this MR do?

Related to #280589 (closed)

This change adds background migration to fix problem with vulnerabilities that are not dismissed, when they have dismissal feedback created for associated findings.

Migration

$ env VERBOSE=true bundle exec rake db:migrate:down VERSION=20201130103926
== 20201130103926 SchedulePopulateDismissedStateForVulnerabilities: reverting =
== 20201130103926 SchedulePopulateDismissedStateForVulnerabilities: reverted (0.0000s) 
$ env VERBOSE=true bundle exec rake db:migrate:up VERSION=20201130103926                                           06:52:12
== 20201130103926 SchedulePopulateDismissedStateForVulnerabilities: migrating =
-- exec_query("SELECT \"vulnerability_occurrences\".\"vulnerability_id\"\nFROM \"vulnerability_occurrences\"\nJOIN \"vulnerabilities\"\nON \"vulnerability_occurrences\".\"vulnerability_id\" = \"vulnerabilities\".\"id\" AND \"vulnerabilities\".\"state\" != 2\nJOIN \"vulnerability_feedback\"\nON \"vulnerability_occurrences\".\"project_id\" = \"vulnerability_feedback\".\"project_id\"\n  AND \"vulnerability_occurrences\".\"report_type\" = \"vulnerability_feedback\".\"category\"\n  AND ENCODE(\"vulnerability_occurrences\".\"project_fingerprint\", 'hex') = \"vulnerability_feedback\".\"project_fingerprint\"\n  AND \"vulnerability_feedback\".\"feedback_type\" = 0\nORDER BY \"vulnerability_occurrences\".\"vulnerability_id\" ASC;\n")
   -> 0.0108s
== 20201130103926 SchedulePopulateDismissedStateForVulnerabilities: migrated (0.0109s) 

Queries

SELECT "vulnerability_occurrences"."vulnerability_id"
FROM "vulnerability_occurrences"
JOIN "vulnerabilities"
ON "vulnerability_occurrences"."vulnerability_id" = "vulnerabilities"."id" AND "vulnerabilities"."state" != 2
JOIN "vulnerability_feedback"
ON "vulnerability_occurrences"."project_id" = "vulnerability_feedback"."project_id"
  AND "vulnerability_occurrences"."report_type" = "vulnerability_feedback"."category"
  AND ENCODE("vulnerability_occurrences"."project_fingerprint", 'hex') = "vulnerability_feedback"."project_fingerprint"
  AND "vulnerability_feedback"."feedback_type" = 0
ORDER BY "vulnerability_occurrences"."vulnerability_id" ASC;

https://explain.depesz.com/s/curR (~950ms)

Calculations

This is a migration that uses other migration described here: !46370 (merged)

  • 1000 Vulnerability IDs in a batch
  • 33290 rows in database
  • 34 batches
  • 2 minutes for each batch
  • 34 * 2 minutes = 68 minutes

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Alan (Maciej) Paruszewski

Merge request reports

Loading