Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosantoniodasilva/4952387 to your computer and use it in GitHub Desktop.
Save carlosantoniodasilva/4952387 to your computer and use it in GitHub Desktop.
Test AR monkey patch of define_attribute_methods.
require 'active_record'
require 'active_record/base'
module ActiveRecord
module CVE123456
def define_attribute_methods
# ....
raise "OMG Monkey Patch!"
end
end
end
ActiveRecord::Base.extend ActiveRecord::CVE123456
# puts ActiveRecord::Base.define_attribute_methods
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define do
create_table :projects do |t|
t.string :name
t.text :description
end
end
class Project < ActiveRecord::Base
end
puts Project.new(name: "OMG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment