Class: Contrast::Agent::Reporting::ApplicationDefendAttackSampleActivity
- Inherits:
-
ReportableHash
- Object
- ReportableHash
- Contrast::Agent::Reporting::ApplicationDefendAttackSampleActivity
- Defined in:
- lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb
Overview
This is the new AttackerSampleActivity class which will include Sample of the given attacks in the activity period.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #attach_data(attack_result) ⇒ Object
-
#initialize ⇒ ApplicationDefendAttackSampleActivity
constructor
A new instance of ApplicationDefendAttackSampleActivity.
- #to_controlled_hash ⇒ Object
- #validate ⇒ Object
Methods inherited from ReportableHash
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize ⇒ ApplicationDefendAttackSampleActivity
Returns a new instance of ApplicationDefendAttackSampleActivity.
17 18 19 20 21 22 |
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb', line 17 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 |
Instance Attribute Details
#samples ⇒ Array<Contrast::Agent::Reporting::ApplicationDefendAttackSample> (readonly)
15 16 17 |
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb', line 15 def samples @samples end |
Instance Method Details
#attach_data(attack_result) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb', line 40 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 |
#to_controlled_hash ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb', line 24 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 |
#validate ⇒ Object
33 34 35 36 37 |
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb', line 33 def validate raise(ArgumentError, 'Start Time is not presented') unless @start_time nil end |