0

I have quick question. Is this code is vulnerable to SQL injection:

ActiveAdmin::SurveyPack.where("survey_schemas @> '{#{survey_schema}}'")

survey_schemas column is an array column in my rails app.

1

2 Answers 2

2

Please make it simple.

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

or

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

Happy coding.

Sign up to request clarification or add additional context in comments.

Comments

1

short answer, yes.

from ActiveAdmin::SurveyPack.where("survey_schemas @> '{#{survey_schema}}'")

to ActiveAdmin::SurveyPack.where("survey_schemas @> '{?}'", survey_schema)

2 Comments

Hmm, this ActiveAdmin::SurveyPack.where("survey_schemas @> '{?}'", survey_schema) returns syntax error.
Something like this works properly: ActiveAdmin::SurveyPack.where("survey_schemas @> ?", '{"#{survey_schema}"}')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.