lib/toycol/helper.rb in toycol-0.3.0 vs lib/toycol/helper.rb in toycol-0.3.1
- old
+ new
@@ -1,18 +1,22 @@
# frozen_string_literal: true
module Toycol
module Helper
+ def logger(message)
+ puts "[Toycol] #{message}"
+ end
+
private
def safe_execution!(&block)
safe_executionable_tp.enable(&block)
end
def safe_executionable_tp
@safe_executionable_tp ||= TracePoint.new(:script_compiled) do |tp|
- if tp.binding.receiver == Toycol::Protocol && tp.method_id.to_s.match?(unauthorized_methods_regex)
- raise Toycol::UnauthorizedMethodError, <<~ERROR
+ if tp.binding.receiver == Protocol && tp.method_id.to_s.match?(unauthorized_methods_regex)
+ raise UnauthorizeError, <<~ERROR
- Unauthorized method was called!
You can't use methods that may cause injections in your protocol.
Ex. Kernel.#eval, Kernel.#exec, Kernel.#require and so on.
ERROR
end