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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
16772b91
Commit
16772b91
authored
Apr 03, 2019
by
rpereira2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove permitting of params
- It is now being done in ProxyService class.
parent
eac3e230
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
21 deletions
+5
-21
app/controllers/projects/environments/prometheus_api_controller.rb
...ollers/projects/environments/prometheus_api_controller.rb
+5
-12
spec/controllers/projects/environments/prometheus_api_controller_spec.rb
...s/projects/environments/prometheus_api_controller_spec.rb
+0
-9
No files found.
app/controllers/projects/environments/prometheus_api_controller.rb
View file @
16772b91
...
...
@@ -5,13 +5,11 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
before_action
:environment
def
proxy
permitted
=
permit_params
result
=
Prometheus
::
ProxyService
.
new
(
environment
,
request
.
method
,
p
ermitted
[
:proxy_path
],
p
ermitted
.
except
(
:proxy_path
)
# rubocop: disable CodeReuse/ActiveRecord
p
arams
[
:proxy_path
],
p
arams
).
execute
if
result
.
nil?
...
...
@@ -24,20 +22,15 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
if
result
[
:status
]
==
:success
render
status:
result
[
:http_status
],
json:
result
[
:body
]
else
render
status:
result
[
:http_status
]
||
:bad_request
,
render
(
status:
result
[
:http_status
]
||
:bad_request
,
json:
{
status:
result
[
:status
],
message:
result
[
:message
]
}
)
end
end
private
def
permit_params
params
.
permit
([
:proxy_path
,
:query
,
:time
,
:timeout
,
:start
,
:end
,
:step
,
{
match:
[]
},
:match_target
,
:metric
,
:limit
])
end
def
environment
@environment
||=
project
.
environments
.
find
(
params
[
:id
])
end
...
...
spec/controllers/projects/environments/prometheus_api_controller_spec.rb
View file @
16772b91
...
...
@@ -36,15 +36,6 @@ describe Projects::Environments::PrometheusApiController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
(
prometheus_json_body
)
end
it
'filters unknown params'
do
get
:proxy
,
params:
environment_params
(
unknown_param:
'value'
)
params
=
ActionController
::
Parameters
.
new
(
'query'
=>
'1'
).
permit!
expect
(
Prometheus
::
ProxyService
)
.
to
have_received
(
:new
)
.
with
(
environment
,
'GET'
,
'query'
,
params
)
end
end
context
'with nil result'
do
...
...
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