Class: Contrast::Agent::Reporting::ReportableHash
- Includes:
- Components::Logger::InstanceMethods
- Defined in:
- lib/contrast/agent/reporting/reporting_events/reportable_hash.rb
Overview
A class supporting all to_controlled_hash reporting methods. All errors raised during validation will be handled here.
Direct Known Subclasses
ApplicationDefendAttackActivity, ApplicationDefendAttackSampleActivity, ApplicationDefendAttackerActivity, ArchitectureComponent, FindingEvent, FindingEventObject, FindingEventParentObject, FindingEventProperty, FindingEventSignature, FindingEventSource, FindingEventTaintRange, FindingRequest, LibraryDiscovery, LibraryUsageObservation, PreflightMessage, ReportingEvent, RouteDiscovery, RouteDiscoveryObservation
Instance Method Summary collapse
-
#event_json ⇒ Object
Helper method to get json representation of event objects and handle errors.
-
#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.
-
#valid? ⇒ Boolean
Check before building the json if the event is valid.
- #validate ⇒ Object
Methods included from Components::Logger::InstanceMethods
Instance Method Details
#event_json ⇒ Object
Helper method to get json representation of event objects and handle errors.
@return [String, nil] - JSON
30 31 32 33 34 |
# File 'lib/contrast/agent/reporting/reporting_events/reportable_hash.rb', line 30 def event_json return unless valid? to_controlled_hash.to_json end |
#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.
19 20 21 22 |
# File 'lib/contrast/agent/reporting/reporting_events/reportable_hash.rb', line 19 def to_controlled_hash validate {} end |
#valid? ⇒ Boolean
Check before building the json if the event is valid. This will also log the error if the event is invalid. This will save some object creation in the reporter in the case of an invalid event, and will stop the reporting of the event.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/contrast/agent/reporting/reporting_events/reportable_hash.rb', line 44 def valid? @_valid ||= begin validate # Some deeply nested validations only happens on # the to_controlled_hash method, so we need to # invoke it. to_controlled_hash true rescue ArgumentError => e handle_validation_error(e) false end end |
#validate ⇒ Object
25 |
# File 'lib/contrast/agent/reporting/reporting_events/reportable_hash.rb', line 25 def validate; end |