Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
d35ee8de
Unverified
Commit
d35ee8de
authored
1 year ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
force whitelist
parent
a3aeb727
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/services/polymorphic_object_finder.rb
+6
-8
6 additions, 8 deletions
app/services/polymorphic_object_finder.rb
with
6 additions
and
8 deletions
app/services/polymorphic_object_finder.rb
+
6
−
8
View file @
d35ee8de
...
...
@@ -10,7 +10,7 @@ class PolymorphicObjectFinder
def
self
.
find
(
params
,
key
:,
university
:,
only:
[])
key_id
=
"
#{
key
}
_id"
.
to_sym
key_type
=
"
#{
key
}
_type"
.
to_sym
model_name
=
self
.
find
_model_name
(
params
,
key_type
,
only
)
model_name
=
self
.
safe
_model_name
(
params
,
key_type
,
only
)
return
if
model_name
.
nil?
model
=
model_name
.
constantize
...
...
@@ -20,12 +20,10 @@ class PolymorphicObjectFinder
private
def
self
.
find_model_name
(
params
,
key_type
,
only
)
if
only
.
any?
# Whitelist user input
only
.
detect
{
|
item
|
item
==
params
[
key_type
]
}
else
params
[
key_type
]
end
# Whitelist user input
def
self
.
safe_model_name
(
params
,
key_type
,
only
)
only
.
detect
{
|
item
|
item
==
params
[
key_type
]
}
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment