Add option for switching between block log
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:
Disabling WAF in a fresh installation:
Updating in progress for an existing installation:
Changing WAF mode for an existing installation:
Error while updating:
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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