class Sqreen::Rules::RunReqStartActions
Runs actions concerned with whether the request ought to be served
Constants
- PRIORITY
Public Class Methods
new(framework)
click to toggle source
Calls superclass method
Sqreen::CB::new
# File lib/sqreen/rules/run_req_start_actions.rb, line 18 def initialize(framework) if defined?(Sqreen::Frameworks::SinatraFramework) && framework.is_a?(Sqreen::Frameworks::SinatraFramework) super(Sqreen::SinatraMiddleware, :call) elsif defined?(Sqreen::Frameworks::RailsFramework) && framework.is_a?(Sqreen::Frameworks::RailsFramework) super(Sqreen::RailsMiddleware, :call) else # last resort; we won't get nice errors super(Sqreen::Middleware, :call) end self.framework = framework end
Public Instance Methods
pre(_inst, _args, _budget = nil, &_block)
click to toggle source
# File lib/sqreen/rules/run_req_start_actions.rb, line 43 def pre(_inst, _args, _budget = nil, &_block) return unless framework ip = framework.client_ip return unless ip actions = actions_repo.get(Sqreen::Actions::BlockIp, ip) + actions_repo.get(Sqreen::Actions::RedirectIp, ip) actions.each do |act| res = run_client_ip_action(act, ip) return res unless res.nil? end nil end
priority()
click to toggle source
# File lib/sqreen/rules/run_req_start_actions.rb, line 39 def priority PRIORITY end
whitelisted?()
click to toggle source
# File lib/sqreen/rules/run_req_start_actions.rb, line 33 def whitelisted? whitelisted = SharedStorage.get(:whitelisted) return whitelisted unless whitelisted.nil? framework && !framework.whitelisted_match.nil? end
Private Instance Methods
actions_repo()
click to toggle source
@return [Sqreen::Actions::Repository]
# File lib/sqreen/rules/run_req_start_actions.rb, line 66 def actions_repo Sqreen::Actions::Repository.current end
run_client_ip_action(action, client_ip)
click to toggle source
@param action [Sqreen::Actions::Base]
# File lib/sqreen/rules/run_req_start_actions.rb, line 61 def run_client_ip_action(action, client_ip) action.run client_ip end