Class: Sqreen::Rules::URLMatchesCB

Inherits:
RegexpRuleCB show all
Defined in:
lib/sqreen/rules/url_matches_cb.rb

Overview

FIXME: Tune this as Rack capable callback? If:

- we have a 404
- the path is a typical bot scanning request

Then we deny the ressource and record the attack.

Constant Summary

Constants inherited from RuleCB

RuleCB::DEFAULT_PAYLOAD

Constants included from CallCountable

CallCountable::COUNT_CALLS, CallCountable::FAILING, CallCountable::POST, CallCountable::PRE

Constants inherited from CB

CB::DEFAULT_PRIORITY

Instance Attribute Summary

Attributes inherited from RuleCB

#block, #payload_tpl, #test

Attributes included from CallCountable

#call_count_interval, #call_counts

Attributes inherited from FrameworkCB

#framework

Attributes inherited from CB

#klass, #method, #overtimeable

Instance Method Summary collapse

Methods inherited from RegexpRuleCB

#initialize, #match_regexp, #prepare

Methods inherited from RuleCB

#advise_action, #initialize, #overtime!, #priority, #record_event, #record_exception, #rule_name, #rulespack_id

Methods included from CallCountable

#count_callback_calls, #failing_with_count, #post_with_count, #pre_with_count

Methods included from Conditionable

#condition_callbacks, #failing_with_conditions, #post_with_conditions, #pre_with_conditions

Methods inherited from FrameworkCB

#record_observation, #whitelisted?

Methods inherited from CB

#failing?, #framework, #initialize, #overtime!, #post?, #pre?, #priority, #to_s, #whitelisted?

Constructor Details

This class inherits a constructor from Sqreen::Rules::RegexpRuleCB

Instance Method Details

#post(rv, _inst, args, _budget = nil, &_block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/sqreen/rules/url_matches_cb.rb', line 16

def post(rv, _inst, args, _budget = nil, &_block)
  return unless rv.is_a?(Array) && rv.size > 0 && rv[0] == 404
  env = args[0]
  path = env['SCRIPT_NAME'].to_s + env['PATH_INFO'].to_s
  found = match_regexp(path)
  infos = { :path => path, :found => found }
  record_event(infos) if found
  advise_action(nil)
end