Permalink
Browse files

Reject access to Kernel methods

  • Loading branch information...
kinoppyd committed Jul 10, 2018
1 parent 5125b40 commit d35e1589616b50823d17c956c13e062871217168
Showing with 8 additions and 0 deletions.
  1. +8 −0 app.rb
8 app.rb
@@ -14,6 +14,14 @@ def banned_method(*_); raise SecurityError.new; end
end
refine Object do
def banned_method(*_); raise SecurityError.new; end
allowed = [:Array, :Complex, :Float, :Hash, :Integer, :Rational, :String, :block_given?, :iterator?, :catch, :raise, :gsub, :lambda, :proc, :rand, :methods]
Kernel.methods.reject { |name| allowed.include?(name.to_sym) }.each do |m|
alias_method(m, :banned_method)
end
end
refine Kernel.singleton_class do
def banned_method(*_); raise SecurityError.new; end
allowed = [:Array, :Complex, :Float, :Hash, :Integer, :Rational, :String, :block_given?, :iterator?, :catch, :raise, :gsub, :lambda, :proc, :rand]
Kernel.methods.reject { |name| allowed.include?(name.to_sym) }.each do |m|

0 comments on commit d35e158

Please sign in to comment.