Class: Sqreen::Rules::RunReqStartActions
- Inherits:
-
FrameworkCB
- Object
- CB
- FrameworkCB
- Sqreen::Rules::RunReqStartActions
- Defined in:
- lib/sqreen/rules/run_req_start_actions.rb
Overview
Runs actions concerned with whether the request ought to be served
Constant Summary collapse
- PRIORITY =
95
Constants inherited from CB
Instance Attribute Summary
Attributes inherited from FrameworkCB
Attributes inherited from CB
#klass, #method, #overtimeable
Instance Method Summary collapse
-
#initialize(framework) ⇒ RunReqStartActions
constructor
A new instance of RunReqStartActions.
- #pre(_inst, _args, _budget = nil, &_block) ⇒ Object
- #priority ⇒ Object
- #whitelisted? ⇒ Boolean
Methods inherited from FrameworkCB
Methods inherited from CB
#failing?, #framework, #overtime!, #post?, #pre?, #to_s
Constructor Details
#initialize(framework) ⇒ RunReqStartActions
Returns a new instance of RunReqStartActions.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |
Instance Method Details
#pre(_inst, _args, _budget = nil, &_block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/sqreen/rules/run_req_start_actions.rb', line 39 def priority PRIORITY end |
#whitelisted? ⇒ Boolean
33 34 35 36 37 |
# 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 |