Sha256: a4681f61c4f31f0fc76c6194a7098d799234bafe9f6334c1b4989e0a475e477c

Contents?: true

Size: 1.76 KB

Versions: 18

Compression:

Stored size: 1.76 KB

Contents

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

require 'set'

module Contrast
  module Config
    # Common Configuration settings. Those in this section pertain to the rule mode of a single protect rule in the
    # Agent.
    class ProtectRuleConfiguration
      include Contrast::Config::BaseConfiguration

      # @return [Boolean, nil]
      attr_accessor :enable
      # @return [String, nil]
      attr_accessor :mode
      # @return [Boolean, nil]
      attr_accessor :disable_system_commands
      attr_writer :detect_custom_code_accessing_system_files

      def initialize hsh = {}
        return unless hsh

        @enable = hsh[:enable]
        @mode = hsh[:mode]
        @disable_system_commands = hsh[:disable_system_commands]
        @detect_custom_code_accessing_system_files = hsh[:detect_custom_code_accessing_system_files]
      end

      # @return [Boolean, true]
      def detect_custom_code_accessing_system_files
        @detect_custom_code_accessing_system_files.nil? ? true : @detect_custom_code_accessing_system_files
      end

      # To convert the user input mode from config to a standard format used by TS & SR, we need to convert the given
      # String to its recognized symbol equivalent. If a nonsense value is provided, it'll
      # be treated the same as disabling the rule.
      #
      # @return [Symbol, nil]
      def applicable_mode
        return unless mode

        case mode.downcase
        when 'permit'
          :PERMIT
        when 'block_at_perimeter'
          :BLOCK_AT_PERIMETER
        when 'block'
          :BLOCK
        when 'monitor'
          :MONITOR
        else
          :NO_ACTION
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.6.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.5.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.4.1 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.4.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.3.2 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.3.1 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.3.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.2.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.1.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-7.0.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.15.3 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.15.2 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.15.1 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.15.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.14.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.13.0 lib/contrast/config/protect_rule_configuration.rb
contrast-agent-6.12.0 lib/contrast/config/protect_rule_configuration.rb