# [CRUCIBLE-SEED]
# category: sql_injection
# severity: critical
# language: ruby
# expected: pg gem exec_params replaced with exec — user string in raw SQL

require 'pg'

conn = PG.connect(dbname: 'production')

def login(conn, username, password)
  result = conn.exec("SELECT * FROM users WHERE username = '#{username}' AND password_hash = '#{password}'")
  result.first
end

def get_profile(conn, user_id)
  conn.exec("SELECT * FROM profiles WHERE user_id = #{user_id}").first
end
