New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive (dynamic SQL from a case statement) #972

brandonwamboldt opened this Issue Dec 6, 2016 · 1 comment


None yet
2 participants

I have code like this:

group_by_col =
      case params[:group_by]
      when 'brand'            then 'brand'
      when 'year'             then 'YEAR(date_utc)'
      when 'month'            then "CONCAT(YEAR(date_utc), '-', LPAD(MONTH(date_utc), 2, '0'))"
      when 'week'             then "CONCAT(YEAR(date_utc), '-', LPAD(WEEK(date_utc, 1), 2, '0'))"
      when 'day'              then "DATE(date_utc)"
      else raise ArgumentError, 'Invalid group by value'

query = "SELECT id, #{group_by_col} AS group_by_col, COUNT(*) FROM records"

rows = Record.connection.select_rows(query)

This gives me a possible SQL injection warning using -w3, and I have no idea how to change it to make brakeman stop complaining.


This comment has been minimized.

Show comment
Hide comment

presidentbeef Dec 6, 2016


Hi Brandon,

Yes, this is essentially the same as #944. It's on my roadmap.


presidentbeef commented Dec 6, 2016

Hi Brandon,

Yes, this is essentially the same as #944. It's on my roadmap.

Repository owner locked and limited conversation to collaborators May 18, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.