Class: Contrast::Agent::Protect::Rule::SqliBaseRule

Inherits:
Base
  • Object
show all
Includes:
Reporting::InputType, Components::Logger::InstanceMethods
Defined in:
lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb

Overview

This is the Base Rule

Direct Known Subclasses

Sqli, SqliDangerousFunctions

Constant Summary collapse

BLOCK_MESSAGE =
'SQLi rule triggered. Response blocked.'
APPLICABLE_USER_INPUTS =
[
  BODY, COOKIE_NAME, COOKIE_VALUE, HEADER,
  PARAMETER_NAME, PARAMETER_VALUE, JSON_VALUE,
  MULTIPART_VALUE, MULTIPART_FIELD_NAME,
  XML_VALUE, DWR_VALUE
].cs__freeze

Constants included from Reporting::InputType

Reporting::InputType::BODY, Reporting::InputType::COOKIE_NAME, Reporting::InputType::COOKIE_VALUE, Reporting::InputType::DWR_VALUE, Reporting::InputType::HEADER, Reporting::InputType::JSON_ARRAYED_VALUE, Reporting::InputType::JSON_VALUE, Reporting::InputType::METHOD, Reporting::InputType::MULTIPART_CONTENT_TYPE, Reporting::InputType::MULTIPART_FIELD_NAME, Reporting::InputType::MULTIPART_NAME, Reporting::InputType::MULTIPART_VALUE, Reporting::InputType::PARAMETER_NAME, Reporting::InputType::PARAMETER_VALUE, Reporting::InputType::QUERYSTRING, Reporting::InputType::REQUEST, Reporting::InputType::SOCKET, Reporting::InputType::UNDEFINED_TYPE, Reporting::InputType::UNKNOWN, Reporting::InputType::URI, Reporting::InputType::URL_PARAMETER, Reporting::InputType::XML_VALUE

Constants inherited from Base

Base::BLOCKING_MODES, Base::RULE_NAME, Base::STACK_COLLECTION_RESULTS, Base::SUSPICIOUS_REPORTING_RULES

Constants included from Filters

Filters::POSTFILTER_MODES

Instance Attribute Summary

Attributes inherited from Base

#mode

Instance Method Summary collapse

Methods included from Reporting::InputType

to_a

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Methods inherited from Base

#append_to_activity, #block_message, #cef_logging, #classification, #classify, #enabled?, #excluded?, #initialize, #rule_name, #stream_safe?, #sub_rules, #update

Methods included from Filters

#infilter?, #postfilter, #postfilter?, #prefilter, #prefilter?

Methods included from Builders

#build_attack_result, #build_attack_with_match, #build_attack_without_match, #build_base_sample, #build_sample, #build_violation

Methods included from Components::Scope::InstanceMethods

#contrast_enter_method_scopes!, #contrast_exit_method_scopes!, #with_app_scope, #with_contrast_scope, #with_deserialization_scope, #with_split_scope

Constructor Details

This class inherits a constructor from Contrast::Agent::Protect::Rule::Base

Instance Method Details

#infilter(context, database, query_string) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb', line 22

def infilter context, database, query_string
  return unless infilter?(context)

  result = find_attacker(context, query_string, database: database)
  return unless result

  append_to_activity(context, result)
  record_triggered(context)
  raise(Contrast::SecurityException.new(self, BLOCK_MESSAGE)) if blocked_violation?(result)
end