Sha256: 54662a69a9ab3db8a68ade16607d56131aa12711df6757827676d7c0a82cb37b

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Agent
    module Protect
      module Rule
        # This is the Base Rule
        class SqliBaseRule < Contrast::Agent::Protect::Rule::BaseService
          include Contrast::Components::Logger::InstanceMethods
          include Contrast::Agent::Reporting::InputType

          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

          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)

            cef_logging(result, :successful_attack)
            raise(Contrast::SecurityException.new(self, BLOCK_MESSAGE)) if blocked?
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb
contrast-agent-6.10.0 lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb
contrast-agent-6.9.0 lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb
contrast-agent-6.8.0 lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb