Skip to content

Add default value to vulnerabilities_allowed column

What does this MR do?

Add default value to vulnerabilities_allowed column under project_approval_rules table. The default has been set to zero so it is consistent with the value set in the model.

Related issue: #337364 (closed)

DB migrate
$ bundle exec rails db:migrate
== 20210818220234 AddDefaultProjectApprovalRulesVulnAllowed: migrating ========
-- change_column_default(:approval_project_rules, :vulnerabilities_allowed, 0)
   -> 0.0098s
-- change_column_null(:approval_project_rules, :vulnerabilities_allowed, false, 0)
   -> 0.0037s
== 20210818220234 AddDefaultProjectApprovalRulesVulnAllowed: migrated (0.0136s)
                                            Table "public.approval_project_rules"
         Column          |           Type           | Collation | Nullable |                      Default
-------------------------+--------------------------+-----------+----------+----------------------------------------------------
 id                      | bigint                   |           | not null | nextval('approval_project_rules_id_seq'::regclass)
 created_at              | timestamp with time zone |           | not null |
 updated_at              | timestamp with time zone |           | not null |
 project_id              | integer                  |           | not null |
 approvals_required      | smallint                 |           | not null | 0
 name                    | character varying        |           | not null |
 rule_type               | smallint                 |           | not null | 0
 scanners                | text[]                   |           |          |
 vulnerabilities_allowed | smallint                 |           | not null | 0
 severity_levels         | text[]                   |           | not null | '{}'::text[]
DB rollback
$ bundle exec rails db:rollback
== 20210818220234 AddDefaultProjectApprovalRulesVulnAllowed: reverting ========
-- change_column_default(:approval_project_rules, :vulnerabilities_allowed, nil)
   -> 0.0050s
-- change_column_null(:approval_project_rules, :vulnerabilities_allowed, true)
   -> 0.0015s
== 20210818220234 AddDefaultProjectApprovalRulesVulnAllowed: reverted (0.0065s)
                                      Table "public.approval_project_rules"
         Column          |           Type           | Collation | Nullable |                      Default
-------------------------+--------------------------+-----------+----------+----------------------------------------------------
 id                      | bigint                   |           | not null | nextval('approval_project_rules_id_seq'::regclass)
 created_at              | timestamp with time zone |           | not null |
 updated_at              | timestamp with time zone |           | not null |
 project_id              | integer                  |           | not null |
 approvals_required      | smallint                 |           | not null | 0
 name                    | character varying        |           | not null |
 rule_type               | smallint                 |           | not null | 0
 scanners                | text[]                   |           |          |
 vulnerabilities_allowed | smallint                 |           |          |
 severity_levels         | text[]                   |           | not null | '{}'::text[]

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (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
Edited by Zamir Martins

Merge request reports