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
2a304b4c
Commit
2a304b4c
authored
Jul 01, 2020
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape metrics dashboard paths
Encode dashboard paths when used as query params.
parent
5655d7cb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
3 deletions
+61
-3
app/assets/javascripts/monitoring/components/dashboard_header.vue
...ts/javascripts/monitoring/components/dashboard_header.vue
+1
-1
app/assets/javascripts/monitoring/monitoring_app.js
app/assets/javascripts/monitoring/monitoring_app.js
+2
-1
app/controllers/concerns/metrics_dashboard.rb
app/controllers/concerns/metrics_dashboard.rb
+11
-1
changelogs/unreleased/rc-escape_dashboard_paths.yml
changelogs/unreleased/rc-escape_dashboard_paths.yml
+5
-0
spec/controllers/concerns/metrics_dashboard_spec.rb
spec/controllers/concerns/metrics_dashboard_spec.rb
+16
-0
spec/frontend/monitoring/components/dashboard_spec.js
spec/frontend/monitoring/components/dashboard_spec.js
+26
-0
No files found.
app/assets/javascripts/monitoring/components/dashboard_header.vue
View file @
2a304b4c
...
...
@@ -136,7 +136,7 @@ export default {
]),
selectDashboard
(
dashboard
)
{
const
params
=
{
dashboard
:
dashboard
.
path
,
dashboard
:
encodeURIComponent
(
dashboard
.
path
)
,
};
redirectTo
(
mergeUrlParams
(
params
,
window
.
location
.
href
));
},
...
...
app/assets/javascripts/monitoring/monitoring_app.js
View file @
2a304b4c
...
...
@@ -11,7 +11,8 @@ export default (props = {}) => {
const
el
=
document
.
getElementById
(
'
prometheus-graphs
'
);
if
(
el
&&
el
.
dataset
)
{
const
[
currentDashboard
]
=
getParameterValues
(
'
dashboard
'
);
const
[
encodedDashboard
]
=
getParameterValues
(
'
dashboard
'
);
const
currentDashboard
=
encodedDashboard
?
decodeURIComponent
(
encodedDashboard
)
:
null
;
const
{
metricsDashboardBasePath
,
...
dataset
}
=
el
.
dataset
;
const
{
initState
,
dataProps
}
=
stateAndPropsFromDataset
({
currentDashboard
,
...
dataset
});
...
...
app/controllers/concerns/metrics_dashboard.rb
View file @
2a304b4c
...
...
@@ -13,7 +13,7 @@ module MetricsDashboard
result
=
dashboard_finder
.
find
(
project_for_dashboard
,
current_user
,
metrics_dashboard_params
.
to_h
.
symbolize_key
s
decoded_param
s
)
if
result
...
...
@@ -114,4 +114,14 @@ module MetricsDashboard
json:
result
.
slice
(
:all_dashboards
,
:message
,
:status
)
}
end
def
decoded_params
params
=
metrics_dashboard_params
if
params
[
:dashboard_path
]
params
[
:dashboard_path
]
=
CGI
.
unescape
(
params
[
:dashboard_path
])
end
params
end
end
changelogs/unreleased/rc-escape_dashboard_paths.yml
0 → 100644
View file @
2a304b4c
---
title
:
Allow special characters in dashboard path
merge_request
:
32714
author
:
type
:
fixed
spec/controllers/concerns/metrics_dashboard_spec.rb
View file @
2a304b4c
...
...
@@ -76,6 +76,22 @@ RSpec.describe MetricsDashboard do
end
end
context
'when dashboard path includes encoded characters'
do
let
(
:params
)
{
{
dashboard_path:
'dashboard%26copy.yml'
}
}
before
do
allow
(
controller
)
.
to
receive
(
:metrics_dashboard_params
)
.
and_return
(
params
)
end
it
'decodes dashboard path'
do
expect
(
::
Gitlab
::
Metrics
::
Dashboard
::
Finder
).
to
receive
(
:find
).
with
(
anything
,
anything
,
hash_including
(
dashboard_path:
'dashboard©.yml'
))
json_response
end
end
context
'when parameters are provided and the list of all dashboards is required'
do
before
do
allow
(
controller
).
to
receive
(
:include_all_dashboards?
).
and_return
(
true
)
...
...
spec/frontend/monitoring/components/dashboard_spec.js
View file @
2a304b4c
...
...
@@ -426,6 +426,32 @@ describe('Dashboard', () => {
);
});
});
describe
(
'
when custom dashboard is selected
'
,
()
=>
{
const
windowLocation
=
window
.
location
;
const
findDashboardDropdown
=
()
=>
wrapper
.
find
(
DashboardHeader
).
find
(
DashboardsDropdown
);
beforeEach
(()
=>
{
delete
window
.
location
;
window
.
location
=
{
...
windowLocation
,
assign
:
jest
.
fn
()
};
createMountedWrapper
();
return
wrapper
.
vm
.
$nextTick
();
});
afterEach
(()
=>
{
window
.
location
=
windowLocation
;
});
it
(
'
encodes dashboard param
'
,
()
=>
{
findDashboardDropdown
().
vm
.
$emit
(
'
selectDashboard
'
,
{
path
:
'
dashboard©.yml
'
,
});
expect
(
window
.
location
.
assign
).
toHaveBeenCalledWith
(
'
http://localhost/?dashboard=dashboard%2526copy.yml
'
,
);
});
});
});
describe
(
'
when all requests have been commited by the store
'
,
()
=>
{
...
...
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