class Lecter::Rack
Public Class Methods
new(app)
click to toggle source
# File lib/lecter/rack.rb, line 2 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/lecter/rack.rb, line 6 def call(env) request = Rack::Request.new(env) if request.params['lecter_analysis'] thread = Thread.current thread[:items] = '' tp = TracePoint.new(:line, :class, :call, :c_call, :return) do |tp| if tp.path && !tp.path.include?('/app/views') && !tp.path.include?('/app/helpers') && tp.path.include?(Rails.root.to_s) && tp.method_id != :method_added && tp.defined_class != Module && tp.defined_class != Class && tp.defined_class != String && tp.defined_class != Kernel && tp.defined_class != NilClass thread[:items] += [tp.path, tp.lineno, tp.defined_class, tp.method_id, tp.event].join(' ') + ';' end end tp.enable ActionController::Base.allow_forgery_protection = false end status, headers, response = @app.call(env) if tp response = [status.to_s + thread[:items]] status = 200 headers = {} end [status, headers, response] ensure if tp tp.disable ActionController::Base.allow_forgery_protection = true end end