Sha256: 805ab9c60ecd509465f884261e9313a83fd7a7f44dd1ee4560253f91cf41b607

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

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

cs__scoped_require 'contrast/components/interface'

cs__scoped_require 'zlib'
cs__scoped_require 'digest'

module Contrast
  module Agent
    module Assess
      module Rule
        # The base class for each of our Assess Rules
        class Base
          include Contrast::Components::Interface
          access_component :agent, :analysis, :logging, :settings

          def initialize
            SETTINGS.assess_rules[name] = self
          end

          # Should return the name as it is known to Teamserver; defaults to
          # class
          def name
            cs__class.name
          end

          def enabled?
            ASSESS.enabled? && !ASSESS.rule_disabled?(name)
          end

          def prefilter _context; end

          # If a rule needs to inspect the response body it is not stream safe
          # The rule should override this and return false
          def stream_safe?
            true
          end

          def postfilter _context; end

          # this rule is excluded if any of the given exclusions have a
          # protection rule that matches this rule name
          def excluded? exclusions
            Array(exclusions).any? do |ex|
              ex.assess_rule?(name)
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.13.1 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.13.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.12.2 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.12.1 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.12.0 lib/contrast/agent/assess/rule/base.rb