Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
276b063d
Commit
276b063d
authored
May 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
fc3b72db
6f4a5762
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
2 deletions
+50
-2
config/database.yml.example
config/database.yml.example
+0
-0
config/initializers/rack_attack_logging.rb
config/initializers/rack_attack_logging.rb
+9
-1
doc/administration/logs.md
doc/administration/logs.md
+9
-0
doc/security/rack_attack.md
doc/security/rack_attack.md
+1
-1
lib/gitlab/auth_logger.rb
lib/gitlab/auth_logger.rb
+9
-0
spec/requests/rack_attack_global_spec.rb
spec/requests/rack_attack_global_spec.rb
+22
-0
No files found.
config/database.yml.example
0 → 100644
View file @
276b063d
config/initializers/rack_attack_logging.rb
View file @
276b063d
# frozen_string_literal: true
#
# Adds logging for all Rack Attack blocks and throttling events.
# Adds logging for all Rack Attack blocks and throttling events.
ActiveSupport
::
Notifications
.
subscribe
(
'rack.attack'
)
do
|
name
,
start
,
finish
,
request_id
,
req
|
ActiveSupport
::
Notifications
.
subscribe
(
'rack.attack'
)
do
|
name
,
start
,
finish
,
request_id
,
req
|
if
[
:throttle
,
:blacklist
].
include?
req
.
env
[
'rack.attack.match_type'
]
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
}
"
)
Gitlab
::
AuthLogger
.
error
(
message:
'Rack_Attack'
,
env:
req
.
env
[
'rack.attack.match_type'
],
ip:
req
.
ip
,
request_method:
req
.
request_method
,
fullpath:
req
.
fullpath
)
end
end
end
end
doc/administration/logs.md
View file @
276b063d
...
@@ -280,6 +280,14 @@ installations from source.
...
@@ -280,6 +280,14 @@ installations from source.
Currently it logs the progress of project imports from the Bitbucket Server
Currently it logs the progress of project imports from the Bitbucket Server
importer. Future importers may use this file.
importer. Future importers may use this file.
## `auth.log`
Introduced in GitLab 12.0. This file lives in
`/var/log/gitlab/gitlab-rails/auth.log`
for
Omnibus GitLab packages or in
`/home/git/gitlab/log/auth.log`
for
installations from source.
It logs information whenever [Rack Attack] registers an abusive request.
## Reconfigure Logs
## Reconfigure Logs
Reconfigure log files live in
`/var/log/gitlab/reconfigure`
for Omnibus GitLab
Reconfigure log files live in
`/var/log/gitlab/reconfigure`
for Omnibus GitLab
...
@@ -298,3 +306,4 @@ Omnibus GitLab packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
...
@@ -298,3 +306,4 @@ Omnibus GitLab packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
installations from source.
installations from source.
[
repocheck
]:
repository_checks.md
[
repocheck
]:
repository_checks.md
[
Rack Attack
]:
../security/rack_attack.md
doc/security/rack_attack.md
View file @
276b063d
...
@@ -94,7 +94,7 @@ In case you want to remove a blocked IP, follow these steps:
...
@@ -94,7 +94,7 @@ In case you want to remove a blocked IP, follow these steps:
1.
Find the IPs that have been blocked in the production log:
1.
Find the IPs that have been blocked in the production log:
```sh
```sh
grep "Rack_Attack" /var/log/gitlab/gitlab-rails/
production
.log
grep "Rack_Attack" /var/log/gitlab/gitlab-rails/
auth
.log
```
```
1.
Since the blacklist is stored in Redis, you need to open up
`redis-cli`
:
1.
Since the blacklist is stored in Redis, you need to open up
`redis-cli`
:
...
...
lib/gitlab/auth_logger.rb
0 → 100644
View file @
276b063d
# frozen_string_literal: true
module
Gitlab
class
AuthLogger
<
Gitlab
::
JsonLogger
def
self
.
file_name_noext
'auth'
end
end
end
spec/requests/rack_attack_global_spec.rb
View file @
276b063d
...
@@ -182,6 +182,17 @@ describe 'Rack Attack global throttles' do
...
@@ -182,6 +182,17 @@ describe 'Rack Attack global throttles' do
end
end
end
end
end
end
it
'logs RackAttack info into structured logs'
do
requests_per_period
.
times
do
get
url_that_does_not_require_authentication
expect
(
response
).
to
have_http_status
200
end
expect
(
Gitlab
::
AuthLogger
).
to
receive
(
:error
).
once
get
url_that_does_not_require_authentication
end
end
end
context
'when the throttle is disabled'
do
context
'when the throttle is disabled'
do
...
@@ -327,6 +338,17 @@ describe 'Rack Attack global throttles' do
...
@@ -327,6 +338,17 @@ describe 'Rack Attack global throttles' do
expect_rejection
{
get
url_that_requires_authentication
}
expect_rejection
{
get
url_that_requires_authentication
}
end
end
it
'logs RackAttack info into structured logs'
do
requests_per_period
.
times
do
get
url_that_requires_authentication
expect
(
response
).
to
have_http_status
200
end
expect
(
Gitlab
::
AuthLogger
).
to
receive
(
:error
).
once
get
url_that_requires_authentication
end
end
end
context
'when the throttle is disabled'
do
context
'when the throttle is disabled'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment