Class: Contrast::Agent::Protect::Rule::SqliDangerousFunctions

Inherits:
SqliBaseRule show all
Defined in:
lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb

Overview

This class will include the check for SQL Injection Semantic Dangerous Functions

Constant Summary collapse

NAME =
'sql-injection-semantic-dangerous-functions'
BLOCK_MESSAGE =
'SQLi Semantic Dangerous Functions rule triggered. Response blocked.'
SQL_DANGEROUS_FUNCTIONS =
%w[unhex waitfor xp_cmdshell exec].cs__freeze

Constants inherited from SqliBaseRule

Contrast::Agent::Protect::Rule::SqliBaseRule::APPLICABLE_USER_INPUTS

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, #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

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, sql_query) ⇒ Object



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

def infilter context, sql_query
  return false if protect_excluded_by_url?(rule_name)
  return unless violated?(sql_query)

  result = build_violation(context, sql_query)
  return unless result

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

#rule_nameObject



17
18
19
# File 'lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb', line 17

def rule_name
  NAME
end