Created
August 6, 2012 18:56
-
-
Save tsabat/3277538 to your computer and use it in GitHub Desktop.
security_manager.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'haml' | |
require 'java' | |
class JRubySecurityManager < java.lang.SecurityManager | |
def checkPermission(perm) | |
puts perm.inspect | |
#puts perm | |
end | |
#def checkWrite(f) | |
#puts f | |
#end | |
end | |
java.lang.reflect.ReflectPermission | |
i = "%pre=`ls al`" | |
require 'timeout' | |
begin | |
status = Timeout::timeout(1) { | |
begin | |
thread = Thread.new { | |
java.lang.System.setSecurityManager(JRubySecurityManager.new) | |
Thread.current[:out] = Haml::Engine.new(i).render | |
java.lang.System.setSecurityManager(nil) | |
} | |
thread.join | |
puts thread[:out] | |
rescue SecurityError => e | |
puts e | |
end | |
} | |
rescue TimeoutError => e | |
puts e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment