Module: Contrast::Agent::Reporting::BuildPreflight

Defined in:
lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb

Overview

This module will handle the building of new preflights prior to sending them.

Class Method Summary collapse

Class Method Details

.generate(finding) ⇒ Contrast::Agent::Reporting::Preflight?



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb', line 19

def generate finding
  return unless finding&.cs__is_a?(Contrast::Agent::Reporting::Finding)

  new_preflight = Contrast::Agent::Reporting::Preflight.new
  new_preflight_message = Contrast::Agent::Reporting::PreflightMessage.new
  routes = finding.routes
  unless Contrast::Utils::DuckUtils.empty_duck?(routes)
    routes.each { |route| new_preflight_message.routes << route }
  end
  new_preflight_message.data = "#{ finding.rule_id },#{ finding.hash_code }"
  new_preflight.messages << new_preflight_message
  return new_preflight unless Contrast::Utils::DuckUtils.empty_duck?(new_preflight.messages)

  nil
end