Class: Contrast::Agent::Reporting::ArchitectureComponent

Inherits:
ReportableHash show all
Defined in:
lib/contrast/agent/reporting/reporting_events/architecture_component.rb

Overview

This is the new Architecture Component class which will include all the needed information for the new reporting system to relay this information in the Application Update and Application Activity messages. These components are used by TeamServer to construct the backend/ outbound connection section of the Flow Map feature.

Constant Summary collapse

AC_TYPE_DB =

TeamServer only treats these specific values as valid for Architecture Components. It does not know how to process a message with a different type.

'db'
VALID_TYPES =
%w[db ldap ws].cs__freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Instance Attribute Details

#remote_hostObject

optional attributes



19
20
21
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 19

def remote_host
  @remote_host
end

#remote_portObject

optional attributes



19
20
21
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 19

def remote_port
  @remote_port
end

#typeObject

required attributes



19
20
21
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 19

def type
  @type
end

#urlObject

required attributes



19
20
21
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 19

def url
  @url
end

#vendorObject

optional attributes



19
20
21
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 19

def vendor
  @vendor
end

Class Method Details

.build_databaseObject



31
32
33
34
35
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 31

def build_database
  msg = new
  msg.type = AC_TYPE_DB
  msg
end

Instance Method Details

#to_controlled_hashHash

Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.

Returns:

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 43

def to_controlled_hash
  validate
  {
      remoteHost: remote_host,
      remotePort: remote_port,
      type: type,
      url: url,
      vendor: vendor
  }
end

#validateObject

Ensure the required fields are present.

Raises:

  • (ArgumentError)


57
58
59
60
61
62
63
64
# File 'lib/contrast/agent/reporting/reporting_events/architecture_component.rb', line 57

def validate
  unless VALID_TYPES.include?(type)
    raise(ArgumentError, "#{ self } did not have a proper type - '#{ type }'. Unable to continue.")
  end
  raise(ArgumentError, "#{ self } did not have a proper URL. Unable to continue.") unless url

  nil
end