Class: Contrast::Components::Assess::Interface
Overview
A wrapper build around the Common Agent Configuration project to allow for access of the values contained in its parent_configuration_spec.yaml. Specifically, this allows for querying the state of the Assess product.
Constant Summary
collapse
- DEFAULT_STACKTRACES =
'ALL'
- DEFAULT_MAX_SOURCE_EVENTS =
50_000
- DEFAULT_MAX_PROPAGATION_EVENTS =
50_000
- DEFAULT_MAX_RULE_REPORTED =
100
- DEFAULT_MAX_RULE_TIME_THRESHOLD =
300_000
- CANON_NAME =
'assess'
- CONFIG_VALUES =
%w[
enabled?
tags
enable_scan_response
enable_original_object
enable_dynamic_sources
enable_response_as_source
stacktraces
max_context_source_events
max_propagation_events
max_rule_reported
time_limit_threshold
].cs__freeze
ComponentBase::ENABLE
Contrast::Config::Diagnostics::Tools::CHECK
Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK
Instance Attribute Summary collapse
Instance Method Summary
collapse
#false?, #file_exists?, #stringify_array, #true?, #valid_cert?
#add_effective_config_values, #add_single_effective_value
#flatten_settings, #to_config_values, #update_config, #value_to_s
Constructor Details
#initialize(hsh = {}) ⇒ Interface
rubocop:disable Naming/MemoizedInstanceVariableName
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/contrast/components/assess.rb', line 69
def initialize hsh = {}
@config_values = CONFIG_VALUES
@canon_name = CANON_NAME
return unless hsh
@enable = hsh[:enable]
@tags = hsh[:tags]
@enable_scan_response = hsh[:enable_scan_response]
@enable_dynamic_sources = hsh[:enable_dynamic_sources]
@enable_original_object = hsh[:enable_original_object]
@enable_response_as_source = hsh[:enable_response_as_source]
@sampling = Contrast::Components::Sampling::Interface.new(hsh[:sampling])
@rules = Contrast::Components::AssessRules::Interface.new(hsh[:rules])
@stacktraces = hsh[:stacktraces]
assign_limits(hsh)
end
|
Instance Attribute Details
#canon_name ⇒ String
33
34
35
|
# File 'lib/contrast/components/assess.rb', line 33
def canon_name
@canon_name
end
|
#config_values ⇒ Array<String>
35
36
37
|
# File 'lib/contrast/components/assess.rb', line 35
def config_values
@config_values
end
|
#enable ⇒ Boolean?
19
20
21
|
# File 'lib/contrast/components/assess.rb', line 19
def enable
@enable
end
|
#enable_dynamic_sources ⇒ Boolean
92
93
94
|
# File 'lib/contrast/components/assess.rb', line 92
def enable_dynamic_sources
@enable_dynamic_sources.nil? ? true : @enable_dynamic_sources
end
|
#enable_original_object ⇒ Boolean
97
98
99
|
# File 'lib/contrast/components/assess.rb', line 97
def enable_original_object
@enable_original_object.nil? ? true : @enable_original_object
end
|
#enable_response_as_source ⇒ Boolean
102
103
104
|
# File 'lib/contrast/components/assess.rb', line 102
def enable_response_as_source
@enable_response_as_source.nil? ? false : @enable_response_as_source
end
|
#enable_scan_response ⇒ Boolean
87
88
89
|
# File 'lib/contrast/components/assess.rb', line 87
def enable_scan_response
@enable_scan_response.nil? ? true : @enable_scan_response
end
|
#max_context_source_events ⇒ Object
132
133
134
|
# File 'lib/contrast/components/assess.rb', line 132
def max_context_source_events
@max_context_source_events ||= DEFAULT_MAX_SOURCE_EVENTS
end
|
#max_propagation_events ⇒ Object
128
129
130
|
# File 'lib/contrast/components/assess.rb', line 128
def max_propagation_events
@max_propagation_events ||= DEFAULT_MAX_PROPAGATION_EVENTS
end
|
#max_rule_reported ⇒ Object
120
121
122
|
# File 'lib/contrast/components/assess.rb', line 120
def max_rule_reported
@max_rule_reported ||= DEFAULT_MAX_RULE_REPORTED
end
|
#stacktraces ⇒ Object
116
117
118
|
# File 'lib/contrast/components/assess.rb', line 116
def stacktraces
@stacktraces ||= DEFAULT_STACKTRACES
end
|
137
138
139
|
# File 'lib/contrast/components/assess.rb', line 137
def tags
stringify_array(@tags)
end
|
#time_limit_threshold ⇒ Object
Instance Method Details
#capture_stacktrace?(policy_node) ⇒ Boolean
Consider capture_stacktrace_value along with the node type to determine whether stacktraces should be captured.
capture_stacktrace_value -> (:ALL, :NONE, :SOME) node types (SourceNode, PolicyNode, TriggerNode, PropagationNode)
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/contrast/components/assess.rb', line 187
def capture_stacktrace? policy_node
return true if capture_stacktrace_value == :ALL
return false if capture_stacktrace_value == :NONE
return true if policy_node.cs__is_a?(Contrast::Agent::Assess::Policy::SourceNode)
return true if policy_node.cs__is_a?(Contrast::Agent::Assess::Policy::TriggerNode)
false
end
|
#capture_stacktrace_value ⇒ Symbol
The value of the stacktrace should be treated as an ENUM. We upcase it for faster comparisons when we use it. Anything not one of the known values of ‘NONE’, ‘SOME’, or ‘ALL’ is treated as ‘ALL’
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/contrast/components/assess.rb', line 168
def capture_stacktrace_value
@_capture_stacktrace_value ||= case stacktraces&.upcase
when 'NONE'
:NONE
when 'SOME'
:SOME
else
:ALL
end
end
|
#disabled_rules ⇒ Object
221
222
223
|
# File 'lib/contrast/components/assess.rb', line 221
def disabled_rules
rules&.disabled_rules || ::Contrast::SETTINGS.assess_state.disabled_assess_rules || []
end
|
#enabled? ⇒ Boolean
141
142
143
144
145
146
147
|
# File 'lib/contrast/components/assess.rb', line 141
def enabled?
return false if forcibly_disabled?
return true if forcibly_enabled?
::Contrast::SETTINGS.assess_state.enabled == true
end
|
#forcibly_disabled? ⇒ Boolean
153
154
155
156
157
|
# File 'lib/contrast/components/assess.rb', line 153
def forcibly_disabled?
@_forcibly_disabled = false?(enable) if @_forcibly_disabled.nil?
@_forcibly_disabled
end
|
#non_request_tracking? ⇒ Boolean
215
216
217
218
219
|
# File 'lib/contrast/components/assess.rb', line 215
def non_request_tracking?
@_non_request_tracking = true?(::Contrast::CONFIG.agent.ruby.non_request_tracking) if
@_non_request_tracking.nil?
@_non_request_tracking
end
|
#require_dynamic_sources? ⇒ Boolean
209
210
211
212
213
|
# File 'lib/contrast/components/assess.rb', line 209
def require_dynamic_sources?
return @_require_dynamic_sources unless @_require_dynamic_sources.nil?
@_require_dynamic_sources = !false?(enable_dynamic_sources)
end
|
#require_scan? ⇒ Boolean
204
205
206
207
|
# File 'lib/contrast/components/assess.rb', line 204
def require_scan?
@_require_scan = !false?(::Contrast::CONFIG.agent.ruby.require_scan) if @_require_scan.nil?
@_require_scan
end
|
#rule_disabled?(name) ⇒ Boolean
159
160
161
|
# File 'lib/contrast/components/assess.rb', line 159
def rule_disabled? name
disabled_rules.include?(name)
end
|
#scan_response? ⇒ Boolean
198
199
200
201
202
|
# File 'lib/contrast/components/assess.rb', line 198
def scan_response?
@_scan_response = !false?(enable_scan_response) if @_scan_response.nil?
@_scan_response
end
|
#session_id ⇒ Object
The id for this process, based on the session metadata or id provided by the user, as indicated in application startup.
The ID of the current application run, as returned by the application settings endpoint or set by application.session_id. If there is no session associated with this run, this field should be omitted when reporting to TS.
244
245
246
|
# File 'lib/contrast/components/assess.rb', line 244
def session_id
::Contrast::SETTINGS.assess_state.session_id
end
|
#tainted_columns ⇒ Object
149
150
151
|
# File 'lib/contrast/components/assess.rb', line 149
def tainted_columns
::Contrast::SETTINGS.tainted_columns
end
|
#to_effective_config(effective_config) ⇒ Object
Converts current configuration to effective config values class and appends them to EffectiveConfig class.
252
253
254
255
256
|
# File 'lib/contrast/components/assess.rb', line 252
def to_effective_config effective_config
super
sampling&.to_effective_config(effective_config)
rules&.to_effective_config(effective_config)
end
|
#track_original_object? ⇒ Boolean
225
226
227
228
229
|
# File 'lib/contrast/components/assess.rb', line 225
def track_original_object?
@_track_original_object = !false?(enable_original_object) if @_track_original_object.nil?
@_track_original_object
end
|
#track_response_as_source? ⇒ Boolean
231
232
233
234
235
236
|
# File 'lib/contrast/components/assess.rb', line 231
def track_response_as_source?
@track_response_as_source = !false?(enable_response_as_source) if
@track_response_as_source.nil?
@track_response_as_source
end
|