Sha256: 156fef2e95acaed7c55e3d2aa512d76c89ad08564277b3227cfc9fb0f594bfbd

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

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

require 'digest'
require 'zlib'
require 'contrast/components/interface'

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

9 entries across 9 versions & 1 rubygems

Version Path
contrast-agent-4.3.2 lib/contrast/agent/assess/rule/base.rb
contrast-agent-4.3.1 lib/contrast/agent/assess/rule/base.rb
contrast-agent-4.3.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-4.2.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-4.1.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-4.0.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.16.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.15.0 lib/contrast/agent/assess/rule/base.rb
contrast-agent-3.14.0 lib/contrast/agent/assess/rule/base.rb