[#2579] Protect against SQL injection on column and table in filtered_ids
This commit is contained in:
parent
670edc3279
commit
1ac8840bc9
1 changed files with 5 additions and 5 deletions
|
@ -100,7 +100,7 @@ class DossierFieldService
|
||||||
|
|
||||||
def sorted_ids(dossiers, procedure_presentation, gestionnaire)
|
def sorted_ids(dossiers, procedure_presentation, gestionnaire)
|
||||||
table = procedure_presentation.sort['table']
|
table = procedure_presentation.sort['table']
|
||||||
column = procedure_presentation.sort['column']
|
column = sanitized_column(procedure_presentation.sort)
|
||||||
order = procedure_presentation.sort['order']
|
order = procedure_presentation.sort['order']
|
||||||
assert_valid_order(order)
|
assert_valid_order(order)
|
||||||
|
|
||||||
|
@ -117,23 +117,23 @@ class DossierFieldService
|
||||||
end
|
end
|
||||||
when 'self'
|
when 'self'
|
||||||
return dossiers
|
return dossiers
|
||||||
.order("dossiers.#{column} #{order}")
|
.order("#{column} #{order}")
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
when 'france_connect_information'
|
when 'france_connect_information'
|
||||||
return dossiers
|
return dossiers
|
||||||
.includes(user: :france_connect_information)
|
.includes(user: :france_connect_information)
|
||||||
.order("france_connect_informations.#{column} #{order}")
|
.order("#{column} #{order}")
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
when 'type_de_champ', 'type_de_champ_private'
|
when 'type_de_champ', 'type_de_champ_private'
|
||||||
return dossiers
|
return dossiers
|
||||||
.includes(table == 'type_de_champ' ? :champs : :champs_private)
|
.includes(table == 'type_de_champ' ? :champs : :champs_private)
|
||||||
.where("champs.type_de_champ_id = #{column.to_i}")
|
.where("champs.type_de_champ_id = #{procedure_presentation.sort['column'].to_i}")
|
||||||
.order("champs.value #{order}")
|
.order("champs.value #{order}")
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
else
|
else
|
||||||
return dossiers
|
return dossiers
|
||||||
.includes(table)
|
.includes(table)
|
||||||
.order("#{table.pluralize}.#{column} #{order}")
|
.order("#{column} #{order}")
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue