Class: Contrast::Agent::Reporting::FindingEventSource
- Inherits:
-
ReportableHash
- Object
- ReportableHash
- Contrast::Agent::Reporting::FindingEventSource
- Defined in:
- lib/contrast/agent/reporting/reporting_events/finding_event_source.rb
Overview
This is the new FindingEventSource class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. These FindingEventSource are used by TeamServer to construct the vulnerability information for the assess feature. They indicate the type of data that the event represents.
Instance Attribute Summary collapse
-
#source_name ⇒ String
readonly
The name of the source.
-
#source_type ⇒ String
readonly
The type of the source.
Instance Method Summary collapse
-
#initialize(type, name) ⇒ FindingEventSource
constructor
A new instance of FindingEventSource.
-
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
-
#to_controlled_observation_hash ⇒ Hash
Convert this EventSource into the format expected for route observation.
- #validate ⇒ Object
Methods inherited from ReportableHash
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize(type, name) ⇒ FindingEventSource
Returns a new instance of FindingEventSource.
23 24 25 26 27 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 23 def initialize type, name @source_type = type @source_name = name super() end |
Instance Attribute Details
#source_name ⇒ String (readonly)
Returns the name of the source.
17 18 19 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 17 def source_name @source_name end |
#source_type ⇒ String (readonly)
Returns the type of the source.
19 20 21 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 19 def source_type @source_type end |
Instance Method Details
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
34 35 36 37 38 39 40 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 34 def to_controlled_hash validate { sourceName: source_name, sourceType: source_type } end |
#to_controlled_observation_hash ⇒ Hash
Convert this EventSource into the format expected for route observation
46 47 48 49 50 51 52 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 46 def to_controlled_observation_hash validate { name: source_name, type: source_type } end |
#validate ⇒ Object
55 56 57 58 59 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_source.rb', line 55 def validate return unless Contrast::Utils::DuckUtils.empty_duck?(source_type) raise(ArgumentError, "#{ self } did not have a proper type. Unable to continue.") end |