Skip to content

Make database changes to persist false_positive information

Saikat Sarkar requested to merge false-positive into master

What does this MR do?

This MR is related to this issue. We are trying to address the following tasks in this MR.

Tasks

  • Create a new table vulnerability_flags to store details about false_positive.

In this MR, we are going to create a new table named vulnerability_flags to store details about the false_positive.

Screenshots or Screencasts (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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

Migration Outputs

Up

➜  gitlab git:(false-positive) ✗ bin/rails db:migrate:up VERSION='20210707171554'
== 20210707171554 CreateVulnerabilityFlags: migrating =========================
-- create_table(:vulnerability_flags, {})
-- quote_column_name(:origin)
   -> 0.0000s
-- quote_column_name(:description)
   -> 0.0000s
   -> 0.0091s
-- quote_table_name("check_49c1d00032")
   -> 0.0000s
-- quote_table_name("check_45e743349f")
   -> 0.0000s
-- quote_table_name(:vulnerability_flags)
   -> 0.0000s
-- execute("ALTER TABLE \"vulnerability_flags\"\nADD CONSTRAINT \"check_49c1d00032\" CHECK (char_length(\"origin\") <= 255),\nADD CONSTRAINT \"check_45e743349f\" CHECK (char_length(\"description\") <= 1024)\n")
   -> 0.0009s
== 20210707171554 CreateVulnerabilityFlags: migrated (0.0162s) ================

Down

➜  gitlab git:(false-positive) bin/rails db:migrate:down VERSION='20210707171554'
== 20210707171554 CreateVulnerabilityFlags: reverting =========================
-- drop_table(:vulnerability_flags)
   -> 0.0073s
== 20210707171554 CreateVulnerabilityFlags: reverted (0.0073s) ================

check inverse_of

[1] pry(main)> Vulnerabilities::Finding.reflect_on_association(:vulnerability_flags).has_inverse?

=> :finding
[2] pry(main)> Vulnerabilities::Flag.reflect_on_association(:finding).has_inverse?

=> :vulnerability_flags
Edited by Saikat Sarkar

Merge request reports