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
f1ba1127
Commit
f1ba1127
authored
Mar 22, 2021
by
Alex Kalderimis
Committed by
Bob Van Landuyt
Mar 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of term whitelist
Uses preferred terminology 'allowed' instead.
parent
3dcc435c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
app/models/concerns/safe_url.rb
app/models/concerns/safe_url.rb
+2
-2
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+1
-1
spec/models/concerns/safe_url_spec.rb
spec/models/concerns/safe_url_spec.rb
+7
-5
No files found.
app/models/concerns/safe_url.rb
View file @
f1ba1127
...
...
@@ -3,12 +3,12 @@
module
SafeUrl
extend
ActiveSupport
::
Concern
def
safe_url
(
usernames_whitelist
:
[])
def
safe_url
(
allowed_usernames
:
[])
return
if
url
.
nil?
uri
=
URI
.
parse
(
url
)
uri
.
password
=
'*****'
if
uri
.
password
uri
.
user
=
'*****'
if
uri
.
user
&&
!
usernames_whitelist
.
in
clude?
(
uri
.
user
)
uri
.
user
=
'*****'
if
uri
.
user
&&
allowed_usernames
.
ex
clude?
(
uri
.
user
)
uri
.
to_s
rescue
URI
::
Error
end
...
...
app/models/remote_mirror.rb
View file @
f1ba1127
...
...
@@ -207,7 +207,7 @@ class RemoteMirror < ApplicationRecord
end
def
safe_url
super
(
usernames_whitelist
:
%w[git]
)
super
(
allowed_usernames
:
%w[git]
)
end
def
bare_url
...
...
spec/models/concerns/safe_url_spec.rb
View file @
f1ba1127
...
...
@@ -26,14 +26,16 @@ RSpec.describe SafeUrl do
context
'when URL contains credentials'
do
let
(
:url
)
{
'http://foo:bar@example.com'
}
it
{
is_expected
.
to
eq
(
'http://*****:*****@example.com'
)}
it
'masks username and password'
do
is_expected
.
to
eq
(
'http://*****:*****@example.com'
)
end
context
'when username is
whitelist
ed'
do
subject
{
test_class
.
safe_url
(
usernames_whitelist:
usernames_whitelist
)
}
context
'when username is
allow
ed'
do
subject
{
test_class
.
safe_url
(
allowed_usernames:
usernames
)
}
let
(
:usernames
_whitelist
)
{
%w[foo]
}
let
(
:usernames
)
{
%w[foo]
}
it
'
does expect the whitelisted username not to be masked
'
do
it
'
masks the password, but not the username
'
do
is_expected
.
to
eq
(
'http://foo:*****@example.com'
)
end
end
...
...
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