Sha256: 3d19f96b2a68b2419ff4ff0914dc6417e523e6ba64006b1be7bd0c34622958e0

Contents?: true

Size: 1.47 KB

Versions: 15

Compression:

Stored size: 1.47 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/agent/reporting/reporting_events/preflight_message'
require 'contrast/agent/reporting/reporting_events/preflight'
require 'contrast/agent/reporting/reporting_events/route_discovery'
require 'contrast/agent/reporting/reporting_utilities/reporting_storage'
require 'contrast/utils/duck_utils'

module Contrast
  module Agent
    module Reporting
      # This module will handle the building of new preflights prior to
      # sending them.
      module BuildPreflight
        class << self
          # @param finding [Contrast::Agent::Reporting::Finding]
          # @return [Contrast::Agent::Reporting::Preflight, nil]
          def generate finding
            return unless finding

            new_preflight = Contrast::Agent::Reporting::Preflight.new
            new_preflight_message = Contrast::Agent::Reporting::PreflightMessage.new
            finding.routes.each do |route|
              new_preflight_message.routes << route
            end
            new_preflight_message.hash_code = finding.hash_code
            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
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
contrast-agent-7.4.1 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.4.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.3.2 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.3.1 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.3.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.2.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.1.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-7.0.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.15.3 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.15.2 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.15.1 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.15.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.14.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.13.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
contrast-agent-6.12.0 lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb