Class: Contrast::Agent::Reporting::FindingEventProperty

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

Overview

This is the new FindingEventProperty class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. Events have properties on them which are held as an array of key-value pairs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize(key, value) ⇒ FindingEventProperty

Returns a new instance of FindingEventProperty.



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

def initialize key, value
  @key = key
  @value = value
  super()
end

Instance Attribute Details

#keyString (readonly)

Returns the key of the property.

Returns:

  • (String)

    the key of the property



15
16
17
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_property.rb', line 15

def key
  @key
end

#valueString (readonly)

Returns the value of the source.

Returns:

  • (String)

    the value of the source



17
18
19
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_property.rb', line 17

def value
  @value
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)


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

def to_controlled_hash
  validate
  {
      key: key,
      value: value
  }
end

#validateObject

Raises:

  • (ArgumentError)


39
40
41
42
43
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_property.rb', line 39

def validate
  return unless Contrast::Utils::DuckUtils.empty_duck?(key)

  raise(ArgumentError, "#{ self } did not have a proper key. Unable to continue.")
end