Class: Contrast::Agent::Reporting::PreflightMessage
- Inherits:
-
ReportableHash
- Object
- ReportableHash
- Contrast::Agent::Reporting::PreflightMessage
- Defined in:
- lib/contrast/agent/reporting/reporting_events/preflight_message.rb
Overview
This is the new PreflightMessage class which will include all the needed information for the new reporting system to report a single message, part of the main Preflight, to TeamServer. This message represents the identifying information of a Finding/Trace, which TeamServer will use to determine if it requires the full information of the Finding/Trace to be reported.
Constant Summary collapse
- CODE =
The type of this event, as understood by TeamServer. While TRACE and APPUPDATE are both technically valid, we only use the TRACE type.
:TRACE
Instance Attribute Summary collapse
-
#data ⇒ String
The message identifier; rule_id,hash.
-
#hash_code ⇒ String
CRC checksum of the finding to which this message pertains.
-
#routes ⇒ Array<Contrast::Agent::Reporting::RouteDiscovery] the route that triggered the finding to which this preflight applies.
readonly
Array<Contrast::Agent::Reporting::RouteDiscovery] the route that triggered the finding to which this preflight applies.
Instance Method Summary collapse
-
#initialize ⇒ PreflightMessage
constructor
A new instance of PreflightMessage.
-
#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.
- #validate ⇒ Object
Methods inherited from ReportableHash
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize ⇒ PreflightMessage
Returns a new instance of PreflightMessage.
28 29 30 31 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 28 def initialize @routes = [] super() end |
Instance Attribute Details
#data ⇒ String
Returns the message identifier; rule_id,hash.
17 18 19 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 17 def data @data end |
#hash_code ⇒ String
Returns CRC checksum of the finding to which this message pertains.
19 20 21 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 19 def hash_code @hash_code end |
#routes ⇒ Array<Contrast::Agent::Reporting::RouteDiscovery] the route that triggered the finding to which this preflight applies. (readonly)
Returns Array<Contrast::Agent::Reporting::RouteDiscovery] the route that triggered the finding to which this preflight applies.
22 23 24 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 22 def routes @routes 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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 38 def to_controlled_hash validate { appLanguage: Contrast::Utils::ObjectShare::RUBY, appName: ::Contrast::APP_CONTEXT.name, # rubocop:disable Security/Module/Name appPath: ::Contrast::APP_CONTEXT.name, # rubocop:disable Security/Module/Name appVersion: ::Contrast::APP_CONTEXT.version, code: CODE, data: @data || '', key: 0, session_id: ::Contrast::ASSESS.session_id, routes: @routes.map(&:to_controlled_hash) }.compact end |
#validate ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/contrast/agent/reporting/reporting_events/preflight_message.rb', line 54 def validate unless Contrast::Utils::StringUtils.present?(data) raise(ArgumentError, "#{ cs__class } did not have a proper data. Unable to continue.") end unless Contrast::APP_CONTEXT.name # rubocop:disable Security/Module/Name raise(ArgumentError, "#{ cs__class } did not have a proper Application Name. Unable to continue.") end nil end |