Sha256: 14dcc36ca57f302349201692e2b344668a74b902f492e19b541f72ecfaa2ec87
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 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/utils/timer' require 'contrast/agent/reporting/reporting_events/application_defend_attack_sample' require 'contrast/agent/reporting/reporting_events/reportable_hash' module Contrast module Agent module Reporting # This is the new AttackerSampleActivity class which will include Sample of the given attacks in the activity # period. class ApplicationDefendAttackSampleActivity < Contrast::Agent::Reporting::ReportableHash # @return [Array<Contrast::Agent::Reporting::ApplicationDefendAttackSample>] attr_reader :samples def initialize @samples = [] @start_time = Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms || Contrast::Utils::Timer.now_ms @event_type = :application_defend_attack_sample_activity super() end def to_controlled_hash validate { samples: samples.map(&:to_controlled_hash), startTime: @start_time, # Start time in ms. total: 1 # there will only ever be 1 attack sample, until batching is done } end def validate raise(ArgumentError, 'Start Time is not presented') unless @start_time end # @param attack_result [Contrast::Agent::Reporting::AttackResult] def attach_data attack_result attack_result.samples.each do |attack_sample| samples << Contrast::Agent::Reporting::ApplicationDefendAttackSample.convert(attack_result, attack_sample) # If somehow this sample was found before this container was created, change the time to reflect that sample_time = attack_sample.time_stamp.to_i @start_time = sample_time if sample_time < @start_time end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-7.3.2 | lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb |