Class: Contrast::Agent::Reporting::Settings::Syslog

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/agent/reporting/settings/syslog.rb

Overview

Controls for the syslogging feature in the agent

Constant Summary collapse

CONNECTION_TYPE =
%w[UNENCRYPTED ENCRYPTED].cs__freeze
SEVERITIES =

Used for: severity_blocked, severity_blocked_perimeter, severity_exploited, severity_probed, severity_probed_perimeter

%w[ALERT CRITICAL ERROR WARNING NOTICE INFO DEBUG].cs__freeze
SYSLOG_METHODS_NG =

Order and elements matter, the same setter must be called against same response field.

%i[
  enable= ip= port= facility= protocol= connection_type= severity_exploited= severity_blocked=
  severity_probed= severity_probed_suspicious= severity_blocked_perimeter= severity_probed_perimeter=
].cs__freeze
SYSLOG_RESPONSE_KEYS_NG =
%i[
  syslogEnabled syslogIpAddress syslogPortNumber syslogFacilityCode syslogProtocol
  syslogConnectionType syslogSeverityExploited syslogSeverityBlocked syslogSeverityProbed
  syslogSeveritySuspicious syslogSeverityBlockedPerimeter syslogSeverityProbedPerimeter
].cs__freeze
SYSLOG_METHODS =
%i[
  enable= ip= port= facility= connection_type= severity_blocked= severity_blocked_perimeter=
  severity_exploited= severity_probed= severity_probed_perimeter=
].cs__freeze
SYSLOG_RESPONSE_KEYS =
%i[
  enable ip facility connection_type severity_blocked severity_blocked_perimeter severity_exploited
  severity_probed severity_probed_perimeter
].cs__freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSyslog

Returns a new instance of Syslog.



47
48
49
50
51
52
53
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 47

def initialize
  @enable = false
  @ip = Contrast::Utils::ObjectShare::EMPTY_STRING
  @port = 0
  @facility = 0
  @blank = true
end

Instance Attribute Details

#enableObject

Returns the value of attribute enable.



37
38
39
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 37

def enable
  @enable
end

#facilityObject

Returns the value of attribute facility.



43
44
45
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 43

def facility
  @facility
end

#ipObject

Returns the value of attribute ip.



39
40
41
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 39

def ip
  @ip
end

#portObject

Returns the value of attribute port.



41
42
43
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 41

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



45
46
47
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 45

def protocol
  @protocol
end

Instance Method Details

#assign_array(settings_array, ng_: true) ⇒ Object

Parameters:

  • settings_array (Array)

    Settings retrieved from response

  • ng_ (Boolean) (defaults to: true)


162
163
164
165
166
167
168
169
170
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 162

def assign_array settings_array, ng_: true
  methods = ng_ ? SYSLOG_METHODS_NG : SYSLOG_METHODS
  response_keys = ng_ ? SYSLOG_RESPONSE_KEYS_NG : SYSLOG_RESPONSE_KEYS

  methods.each_with_index do |method, index|
    send(method, settings_array[response_keys[index]])
  end
  not_blank!
end

#connection_typeObject



70
71
72
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 70

def connection_type
  @_connection_type ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#connection_type=(type) ⇒ Object

Set the connection type

Parameters:

  • type (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



78
79
80
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 78

def connection_type= type
  @_connection_type = type if valid_entry?(type, CONNECTION_TYPE)
end

#not_blank!Boolean

Set the state of settings

Returns:

  • (Boolean)


65
66
67
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 65

def not_blank!
  @blank = false
end

#settings_blank?Boolean

check to see if object is being used

Returns:

  • (Boolean)


58
59
60
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 58

def settings_blank?
  @blank
end

#severity_blockedObject



83
84
85
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 83

def severity_blocked
  @_severity_blocked ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_blocked=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



91
92
93
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 91

def severity_blocked= severity
  @_severity_blocked = severity if valid_entry?(severity, SEVERITIES)
end

#severity_blocked_perimeterObject



96
97
98
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 96

def severity_blocked_perimeter
  @_severity_blocked_perimeter ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_blocked_perimeter=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



104
105
106
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 104

def severity_blocked_perimeter= severity
  @_severity_blocked_perimeter = severity if valid_entry?(severity, SEVERITIES)
end

#severity_exploitedObject



109
110
111
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 109

def severity_exploited
  @_severity_exploited ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_exploited=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



117
118
119
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 117

def severity_exploited= severity
  @_severity_exploited = severity if valid_entry?(severity, SEVERITIES)
end

#severity_probedObject



122
123
124
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 122

def severity_probed
  @_severity_probed ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_probed=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



130
131
132
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 130

def severity_probed= severity
  @_severity_probed = severity if valid_entry?(severity, SEVERITIES)
end

#severity_probed_perimeterObject



135
136
137
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 135

def severity_probed_perimeter
  @_severity_probed_perimeter ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_probed_perimeter=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



143
144
145
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 143

def severity_probed_perimeter= severity
  @_severity_probed_perimeter = severity if valid_entry?(severity, SEVERITIES)
end

#severity_probed_suspiciousObject



148
149
150
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 148

def severity_probed_suspicious
  @_severity_probed_suspicious ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#severity_probed_suspicious=(severity) ⇒ Object

Set the severity type

Parameters:

  • severity (String, Symbol)

    one of UNENCRYPTED, ENCRYPTED



156
157
158
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 156

def severity_probed_suspicious= severity
  @_severity_probed_suspicious = severity if valid_entry?(severity, SEVERITIES)
end

#to_controlled_hashObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/contrast/agent/reporting/settings/syslog.rb', line 172

def to_controlled_hash
  {
      syslogEnabled: enable,
      syslogIpAddress: ip,
      syslogPortNumber: port,
      syslogFacilityCode: facility,
      syslogConnectionType: connection_type,
      syslogProtocol: protocol,
      syslogSeverityExploited: severity_exploited,
      syslogSeverityBlocked: severity_blocked,
      syslogSeverityProbed: severity_probed,
      syslogSeveritySuspicious: severity_probed_suspicious,
      syslogSeverityBlockedPerimeter: severity_blocked_perimeter,
      syslogSeverityProbedPerimeter: severity_probed_perimeter
  }
end