Skip to content

Instantly share code, notes, and snippets.

@kachick
Last active December 20, 2015 20:59
Show Gist options
  • Save kachick/6194297 to your computer and use it in GitHub Desktop.
Save kachick/6194297 to your computer and use it in GitHub Desktop.
taint with singleton_class, Class, Module
RUBY_DESCRIPTION #=> "ruby 2.1.0dev (2013-08-09 trunk 42473) [x86_64-linux]
$VERBOSE = true
obj = Object.new
mod = Module.new.taint
obj.taint.singleton_class.tainted? #=> true
obj2 = Object.new
obj2.singleton_class.taint
obj2.tainted? #=> false
obj3 = Object.new
obj3.extend mod
obj3.tainted? #=> false
obj4 = Object.new
obj4.singleton_class.__send__ :include, mod
obj4.tainted? #=> false
(mod2 = Module.new { include mod }).tainted? #=> true
Module.new { include mod2 }.tainted? #=> true
(cls = Class.new { include mod2 }).tainted? #=> true
Class.new(cls).tainted? #=> false
Class.new(Class.new.taint).tainted? #=> false
cls.new.tainted? #=> false
Class.new.taint.new.tainted? #=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment