Class: Contrast::Agent::Reporting::ApplicationDefendAttackSample
- Inherits:
-
Object
- Object
- Contrast::Agent::Reporting::ApplicationDefendAttackSample
show all
- Includes:
- InputType
- Defined in:
- lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb
Overview
This is the new ApplicationDefendAttackSample class which includes a samples of an attack for the given rule of the given result observed in the activity period.
Constant Summary
Constants included
from InputType
InputType::BODY, InputType::COOKIE_NAME, InputType::COOKIE_VALUE, InputType::DWR_VALUE, InputType::HEADER, InputType::JSON_ARRAYED_VALUE, InputType::JSON_VALUE, InputType::METHOD, InputType::MULTIPART_CONTENT_TYPE, InputType::MULTIPART_FIELD_NAME, InputType::MULTIPART_NAME, InputType::MULTIPART_VALUE, InputType::PARAMETER_NAME, InputType::PARAMETER_VALUE, InputType::QUERYSTRING, InputType::REQUEST, InputType::SOCKET, InputType::UNDEFINED_TYPE, InputType::UNKNOWN, InputType::URI, InputType::URL_PARAMETER, InputType::XML_VALUE
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from InputType
to_a
Constructor Details
Returns a new instance of ApplicationDefendAttackSample.
Instance Attribute Details
Details are per rule specific and should be set when the sample is build
26
27
28
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 26
def details
@details
end
|
22
23
24
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 22
def stack
@stack
end
|
#time_stamp ⇒ Integer
28
29
30
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 28
def time_stamp
@time_stamp
end
|
20
21
22
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 20
def user_input
@user_input
end
|
Class Method Details
.convert(attack_result, attack_sample) ⇒ Object
33
34
35
36
37
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 33
def convert attack_result, attack_sample
activity = new
activity.attach_data(attack_result, attack_sample)
activity
end
|
Instance Method Details
#attach_data(attack_result, attack_sample) ⇒ Object
#blocked?(response_type) ⇒ Boolean
Returns check if response type is blocked.
63
64
65
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 63
def blocked? response_type
@blocked = response_type == Contrast::Agent::Reporting::ResponseType::BLOCKED
end
|
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 68
def build_input user_input
{
documentPath: user_input.path,
documentType: user_input.document_type.to_s,
filters: user_input.matcher_ids,
name: user_input.key,
time: time_stamp,
type: user_input.input_type.to_s,
value: user_input.value
}
end
|
#build_time_stamp ⇒ Hash
92
93
94
95
96
97
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 92
def build_time_stamp
{
start: time_stamp,
elapsed: Contrast::Utils::Timer.now_ms - time_stamp
}
end
|
#to_controlled_hash ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb', line 50
def to_controlled_hash
{
blocked: @blocked,
input: build_input(@user_input),
details: @details&.to_controlled_hash,
request: @request&.to_controlled_hash,
stack: @stack&.map(&:to_controlled_hash),
timestamp: build_time_stamp
}
end
|