Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rails通过数组列和SQL注入进行搜索_Sql_Ruby On Rails_Ruby_Postgresql - Fatal编程技术网

Rails通过数组列和SQL注入进行搜索

Rails通过数组列和SQL注入进行搜索,sql,ruby-on-rails,ruby,postgresql,Sql,Ruby On Rails,Ruby,Postgresql,我有个简短的问题。此代码易受SQL注入攻击: ActiveAdmin::SurveyPack.where("survey_schemas @> '{#{survey_schema}}'") survey_schemas列是my rails应用程序中的数组列。简短回答,是的 来自ActiveAdmin::SurveyPack.where(“survey_schema@>'{{survey_schema}}') 到ActiveAdmin::SurveyPack.where(“survey_s

我有个简短的问题。此代码易受SQL注入攻击:

ActiveAdmin::SurveyPack.where("survey_schemas @> '{#{survey_schema}}'")
survey_schemas列是my rails应用程序中的数组列。

简短回答,是的

来自
ActiveAdmin::SurveyPack.where(“survey_schema@>'{{survey_schema}}')

ActiveAdmin::SurveyPack.where(“survey_schema@>'{?}',survey_schema)
简短回答,是的

来自
ActiveAdmin::SurveyPack.where(“survey_schema@>'{{survey_schema}}')

ActiveAdmin::SurveyPack.where(“survey_schema@>'{?}',survey_schema)

请简化

    ActiveAdmin::SurveyPack.where("survey_schemas @> ARRAY[?]", survey_schema)

快乐的编码。

请简单一点

    ActiveAdmin::SurveyPack.where("survey_schemas @> ARRAY[?]", survey_schema)


愉快的编码。

Hmm,这个ActiveAdmin::SurveyPack.where(“survey_schemas@>'{?}',survey_schemas”)返回语法错误。类似的东西可以正常工作:ActiveAdmin::SurveyPack.where(“survey_schemas@>>,'{{survey_schemas}')Hmm,这个ActiveAdmin::SurveyPack.where(“survey_schemas@>'{?}',survey_schema”)返回语法错误。类似的操作正常:ActiveAdmin::SurveyPack.where(“survey_schema@>?”,“{{survey_schema}}”)