Class: Contrast::Agent::RequestContext
Overview
This class acts to encapsulate information about the currently executed request, making it available to the Agent for the duration of the request in a standardized and normalized format which the Agent understands.
Constant Summary
collapse
- INPUT_ANALYSIS =
Contrast::Agent::Reporting::InputAnalysis.new
Utils::CEFLogUtils::AGENT_VERSION, Utils::CEFLogUtils::DATE_TIME_FORMAT, Utils::CEFLogUtils::DEFAULT_CEF_NAME, Utils::CEFLogUtils::DEFAULT_LEVEL, Utils::CEFLogUtils::DEFAULT_METADATA, Utils::CEFLogUtils::EVENT_TYPE, Utils::CEFLogUtils::PROGNAME, Utils::CEFLogUtils::VALID_LEVELS
Utils::LogUtils::DATE_TIME_FORMAT, Utils::LogUtils::DEFAULT_LEVEL, Utils::LogUtils::DEFAULT_NAME, Utils::LogUtils::PROGNAME, Utils::LogUtils::STDERR_STR, Utils::LogUtils::STDOUT_STR, Utils::LogUtils::VALID_LEVELS
Utils::RequestUtils::END_PATTERN, Utils::RequestUtils::HASH_PATTERN, Utils::RequestUtils::ID_, Utils::RequestUtils::MEDIA_TYPE_MARKERS, Utils::RequestUtils::NUM_, Utils::RequestUtils::NUM_PATTERN, Utils::RequestUtils::STATIC_SUFFIXES, Utils::RequestUtils::UUID_PATTERN, Utils::RequestUtils::WIN_PATTERN
Instance Attribute Summary collapse
Instance Method Summary
collapse
#append_to_observed_route, #extract_after, #protect_input_analysis, #protect_postfilter_ia
#cef_logger, #logger
#write_permission?
#normalize_params, #read_body, #traverse_parsed_multipart
#contrast_enter_method_scopes!, #contrast_exit_method_scopes!, #with_app_scope, #with_contrast_scope, #with_deserialization_scope, #with_split_scope
Constructor Details
#initialize(rack_request, app_loaded: true) ⇒ RequestContext
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/contrast/agent/request/request_context.rb', line 50
def initialize rack_request, app_loaded: true
with_contrast_scope do
@timer = Contrast::Utils::Timer.new
@logging_hash = { request_id: __id__ }
@request = Contrast::Agent::Request.new(rack_request) if rack_request
@activity = Contrast::Agent::Reporting::ApplicationActivity.new
@do_not_track = false
@agent_input_analysis = INPUT_ANALYSIS
agent_input_analysis.request = request
@app_loaded = !!app_loaded
@_properties = {}
@propagation_event_count = 0
@source_event_count = 0
if ::Contrast::ASSESS.enabled?
@sample_req, @sample_res = Contrast::Utils::Assess::SamplingUtil.instance.sample?(@request)
end
@reported_findings = []
handle_routes
end
end
|
Instance Attribute Details
#activity ⇒ Contrast::Agent::Reporting:ApplicationActivity
29
30
31
|
# File 'lib/contrast/agent/request/request_context.rb', line 29
def activity
@activity
end
|
42
43
44
|
# File 'lib/contrast/agent/request/request_context.rb', line 42
def agent_input_analysis
@agent_input_analysis
end
|
40
41
42
|
# File 'lib/contrast/agent/request/request_context.rb', line 40
def discovered_route
@discovered_route
end
|
#logging_hash ⇒ Hash
31
32
33
|
# File 'lib/contrast/agent/request/request_context.rb', line 31
def logging_hash
@logging_hash
end
|
33
34
35
|
# File 'lib/contrast/agent/request/request_context.rb', line 33
def observed_route
@observed_route
end
|
#propagation_event_count ⇒ Object
Returns the value of attribute propagation_event_count.
48
49
50
|
# File 'lib/contrast/agent/request/request_context.rb', line 48
def propagation_event_count
@propagation_event_count
end
|
#reported_findings ⇒ Array<String>
44
45
46
|
# File 'lib/contrast/agent/request/request_context.rb', line 44
def reported_findings
@reported_findings
end
|
35
36
37
|
# File 'lib/contrast/agent/request/request_context.rb', line 35
def request
@request
end
|
38
39
40
|
# File 'lib/contrast/agent/request/request_context.rb', line 38
def response
@response
end
|
#source_event_count ⇒ Object
Returns the value of attribute source_event_count.
48
49
50
|
# File 'lib/contrast/agent/request/request_context.rb', line 48
def source_event_count
@source_event_count
end
|
46
47
48
|
# File 'lib/contrast/agent/request/request_context.rb', line 46
def timer
@timer
end
|
Instance Method Details
#add_property(key, value) ⇒ Object
119
120
121
|
# File 'lib/contrast/agent/request/request_context.rb', line 119
def add_property key, value
@_properties[key] = value
end
|
#analyze_req_res_assess? ⇒ Boolean
115
116
117
|
# File 'lib/contrast/agent/request/request_context.rb', line 115
def analyze_req_res_assess?
::Contrast::ASSESS.enabled?
end
|
#analyze_req_res_protect? ⇒ Boolean
99
100
101
|
# File 'lib/contrast/agent/request/request_context.rb', line 99
def analyze_req_res_protect?
::Contrast::PROTECT.enabled?
end
|
#analyze_request? ⇒ Boolean
91
92
93
|
# File 'lib/contrast/agent/request/request_context.rb', line 91
def analyze_request?
analyze_request_assess? || analyze_req_res_protect?
end
|
#analyze_request_assess? ⇒ Boolean
103
104
105
106
107
|
# File 'lib/contrast/agent/request/request_context.rb', line 103
def analyze_request_assess?
return false unless analyze_req_res_assess?
@sample_req
end
|
#analyze_response? ⇒ Boolean
95
96
97
|
# File 'lib/contrast/agent/request/request_context.rb', line 95
def analyze_response?
analyze_response_assess? || analyze_req_res_protect?
end
|
#analyze_response_assess? ⇒ Boolean
109
110
111
112
113
|
# File 'lib/contrast/agent/request/request_context.rb', line 109
def analyze_response_assess?
return false unless analyze_req_res_assess?
@sample_res &&= ::Contrast::ASSESS.scan_response?
end
|
#app_loaded? ⇒ Boolean
87
88
89
|
# File 'lib/contrast/agent/request/request_context.rb', line 87
def app_loaded?
@app_loaded
end
|
#get_property(key) ⇒ Object
123
124
125
|
# File 'lib/contrast/agent/request/request_context.rb', line 123
def get_property key
@_properties[key]
end
|
#reset_activity ⇒ Object
127
128
129
130
|
# File 'lib/contrast/agent/request/request_context.rb', line 127
def reset_activity
@activity = Contrast::Agent::Reporting::ApplicationActivity.new
@observed_route = Contrast::Agent::Reporting::ObservedRoute.new
end
|