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
a1a47383
Commit
a1a47383
authored
Nov 15, 2021
by
Rajendra Kadam
Committed by
Markus Koller
Nov 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add allow list approach to mask query params
parent
5e88a37a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
app/helpers/routing/pseudonymization_helper.rb
app/helpers/routing/pseudonymization_helper.rb
+4
-7
spec/helpers/routing/pseudonymization_helper_spec.rb
spec/helpers/routing/pseudonymization_helper_spec.rb
+23
-2
No files found.
app/helpers/routing/pseudonymization_helper.rb
View file @
a1a47383
...
@@ -3,10 +3,7 @@
...
@@ -3,10 +3,7 @@
module
Routing
module
Routing
module
PseudonymizationHelper
module
PseudonymizationHelper
class
MaskHelper
class
MaskHelper
QUERY_PARAMS_TO_MASK
=
%w[
QUERY_PARAMS_TO_NOT_MASK
=
%w[]
.
freeze
assignee_username
author_username
]
.
freeze
def
initialize
(
request_object
,
group
,
project
)
def
initialize
(
request_object
,
group
,
project
)
@request
=
request_object
@request
=
request_object
...
@@ -71,10 +68,10 @@ module Routing
...
@@ -71,10 +68,10 @@ module Routing
query_string_hash
=
Rack
::
Utils
.
parse_nested_query
(
@request
.
query_string
)
query_string_hash
=
Rack
::
Utils
.
parse_nested_query
(
@request
.
query_string
)
QUERY_PARAMS_TO_MASK
.
each
do
|
maskable_attribute
|
query_string_hash
.
keys
.
each
do
|
key
|
next
unless
query_string_hash
.
has_key?
(
maskable_attribute
)
next
if
QUERY_PARAMS_TO_NOT_MASK
.
include?
(
key
)
query_string_hash
[
maskable_attribute
]
=
"masked_
#{
maskable_attribute
}
"
query_string_hash
[
key
]
=
"masked_
#{
key
}
"
end
end
query_string_hash
query_string_hash
...
...
spec/helpers/routing/pseudonymization_helper_spec.rb
View file @
a1a47383
...
@@ -160,7 +160,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do
...
@@ -160,7 +160,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end
end
context
'when author_username is present'
do
context
'when author_username is present'
do
let
(
:masked_url
)
{
"http://localhost/dashboard/issues?author_username=masked_author_username&scope=
all&state=opened
"
}
let
(
:masked_url
)
{
"http://localhost/dashboard/issues?author_username=masked_author_username&scope=
masked_scope&state=masked_state
"
}
let
(
:request
)
do
let
(
:request
)
do
double
(
:Request
,
double
(
:Request
,
path_parameters:
{
path_parameters:
{
...
@@ -179,8 +179,29 @@ RSpec.describe ::Routing::PseudonymizationHelper do
...
@@ -179,8 +179,29 @@ RSpec.describe ::Routing::PseudonymizationHelper do
it_behaves_like
'masked url'
it_behaves_like
'masked url'
end
end
context
'when some query params are not required to be masked'
do
let
(
:masked_url
)
{
"http://localhost/dashboard/issues?author_username=masked_author_username&scope=all&state=masked_state"
}
let
(
:request
)
do
double
(
:Request
,
path_parameters:
{
controller:
'dashboard'
,
action:
'issues'
},
protocol:
'http'
,
host:
'localhost'
,
query_string:
'author_username=root&scope=all&state=opened'
)
end
before
do
stub_const
(
'Routing::PseudonymizationHelper::MaskHelper::QUERY_PARAMS_TO_NOT_MASK'
,
%w[scope]
.
freeze
)
allow
(
helper
).
to
receive
(
:request
).
and_return
(
request
)
end
it_behaves_like
'masked url'
end
context
'when query string has keys with the same names as path params'
do
context
'when query string has keys with the same names as path params'
do
let
(
:masked_url
)
{
"http://localhost/dashboard/issues?action=
foobar&scope=all&state=opened
"
}
let
(
:masked_url
)
{
"http://localhost/dashboard/issues?action=
masked_action&scope=masked_scope&state=masked_state
"
}
let
(
:request
)
do
let
(
:request
)
do
double
(
:Request
,
double
(
:Request
,
path_parameters:
{
path_parameters:
{
...
...
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