Skip to content

Add option for switching between block log

Zamir Martins requested to merge add_option_for_switching_between_block_log into master

What does this MR do?

Add option for switching WAF modes. Modes can be either logging and blocking in addition to enabling or disabling ModSecurity.

This MR depends on !26720 (merged) to be merged.

Related issue: #207173 (closed)

Database output

== 20200311214912 AddModsecurityModeToIngressApplication: migrating ===========
-- transaction_open?()
   -> 0.0000s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- transaction()
-- add_column(:clusters_applications_ingress, :modsecurity_mode, :smallint, {:default=>nil})
   -> 0.0029s
-- change_column_default(:clusters_applications_ingress, :modsecurity_mode, 0)
   -> 0.0033s
   -> 0.0070s
-- columns(:clusters_applications_ingress)
   -> 0.0011s
-- transaction_open?()
   -> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"clusters_applications_ingress\"")
   -> 0.0007s
-- exec_query("SELECT \"clusters_applications_ingress\".\"id\" FROM \"clusters_applications_ingress\" ORDER BY \"clusters_applications_ingress\".\"id\" ASC LIMIT 1")
   -> 0.0006s
-- exec_query("SELECT \"clusters_applications_ingress\".\"id\" FROM \"clusters_applications_ingress\" WHERE \"clusters_applications_ingress\".\"id\" >= 19 ORDER BY \"clusters_applications_ingress\".\"id\" ASC LIMIT 1 OFFSET 1")
   -> 0.0005s
-- execute("UPDATE \"clusters_applications_ingress\" SET \"modsecurity_mode\" = 0 WHERE \"clusters_applications_ingress\".\"id\" >= 19")
   -> 0.0008s
-- change_column_null(:clusters_applications_ingress, :modsecurity_mode, false)
   -> 0.0007s
-- execute("RESET ALL")
   -> 0.0004s
== 20200311214912 AddModsecurityModeToIngressApplication: migrated (0.0133s) ==

Screenshots

Enabling WAF in block mode in a fresh installation:

Screen_Shot_2020-03-12_at_1.45.38_PM

Disabling WAF in a fresh installation:

Screen_Shot_2020-03-12_at_1.45.55_PM

Updating in progress for an existing installation:

Screen_Shot_2020-03-12_at_1.46.53_PM

Changing WAF mode for an existing installation:

Screen_Shot_2020-03-12_at_1.46.26_PM

Error while updating:

Screen_Shot_2020-03-12_at_1.47.27_PM

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 Rémy Coutable

Merge request reports