Make database changes to persist false_positive information
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
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) - [-] I have added/updated documentation, or it's not needed. (Is documentation required?)
- We don't need the documentation change yet as we have not introduced the actual feature yet.
-
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) - This MR will create a fresh table and will not perform any operations on the existing tables. So, this process should not hamper the performance of existing system
- According to Merge request performance guidelines, eager-loading has been used to optimize database queries.
-
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) - [-] I have tested this MR in all supported browsers, or it's not needed.
- Not needed
- [-] I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
- Not needed.
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) ================
inverse_of
check [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