Skip to content

Instantly share code, notes, and snippets.

View keithtom's full-sized avatar

Keith Tom keithtom

View GitHub Profile
@keithtom
keithtom / post_bad.rb
Created February 14, 2013 23:21
A mini program to find published posts from a sql db. post_bad.rb doesn't use sql sanitization and is vulnerable to sql injection attacks, where a user can see unpublished posts.
require 'sqlite3'
require_relative 'post_db' # Setup db table
# Open a database
db = SQLite3::Database.new "test.db"
while true
# Get book name
puts "Find post by name:"
post_name = gets.strip