Sha256: 5c3e1af9f184bffd24a08f3d19c83c40c6470c424f53d59ee3c914cb206411f4

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

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

require 'contrast/components/logger'

module Contrast
  module Config
    # Common Configuration settings. Those in this section pertain to the communication between the Agent & the Service
    class ServiceConfiguration
      include Contrast::Config::BaseConfiguration

      # We don't set these b/c we've been asked to handle the default values of these settings differently, logging
      # when we have to use them.
      DEFAULT_HOST       = '127.0.0.1' # rubocop:disable Style/IpAddresses
      DEFAULT_PORT       = '30555'

      attr_writer :logger, :bypass
      # @return [String, nil]
      attr_accessor :socket
      # @return [String, nil]
      attr_accessor :port
      # @return [String, nil]
      attr_accessor :host
      # @return [Boolean, nil]
      attr_accessor :enable

      def initialize hsh = {}
        return unless hsh

        @enable = hsh[:enable]
        @host = hsh[:host]
        @port = hsh[:port]
        @socket = hsh[:socket]
        @logger = Contrast::Components::Logger::Interface.new(hsh[:logger])
        @bypass = hsh[:bypass]
      end

      # @return [Contrast::Components::Logger::Interface]
      def logger
        @logger ||= Contrast::Components::Logger::Interface.new
      end

      # @return [Boolean, false]
      def bypass
        @bypass.nil? ? false : @bypass
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
contrast-agent-6.6.5 lib/contrast/config/service_configuration.rb
contrast-agent-6.6.4 lib/contrast/config/service_configuration.rb
contrast-agent-6.6.3 lib/contrast/config/service_configuration.rb
contrast-agent-6.6.2 lib/contrast/config/service_configuration.rb
contrast-agent-6.6.1 lib/contrast/config/service_configuration.rb
contrast-agent-6.6.0 lib/contrast/config/service_configuration.rb
contrast-agent-6.5.1 lib/contrast/config/service_configuration.rb
contrast-agent-6.5.0 lib/contrast/config/service_configuration.rb