Class: Contrast::Components::SecurityLogger::Interface

Inherits:
Object
  • Object
show all
Includes:
ComponentBase
Defined in:
lib/contrast/components/security_logger.rb

Overview

Here we will read and store the setting for the CEF Logging functionality

Constant Summary collapse

DEFAULT_CEF_NAME =
'security.log'
CANON_NAME =
'agent.security_logger'
CONFIG_VALUES =
%w[path level].cs__freeze

Constants included from ComponentBase

ComponentBase::ENABLE

Constants included from Contrast::Config::Diagnostics::Tools

Contrast::Config::Diagnostics::Tools::CHECK

Constants included from Contrast::Config::Diagnostics::SingletonTools

Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComponentBase

#false?, #file_exists?, #stringify_array, #true?, #valid_cert?

Methods included from Contrast::Config::Diagnostics::Tools

#add_effective_config_values, #add_single_effective_value

Methods included from Contrast::Config::Diagnostics::SingletonTools

#flatten_settings, #to_config_values, #update_config, #value_to_s

Constructor Details

#initialize(hsh = {}) ⇒ Interface

Returns a new instance of Interface.



26
27
28
29
30
31
32
33
# File 'lib/contrast/components/security_logger.rb', line 26

def initialize hsh = {}
  @config_values = CONFIG_VALUES
  @canon_name = CANON_NAME
  return unless hsh

  @path = hsh[:path]
  @level = hsh[:level]
end

Instance Attribute Details

#canon_nameString (readonly)

Returns:



22
23
24
# File 'lib/contrast/components/security_logger.rb', line 22

def canon_name
  @canon_name
end

#config_valuesArray (readonly)

Returns:

  • (Array)


24
25
26
# File 'lib/contrast/components/security_logger.rb', line 24

def config_values
  @config_values
end

#levelString?

Returns:



20
21
22
# File 'lib/contrast/components/security_logger.rb', line 20

def level
  @level
end

#pathString?

Returns:



18
19
20
# File 'lib/contrast/components/security_logger.rb', line 18

def path
  @path
end

Instance Method Details

#to_effective_config(effective_config) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/contrast/components/security_logger.rb', line 35

def to_effective_config effective_config
  path_setting = nil
  level_setting = nil

  if defined?(Contrast::SETTINGS)
    path_setting = Contrast::SETTINGS.agent_state.cef_logger_path
    level_setting = Contrast::SETTINGS.agent_state.cef_logger_level
  end

  path_setting ||= DEFAULT_CEF_NAME
  level_setting ||= Contrast::CONFIG.agent.logger.level

  add_single_effective_value(effective_config, config_values[0], path || path_setting, CANON_NAME)
  add_single_effective_value(effective_config, config_values[1], level || level_setting, CANON_NAME)
end