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
ae108ff7
Commit
ae108ff7
authored
Jul 31, 2016
by
lookatmike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured.
parent
e299504b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
0 deletions
+9
-0
CHANGELOG
CHANGELOG
+1
-0
config/initializers/trusted_proxies.rb
config/initializers/trusted_proxies.rb
+2
-0
spec/initializers/trusted_proxies_spec.rb
spec/initializers/trusted_proxies_spec.rb
+6
-0
No files found.
CHANGELOG
View file @
ae108ff7
...
...
@@ -36,6 +36,7 @@ v 8.11.0 (unreleased)
- Make error pages responsive (Takuya Noguchi)
- Change requests_profiles resource constraint to catch virtually any file
- Reduce number of queries made for merge_requests/:id/diffs
- Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured.
v 8.10.3 (unreleased)
- Fix hooks missing on imported GitLab projects
...
...
config/initializers/trusted_proxies.rb
View file @
ae108ff7
...
...
@@ -7,6 +7,8 @@ module Rack
class
Request
def
trusted_proxy?
(
ip
)
Rails
.
application
.
config
.
action_dispatch
.
trusted_proxies
.
any?
{
|
proxy
|
proxy
===
ip
}
rescue
IPAddr
::
InvalidAddressError
false
end
end
end
...
...
spec/initializers/trusted_proxies_spec.rb
View file @
ae108ff7
...
...
@@ -47,6 +47,12 @@ describe 'trusted_proxies', lib: true do
expect
(
request
.
remote_ip
).
to
eq
(
'1.1.1.1'
)
expect
(
request
.
ip
).
to
eq
(
'1.1.1.1'
)
end
it
'handles invalid ip addresses'
do
request
=
stub_request
(
'HTTP_X_FORWARDED_FOR'
=>
'(null), 1.1.1.1:12345, 1.1.1.1'
)
expect
(
request
.
remote_ip
).
to
eq
(
'1.1.1.1'
)
expect
(
request
.
ip
).
to
eq
(
'1.1.1.1'
)
end
end
def
stub_request
(
headers
=
{})
...
...
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