summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-11-19 10:44:27 +0000
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-11-19 16:54:33 +0000
commit246feb6ab715936fe4e7134023b761a2cdbe7674 (patch)
tree1304309b6c7b3b23b5a031f77a27072ce7e16028
parent14f06891722ea501b1a47886b69aac3041b78e4d (diff)
downloadgitlab-ce-246feb6ab715936fe4e7134023b761a2cdbe7674.tar.gz
Merge branch 'add-logging-to-rack-attack' into 'master'
Add logging for rack attack events Patch for issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/15612 and partial patch for https://gitlab.com/gitlab-com/support/issues/119. Also related: https://gitlab.com/gitlab-org/gitlab-ce/issues/22527 Adds logging for throttle and blacklist rack attack events to the production log. @stanhu @MrChrisW See merge request !7585
-rw-r--r--changelogs/unreleased/rack_attack_logging.yml4
-rw-r--r--config/initializers/rack_attack_logging.rb7
2 files changed, 11 insertions, 0 deletions
diff --git a/changelogs/unreleased/rack_attack_logging.yml b/changelogs/unreleased/rack_attack_logging.yml
new file mode 100644
index 00000000000..c0d6c1fd12e
--- /dev/null
+++ b/changelogs/unreleased/rack_attack_logging.yml
@@ -0,0 +1,4 @@
+---
+title: Add logging for rack attack events to production.log
+merge_request:
+author:
diff --git a/config/initializers/rack_attack_logging.rb b/config/initializers/rack_attack_logging.rb
new file mode 100644
index 00000000000..8bb9ea29c33
--- /dev/null
+++ b/config/initializers/rack_attack_logging.rb
@@ -0,0 +1,7 @@
+# Adds logging for all Rack Attack blocks and throttling events.
+
+ActiveSupport::Notifications.subscribe('rack.attack') do |name, start, finish, request_id, req|
+ if [:throttle, :blacklist].include? req.env['rack.attack.match_type']
+ Rails.logger.info("Rack_Attack: #{req.env['rack.attack.match_type']} #{req.ip} #{req.request_method} #{req.fullpath}")
+ end
+end