Class: Sqreen::Rules::ShellEnvCB
- Inherits:
-
RegexpRuleCB
- Object
- CB
- FrameworkCB
- RuleCB
- RegexpRuleCB
- Sqreen::Rules::ShellEnvCB
- Defined in:
- lib/sqreen/rules/shell_env_cb.rb
Overview
Callback that detect nifty env in system calls
Constant Summary
Constants inherited from RuleCB
Constants included from CallCountable
CallCountable::COUNT_CALLS, CallCountable::FAILING, CallCountable::POST, CallCountable::PRE
Constants inherited from CB
Instance Attribute Summary
Attributes inherited from RuleCB
Attributes included from CallCountable
#call_count_interval, #call_counts
Attributes inherited from FrameworkCB
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
#pre(_inst, args, _budget = nil, &_block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sqreen/rules/shell_env_cb.rb', line 12 def pre(_inst, args, _budget = nil, &_block) return if args.size == 0 env = args.first return unless env.is_a?(Hash) return if env.size == 0 found = nil var, value = env.find do |_, val| next unless val.is_a?(String) found = match_regexp(val) end return unless var infos = { :variable_name => var, :variable_value => value, :found => found, } Sqreen.log.warn { "presence of a shell env tampering: #{infos.inspect}" } record_event(infos) advise_action(:raise) end |