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
cb865035
Commit
cb865035
authored
Mar 31, 2020
by
mbergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure localhost URLs are valid
parent
0086f377
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
ee/app/models/ee/application_setting.rb
ee/app/models/ee/application_setting.rb
+1
-1
ee/spec/models/application_setting_spec.rb
ee/spec/models/application_setting_spec.rb
+2
-1
lib/gitlab/url_blocker.rb
lib/gitlab/url_blocker.rb
+2
-2
No files found.
ee/app/models/ee/application_setting.rb
View file @
cb865035
...
...
@@ -298,7 +298,7 @@ module EE
# ElasticSearch only exposes a RESTful API, hence we need
# to use the HTTP protocol on all URLs.
elasticsearch_url
.
each
do
|
str
|
::
Gitlab
::
UrlBlocker
.
validate!
(
str
,
schemes:
%w[http https]
)
::
Gitlab
::
UrlBlocker
.
validate!
(
str
,
schemes:
%w[http https]
,
allow_localhost:
true
)
end
rescue
::
Gitlab
::
UrlBlocker
::
BlockedUrlError
errors
.
add
(
:elasticsearch_url
,
"only supports valid HTTP(S) URLs."
)
...
...
ee/spec/models/application_setting_spec.rb
View file @
cb865035
...
...
@@ -111,12 +111,13 @@ describe ApplicationSetting do
"http://10.0.0.1"
|
true
"https://10.0.0.1"
|
true
"http://10.0.0.1, https://10.0.0.1"
|
true
"http://localhost"
|
true
"http://127.0.0.1"
|
true
"es.localdomain"
|
false
"10.0.0.1"
|
false
"http://es.localdomain, es.localdomain"
|
false
"http://es.localdomain, 10.0.0.1"
|
false
"this_isnt_a_url"
|
false
end
...
...
lib/gitlab/url_blocker.rb
View file @
cb865035
...
...
@@ -11,8 +11,8 @@ module Gitlab
# Validates the given url according to the constraints specified by arguments.
#
# ports - Raises error if the given URL port does is not between given ports.
# allow_localhost - Raises error if URL resolves to a localhost IP address and argument is
tru
e.
# allow_local_network - Raises error if URL resolves to a link-local address and argument is
tru
e.
# allow_localhost - Raises error if URL resolves to a localhost IP address and argument is
fals
e.
# allow_local_network - Raises error if URL resolves to a link-local address and argument is
fals
e.
# ascii_only - Raises error if URL has unicode characters and argument is true.
# enforce_user - Raises error if URL user doesn't start with alphanumeric characters and argument is true.
# enforce_sanitization - Raises error if URL includes any HTML/CSS/JS tags and argument is true.
...
...
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