Sha256: 4111c3a497bd68752f357b1fa89e72c43686900600a368ceae137f03925150f1

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

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

require 'contrast/agent/reporting/reporting_events/application_activity'
require 'contrast/api/dtm.pb'

module Contrast
  module Agent
    module Reporting
      # Util module for checking DTM message type. It temporarily allows for the conversion from a DTM to an
      # EventReport.
      # TODO: RUBY-1438 -- remove
      module DtmMessage
        class << self
          # @param dtm [Contrast::Api::Dtm::Finding,Object]
          # @return [Boolean]
          def finding? dtm
            dtm.cs__is_a?(Contrast::Api::Dtm::Finding)
          end

          # @param dtm [Contrast::Api::Dtm::Finding,Object]
          # @return [Boolean]
          def activity? dtm
            dtm.cs__is_a?(Contrast::Api::Dtm::Activity)
          end

          # Converts DTM message to Reporting Event for those messages that have conversion methods crated. We use this
          # as we work to move away from requiring the Service.
          #
          # @param dtm [Contrast::Api::Dtm]
          # @return event [Contrast::Agent::Reporting::ReportingEvent, nil]
          def dtm_to_event dtm
            # For the others, we convert them.
            return Contrast::Agent::Reporting::Finding.convert(dtm) if finding?(dtm)
            return Contrast::Agent::Reporting::ApplicationActivity.convert(dtm) if activity?(dtm)

            nil
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contrast-agent-6.6.4 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.6.3 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.6.2 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.6.1 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.6.0 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.5.1 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.5.0 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.4.0 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
contrast-agent-6.3.0 lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb