Sha256: 6821a23e36ce5c7c634f1b3fd9a810edd3cccfc8d0e70efb41d8144ee155820d

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 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/components/logger'
require 'contrast/agent/reporting/reporting_events/application_defend_attacker_activity'

module Contrast
  module Agent
    module Reporting
      # This is the new ApplicationDefendActivity class which includes information about the defense of the application
      # which was discovered during exercise of the application during this activity period.
      class ApplicationDefendActivity
        # @return [Array<Contrast::Agent::Reporting::ApplicationDefendAttackerActivity>]
        attr_reader :attackers

        class << self
          # @param activity_dtm [Contrast::Api::Dtm::ApplicationActivity]
          # @return [Contrast::Agent::Reporting::ApplicationDefendActivity]
          def convert activity_dtm
            activity = new
            activity.attach_data activity_dtm.results
            activity
          end
        end

        def initialize
          @attackers = []
          @event_type = :application_defend_activity
          super
        end

        def to_controlled_hash
          {
              attackers: attackers.map(&:to_controlled_hash)
          }
        end

        # @param attack_dtms [Contrast::Api::Dtm::AttackResult]
        # @return [Contrast::Agent::Reporting::ApplicationDefendAttackerActivity]
        def attach_data attack_dtms
          attack_dtms.each do |attack|
            @attackers << Contrast::Agent::Reporting::ApplicationDefendAttackerActivity.convert(attack)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-6.1.0 lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb