contrast-agent 5.3.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -1
  3. data/Rakefile +1 -1
  4. data/ext/build_funchook.rb +3 -3
  5. data/ext/cs__assess_array/cs__assess_array.c +7 -0
  6. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +24 -6
  7. data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
  8. data/ext/cs__assess_hash/cs__assess_hash.c +3 -4
  9. data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -2
  10. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +26 -12
  11. data/ext/cs__assess_module/cs__assess_module.c +1 -1
  12. data/ext/cs__assess_regexp/cs__assess_regexp.c +15 -2
  13. data/ext/cs__assess_regexp/cs__assess_regexp.h +2 -0
  14. data/ext/cs__assess_string/cs__assess_string.c +21 -1
  15. data/ext/cs__assess_test/cs__assess_test.h +9 -0
  16. data/ext/cs__assess_test/cs__assess_tests.c +22 -0
  17. data/ext/cs__assess_test/extconf.rb +5 -0
  18. data/ext/cs__common/cs__common.c +113 -11
  19. data/ext/cs__common/cs__common.h +29 -5
  20. data/ext/cs__contrast_patch/cs__contrast_patch.c +55 -44
  21. data/ext/cs__os_information/cs__os_information.c +13 -10
  22. data/ext/cs__scope/cs__scope.c +146 -97
  23. data/ext/cs__tests/cs__tests.c +12 -0
  24. data/ext/cs__tests/cs__tests.h +3 -0
  25. data/ext/cs__tests/extconf.rb +5 -0
  26. data/ext/extconf_common.rb +1 -1
  27. data/lib/contrast/agent/assess/contrast_object.rb +16 -16
  28. data/lib/contrast/agent/assess/events/source_event.rb +17 -19
  29. data/lib/contrast/agent/assess/finalizers/hash.rb +4 -2
  30. data/lib/contrast/agent/assess/policy/policy.rb +9 -10
  31. data/lib/contrast/agent/assess/policy/policy_node.rb +58 -36
  32. data/lib/contrast/agent/assess/policy/policy_node_utils.rb +51 -0
  33. data/lib/contrast/agent/assess/policy/policy_scanner.rb +2 -16
  34. data/lib/contrast/agent/assess/policy/preshift.rb +8 -2
  35. data/lib/contrast/agent/assess/policy/propagation_method.rb +48 -14
  36. data/lib/contrast/agent/assess/policy/propagation_node.rb +2 -3
  37. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  38. data/lib/contrast/agent/assess/policy/propagator/buffer.rb +119 -0
  39. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
  40. data/lib/contrast/agent/assess/policy/propagator/keep.rb +19 -4
  41. data/lib/contrast/agent/assess/policy/propagator/remove.rb +18 -2
  42. data/lib/contrast/agent/assess/policy/propagator/splat.rb +17 -3
  43. data/lib/contrast/agent/assess/policy/propagator/split.rb +17 -21
  44. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +1 -1
  45. data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +1 -1
  46. data/lib/contrast/agent/assess/policy/propagator/trim.rb +2 -2
  47. data/lib/contrast/agent/assess/policy/propagator.rb +1 -0
  48. data/lib/contrast/agent/assess/policy/source_method.rb +7 -7
  49. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  50. data/lib/contrast/agent/assess/policy/trigger_method.rb +11 -17
  51. data/lib/contrast/agent/assess/policy/trigger_node.rb +16 -16
  52. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  53. data/lib/contrast/agent/assess/property/evented.rb +2 -2
  54. data/lib/contrast/agent/assess/property/tagged.rb +3 -3
  55. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +6 -8
  56. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +6 -7
  57. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +12 -7
  58. data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
  59. data/lib/contrast/agent/assess/rule/response/base_rule.rb +13 -6
  60. data/lib/contrast/agent/assess/rule/response/body_rule.rb +3 -3
  61. data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +66 -43
  62. data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +4 -4
  63. data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +6 -6
  64. data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +4 -4
  65. data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +4 -4
  66. data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
  67. data/lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb +4 -4
  68. data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +3 -4
  69. data/lib/contrast/agent/assess/tag.rb +13 -14
  70. data/lib/contrast/agent/at_exit_hook.rb +12 -1
  71. data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +0 -7
  72. data/lib/contrast/agent/deadzone/policy/policy.rb +0 -6
  73. data/lib/contrast/agent/exclusion_matcher.rb +3 -3
  74. data/lib/contrast/agent/inventory/database_config.rb +10 -3
  75. data/lib/contrast/agent/middleware.rb +10 -5
  76. data/lib/contrast/agent/patching/policy/after_load_patch.rb +3 -5
  77. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +2 -2
  78. data/lib/contrast/agent/patching/policy/method_policy_extend.rb +4 -4
  79. data/lib/contrast/agent/patching/policy/patch.rb +20 -19
  80. data/lib/contrast/agent/patching/policy/patch_status.rb +10 -3
  81. data/lib/contrast/agent/patching/policy/patcher.rb +4 -4
  82. data/lib/contrast/agent/patching/policy/policy.rb +13 -15
  83. data/lib/contrast/agent/patching/policy/policy_node.rb +32 -21
  84. data/lib/contrast/agent/patching/policy/trigger_node.rb +1 -1
  85. data/lib/contrast/agent/protect/exploitable_collection.rb +38 -0
  86. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +132 -75
  87. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +4 -3
  88. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +3 -3
  89. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
  90. data/lib/contrast/agent/protect/policy/rule_applicator.rb +4 -4
  91. data/lib/contrast/agent/protect/rule/base.rb +53 -9
  92. data/lib/contrast/agent/protect/rule/base_service.rb +31 -12
  93. data/lib/contrast/agent/protect/rule/cmd_injection.rb +23 -3
  94. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +83 -0
  95. data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +64 -0
  96. data/lib/contrast/agent/protect/rule/default_scanner.rb +2 -1
  97. data/lib/contrast/agent/protect/rule/deserialization.rb +18 -7
  98. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +96 -0
  99. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +72 -46
  100. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +231 -0
  101. data/lib/contrast/agent/protect/rule/no_sqli.rb +28 -2
  102. data/lib/contrast/agent/protect/rule/path_traversal.rb +13 -3
  103. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +18 -54
  104. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +2 -5
  105. data/lib/contrast/agent/protect/rule/sqli.rb +16 -23
  106. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +82 -0
  107. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +45 -0
  108. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +42 -0
  109. data/lib/contrast/agent/protect/rule/xss.rb +17 -0
  110. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +14 -13
  111. data/lib/contrast/agent/protect/rule/xxe.rb +25 -3
  112. data/lib/contrast/agent/reaction_processor.rb +1 -1
  113. data/lib/contrast/agent/reporting/attack_result/attack_result.rb +63 -0
  114. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +52 -0
  115. data/lib/contrast/agent/reporting/attack_result/response_type.rb +29 -0
  116. data/lib/contrast/agent/reporting/attack_result/user_input.rb +87 -0
  117. data/lib/contrast/agent/reporting/masker/masker.rb +243 -0
  118. data/lib/contrast/agent/reporting/masker/masker_utils.rb +62 -0
  119. data/lib/contrast/agent/reporting/report.rb +2 -0
  120. data/lib/contrast/agent/reporting/reporter.rb +29 -22
  121. data/lib/contrast/agent/reporting/reporter_heartbeat.rb +49 -0
  122. data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +34 -0
  123. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +51 -0
  124. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +96 -0
  125. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +70 -0
  126. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +182 -0
  127. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +56 -0
  128. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +22 -0
  129. data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +70 -0
  130. data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +13 -5
  131. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +60 -0
  132. data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +27 -0
  133. data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +44 -0
  134. data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +27 -0
  135. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +7 -12
  136. data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +1 -1
  137. data/lib/contrast/agent/reporting/reporting_events/finding.rb +10 -4
  138. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +2 -4
  139. data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +3 -3
  140. data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +5 -5
  141. data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +6 -2
  142. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +16 -12
  143. data/lib/contrast/agent/reporting/reporting_events/poll.rb +6 -2
  144. data/lib/contrast/agent/reporting/reporting_events/preflight.rb +10 -8
  145. data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +8 -11
  146. data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +2 -1
  147. data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +8 -6
  148. data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +12 -20
  149. data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +27 -0
  150. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +17 -27
  151. data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +38 -0
  152. data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +8 -0
  153. data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
  154. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -2
  155. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +29 -13
  156. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +64 -76
  157. data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
  158. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +17 -7
  159. data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +100 -0
  160. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +75 -13
  161. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +63 -0
  162. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +163 -122
  163. data/lib/contrast/agent/reporting/settings/application_settings.rb +10 -1
  164. data/lib/contrast/agent/reporting/settings/assess.rb +5 -5
  165. data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +7 -35
  166. data/lib/contrast/agent/reporting/settings/exclusions.rb +3 -3
  167. data/lib/contrast/agent/reporting/settings/protect.rb +21 -6
  168. data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +6 -6
  169. data/lib/contrast/agent/reporting/settings/reaction.rb +3 -3
  170. data/lib/contrast/agent/reporting/settings/sampling.rb +36 -0
  171. data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +110 -0
  172. data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +58 -0
  173. data/lib/contrast/agent/reporting/settings/server_features.rb +2 -2
  174. data/lib/contrast/agent/request.rb +5 -5
  175. data/lib/contrast/agent/request_context.rb +25 -21
  176. data/lib/contrast/agent/request_context_extend.rb +12 -25
  177. data/lib/contrast/agent/request_handler.rb +7 -3
  178. data/lib/contrast/agent/response.rb +2 -0
  179. data/lib/contrast/agent/rule_set.rb +2 -2
  180. data/lib/contrast/agent/scope.rb +1 -1
  181. data/lib/contrast/agent/service_heartbeat.rb +6 -48
  182. data/lib/contrast/agent/static_analysis.rb +1 -1
  183. data/lib/contrast/agent/telemetry/base.rb +155 -0
  184. data/lib/contrast/agent/telemetry/events/event.rb +35 -0
  185. data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +119 -0
  186. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +59 -0
  187. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +44 -0
  188. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +115 -0
  189. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +83 -0
  190. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +64 -0
  191. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +20 -0
  192. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions_report.rb +30 -0
  193. data/lib/contrast/agent/telemetry/events/metric_event.rb +28 -0
  194. data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +123 -0
  195. data/lib/contrast/agent/thread_watcher.rb +52 -68
  196. data/lib/contrast/agent/version.rb +1 -1
  197. data/lib/contrast/agent/worker_thread.rb +8 -0
  198. data/lib/contrast/agent.rb +4 -3
  199. data/lib/contrast/api/communication/messaging_queue.rb +29 -12
  200. data/lib/contrast/api/communication/response_processor.rb +7 -10
  201. data/lib/contrast/api/communication/service_lifecycle.rb +1 -1
  202. data/lib/contrast/api/communication/socket.rb +1 -1
  203. data/lib/contrast/api/communication/socket_client.rb +1 -1
  204. data/lib/contrast/api/communication/speedracer.rb +3 -3
  205. data/lib/contrast/api/decorators/activity.rb +33 -0
  206. data/lib/contrast/api/decorators/address.rb +1 -1
  207. data/lib/contrast/api/decorators/agent_startup.rb +10 -9
  208. data/lib/contrast/api/decorators/application_settings.rb +1 -1
  209. data/lib/contrast/api/decorators/application_startup.rb +4 -4
  210. data/lib/contrast/api/decorators/http_request.rb +1 -1
  211. data/lib/contrast/api/decorators/response_type.rb +17 -0
  212. data/lib/contrast/api/decorators.rb +1 -0
  213. data/lib/contrast/components/agent.rb +1 -1
  214. data/lib/contrast/components/app_context.rb +0 -4
  215. data/lib/contrast/components/assess.rb +14 -0
  216. data/lib/contrast/components/base.rb +1 -1
  217. data/lib/contrast/components/config.rb +19 -28
  218. data/lib/contrast/components/contrast_service.rb +13 -1
  219. data/lib/contrast/components/protect.rb +2 -2
  220. data/lib/contrast/components/sampling.rb +8 -12
  221. data/lib/contrast/components/settings.rb +151 -19
  222. data/lib/contrast/config/agent_configuration.rb +34 -41
  223. data/lib/contrast/config/api_configuration.rb +16 -75
  224. data/lib/contrast/config/api_proxy_configuration.rb +9 -48
  225. data/lib/contrast/config/application_configuration.rb +24 -95
  226. data/lib/contrast/config/assess_configuration.rb +21 -76
  227. data/lib/contrast/config/assess_rules_configuration.rb +13 -38
  228. data/lib/contrast/config/base_configuration.rb +11 -76
  229. data/lib/contrast/config/certification_configuration.rb +15 -68
  230. data/lib/contrast/config/exception_configuration.rb +15 -59
  231. data/lib/contrast/config/heap_dump_configuration.rb +19 -73
  232. data/lib/contrast/config/inventory_configuration.rb +11 -55
  233. data/lib/contrast/config/logger_configuration.rb +8 -41
  234. data/lib/contrast/config/protect_configuration.rb +23 -10
  235. data/lib/contrast/config/protect_rule_configuration.rb +23 -37
  236. data/lib/contrast/config/protect_rules_configuration.rb +39 -43
  237. data/lib/contrast/config/request_audit_configuration.rb +16 -55
  238. data/lib/contrast/config/root_configuration.rb +71 -14
  239. data/lib/contrast/config/ruby_configuration.rb +14 -47
  240. data/lib/contrast/config/sampling_configuration.rb +12 -65
  241. data/lib/contrast/config/server_configuration.rb +13 -45
  242. data/lib/contrast/config/service_configuration.rb +18 -54
  243. data/lib/contrast/configuration.rb +25 -17
  244. data/lib/contrast/extension/assess/array.rb +1 -1
  245. data/lib/contrast/extension/assess/erb.rb +1 -1
  246. data/lib/contrast/extension/assess/marshal.rb +1 -1
  247. data/lib/contrast/extension/assess/string.rb +20 -1
  248. data/lib/contrast/extension/extension.rb +2 -2
  249. data/lib/contrast/extension/module.rb +0 -1
  250. data/lib/contrast/framework/base_support.rb +8 -8
  251. data/lib/contrast/framework/grape/support.rb +3 -3
  252. data/lib/contrast/framework/manager.rb +7 -7
  253. data/lib/contrast/framework/manager_extend.rb +1 -1
  254. data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
  255. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +14 -3
  256. data/lib/contrast/framework/rails/patch/assess_configuration.rb +3 -3
  257. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
  258. data/lib/contrast/framework/rails/patch/support.rb +14 -46
  259. data/lib/contrast/framework/rails/support.rb +2 -2
  260. data/lib/contrast/framework/sinatra/support.rb +1 -1
  261. data/lib/contrast/logger/aliased_logging.rb +94 -0
  262. data/lib/contrast/logger/application.rb +1 -5
  263. data/lib/contrast/logger/cef_log.rb +15 -15
  264. data/lib/contrast/logger/format.rb +1 -1
  265. data/lib/contrast/logger/log.rb +8 -8
  266. data/lib/contrast/tasks/config.rb +100 -4
  267. data/lib/contrast/tasks/service.rb +2 -2
  268. data/lib/contrast/utils/assess/object_store.rb +36 -0
  269. data/lib/contrast/utils/assess/propagation_method_utils.rb +6 -0
  270. data/lib/contrast/utils/assess/tracking_util.rb +4 -4
  271. data/lib/contrast/utils/class_util.rb +9 -22
  272. data/lib/contrast/utils/findings.rb +3 -3
  273. data/lib/contrast/utils/hash_digest.rb +6 -7
  274. data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
  275. data/lib/contrast/utils/input_classification.rb +73 -0
  276. data/lib/contrast/utils/invalid_configuration_util.rb +2 -2
  277. data/lib/contrast/utils/log_utils.rb +7 -5
  278. data/lib/contrast/utils/lru_cache.rb +1 -1
  279. data/lib/contrast/utils/metrics_hash.rb +1 -1
  280. data/lib/contrast/utils/middleware_utils.rb +15 -14
  281. data/lib/contrast/utils/net_http_base.rb +5 -5
  282. data/lib/contrast/utils/object_share.rb +2 -1
  283. data/lib/contrast/utils/os.rb +1 -6
  284. data/lib/contrast/utils/patching/policy/patch_utils.rb +6 -7
  285. data/lib/contrast/utils/request_utils.rb +2 -2
  286. data/lib/contrast/utils/response_utils.rb +18 -33
  287. data/lib/contrast/utils/sha256_builder.rb +4 -4
  288. data/lib/contrast/utils/stack_trace_utils.rb +31 -13
  289. data/lib/contrast/utils/telemetry.rb +22 -7
  290. data/lib/contrast/utils/telemetry_client.rb +28 -16
  291. data/lib/contrast/utils/telemetry_hash.rb +41 -0
  292. data/lib/contrast/utils/telemetry_identifier.rb +18 -3
  293. data/lib/contrast/utils/timer.rb +1 -1
  294. data/lib/contrast.rb +9 -0
  295. data/resources/assess/policy.json +99 -1
  296. data/resources/deadzone/policy.json +0 -86
  297. data/ruby-agent.gemspec +10 -9
  298. data/service_executables/VERSION +1 -1
  299. data/service_executables/linux/contrast-service +0 -0
  300. data/service_executables/mac/contrast-service +0 -0
  301. metadata +99 -29
  302. data/lib/contrast/agent/metric_telemetry_event.rb +0 -26
  303. data/lib/contrast/agent/startup_metrics_telemetry_event.rb +0 -121
  304. data/lib/contrast/agent/telemetry.rb +0 -137
  305. data/lib/contrast/agent/telemetry_event.rb +0 -33
  306. data/lib/contrast/utils/exclude_key.rb +0 -20
@@ -21,8 +21,13 @@ module Contrast
21
21
 
22
22
  include Contrast::Agent::Reporting::Endpoints
23
23
  include Contrast::Agent::Reporting::ReporterClientUtils
24
- SERVICE_NAME = 'Reporter'
25
24
  include Contrast::Components::Logger::InstanceMethods
25
+ SERVICE_NAME = 'Reporter'
26
+ def initialize
27
+ @headers = Contrast::Agent::Reporting::Headers.new
28
+ super()
29
+ end
30
+
26
31
  # This method initializes the Net::HTTP client we'll need. it will validate
27
32
  # the connection and make the first request. If connection is valid and response
28
33
  # is available then the open connection is returned.
@@ -30,12 +35,7 @@ module Contrast
30
35
  # @return [Net::HTTP, nil] Return open connection or nil
31
36
  def initialize_connection
32
37
  # for this client we would use proxy and custom certificate file if available
33
- super(SERVICE_NAME, Contrast::API.api_url, true, true)
34
- end
35
-
36
- def initialize
37
- @headers = Contrast::Agent::Reporting::Headers.new
38
- super()
38
+ super(SERVICE_NAME, Contrast::API.api_url, use_proxy: true, use_custom_cert: true)
39
39
  end
40
40
 
41
41
  # Start the client for first time and sent startup event
@@ -50,20 +50,24 @@ module Contrast
50
50
 
51
51
  # Check event type and send it to appropriate TS endpoint
52
52
  #
53
- # @param event [Contrast::Api::Dtm,Contrast::Agent::Reporting::ReportingEvent] One of the DTMs valid
54
- # for the event field of Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
53
+ # @param event [Contrast::Agent::Reporting::ReportingEvent] The event to send to TeamServer. Really a
54
+ # child of the ReportingEvent rather than a literal one.
55
55
  # @param connection [Net::HTTP] open connection
56
56
  # @param send_immediately [Boolean] flag for the logger
57
57
  # @return response [Net::HTTP::Response, nil] response from TS if no response
58
- def send_event event, connection, send_immediately = false
58
+ def send_event event, connection, send_immediately: false
59
59
  return unless Contrast::Agent::Reporter.enabled?
60
60
  return unless connection
61
61
 
62
- response = send_events(event, connection)
63
- log_send_event event if send_immediately
62
+ log_send_event(event) if send_immediately
63
+ request = build_request(event)
64
+ response = connection.request(request)
65
+ audit&.audit_event(event, response) if ::Contrast::API.request_audit_enable?
66
+ process_settings_response(response)
67
+ process_preflight_response(event, response, connection)
64
68
  response
65
69
  rescue StandardError => e
66
- handle_error event, e
70
+ handle_error(event, e)
67
71
  end
68
72
 
69
73
  def status
@@ -78,6 +82,18 @@ module Contrast
78
82
  response_handler.sleep?
79
83
  end
80
84
 
85
+ def timeout
86
+ response_handler.timeout
87
+ end
88
+
89
+ def mode
90
+ response_handler.mode
91
+ end
92
+
93
+ def reset_mode
94
+ response_handler.reset_mode
95
+ end
96
+
81
97
  def wake_up
82
98
  response_handler.wake_up
83
99
  end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'contrast/components/logger'
5
5
  require 'contrast/components/scope'
6
+ require 'contrast/agent/reporting/reporting_events/application_startup'
6
7
  require 'contrast/agent/reporting/reporting_utilities/reporter_client'
7
8
  require 'contrast/agent/reporting/reporting_utilities/endpoints'
8
9
 
@@ -15,33 +16,34 @@ module Contrast
15
16
  include Contrast::Components::Scope::InstanceMethods
16
17
  include Contrast::Agent::Reporting::Endpoints
17
18
 
18
- # @param event [Contrast::Agent::Reporting::Preflight] the preflight we handle here
19
- # @param response [Net::HTTP::Response,nil] The response we handle and read from
20
- # @param connection [Net::HTTP] open connection
21
- def handle_response event, response, connection
22
- return unless event && response && connection
23
- return unless event.cs__is_a?(Contrast::Agent::Reporting::Preflight)
24
-
25
- preflight_message = event.messages[0]
26
- # for handling multiple findings
27
- # we'll only extract the indexes without *
28
- # findings_to_return = response.body.split(',').delete_if { |el| el.include?('*') }
29
- # after that we'll do some magic and return them the same way we do for corresponding_finding
30
- corresponding_finding = Contrast::Agent::Reporting::ReportingStorage.delete(preflight_message.hash_code)
31
- return unless corresponding_finding
19
+ # List the events that need to be sent when agent starts up.
20
+ # The order here matters -- DO NOT CHANGE IT!!! >_< - HM
21
+ #
22
+ # If you add more, update the test in reporter_client_spec.rb
23
+ STARTUP_EVENTS = [
24
+ Contrast::Agent::Reporting::AgentStartup,
25
+ Contrast::Agent::Reporting::ApplicationStartup
26
+ ].cs__freeze
32
27
 
33
- audit&.audit_event(corresponding_finding, response) if ::Contrast::API.request_audit_enable?
34
- send_event(corresponding_finding, connection, true)
35
- nil
36
- rescue StandardError => e
37
- logger.error('Unable to handle response', e)
28
+ def audit
29
+ @_audit ||= Contrast::Agent::Reporting::Audit.new
38
30
  end
39
31
 
40
32
  private
41
33
 
42
- # TODO: RUBY-1466 find better home for this?
43
- def audit
44
- @_audit ||= Contrast::Agent::Reporting::Audit.new
34
+ # Send Agent Startup event
35
+ #
36
+ # @param connection [Net::HTTP] open connection
37
+ def send_agent_startup connection
38
+ logger.debug('Preparing to send startup messages')
39
+
40
+ STARTUP_EVENTS.each do |event|
41
+ startup_event = event.new
42
+ send_event(startup_event, connection, send_immediately: true)
43
+ rescue StandardError => e
44
+ handle_error(startup_event, e)
45
+ end
46
+ logger.debug('Startup messages sent')
45
47
  end
46
48
 
47
49
  # This method will build headers of the request required for TS communication
@@ -66,8 +68,8 @@ module Contrast
66
68
 
67
69
  # log the event sent immediately
68
70
  #
69
- # @param event [Contrast::Api::Dtm,Contrast::Agent::Reporting::ReportingEvent] One of the DTMs valid for the
70
- # event field of Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
71
+ # @param event [Contrast::Agent::Reporting::ReportingEvent] The event to send to TeamServer. Really a
72
+ # child of the ReportingEvent rather than a literal one.
71
73
  def log_send_event event
72
74
  logger.debug("#{ Contrast::Agent::Reporting::ReporterClient::SERVICE_NAME } immediately sending event.",
73
75
  event_id: event.__id__, event_type: event.cs__class.cs__name)
@@ -75,7 +77,7 @@ module Contrast
75
77
 
76
78
  # Handles standard error case, logs and set status for failure
77
79
  #
78
- # @param event [Contrast::Api::Dtm, Contrast::Agent::Reporting::ReportingEvent]
80
+ # @param event [Contrast::Agent::Reporting::ReportingEvent]
79
81
  # One of the DTMs valid for the event field of Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
80
82
  # @param error_msg [StandardError]
81
83
  # @return nil [NilClass] to be passed as response
@@ -92,70 +94,56 @@ module Contrast
92
94
  # Handles response processing and sets status
93
95
  #
94
96
  # @param response [Net::HTTP::Response]
95
- # @return response [Net::HTTP::Response]
96
- def process_response response
97
+ def process_settings_response response
97
98
  response_handler.process(response)
98
- logger.debug('Successfully sent startup messages to service.')
99
+ logger.debug('Successfully sent startup messages to TeamServer.')
99
100
  status.success!
100
- response
101
101
  end
102
102
 
103
- # build the request headers and assign endpoint
103
+ # Given a response from preflght, when the finding hash is desired, then send the finding to which it pertains.
104
+ # The method accepts any Contrast::Agent::Reporting::ReportingEvent, but will short circuit if it is not a
105
+ # Contrast::Agent::Reporting::Preflight.
104
106
  #
105
- # @param event event [Contrast::Api::Dtm::AgentStartup, Contrast::Agent::Reporting::ReportingEvent]
106
- # One of the DTMs valid for the event field of Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
107
+ # @param event [Contrast::Agent::Reporting::ReportingEvent] The event to send to TeamServer. Really a
108
+ # child of the ReportingEvent rather than a literal one.
109
+ # @param response [Net::HTTPResponse,nil] The response we handle and read from
110
+ # @param connection [Net::HTTP] open connection
111
+ def process_preflight_response event, response, connection
112
+ return unless event.cs__is_a?(Contrast::Agent::Reporting::Preflight)
113
+ return unless response && connection
114
+
115
+ findings_to_return = response.body.split(',').delete_if { |el| el.include?('*') }
116
+ findings_to_return.each do |index|
117
+ preflight_message = event.messages[index.to_i]
118
+ corresponding_finding = Contrast::Agent::Reporting::ReportingStorage.delete(preflight_message.hash_code)
119
+ next unless corresponding_finding
120
+
121
+ send_event(corresponding_finding, connection)
122
+ end
123
+ rescue StandardError => e
124
+ logger.error('Unable to handle response', e)
125
+ end
126
+
127
+ # Convert the given event into an appropriate Net::HTTPRequest object, setting the request headers and
128
+ # assigning endpoint the endpoint appropriate for the event and casting its hash to a JSON body.
129
+ #
130
+ # @param event event [Contrast::Agent::Reporting::ReportingEvent] The event to send to TeamServer. Really a
131
+ # child of the ReportingEvent rather than a literal one.
107
132
  # @return [Net::HTTP::Post,Net::HTTP::Put]
108
133
  def build_request event
109
134
  with_contrast_scope do
110
- request = if event.cs__is_a?(Contrast::Agent::Reporting::ReportingEvent)
111
- case event.event_method
112
- when :PUT
113
- Net::HTTP::Put.new(event.event_endpoint)
114
- when :POST
115
- Net::HTTP::Post.new(event.event_endpoint)
116
- end
117
- else # TODO: RUBY-1438 -- remove
118
- Net::HTTP::Put.new(Contrast::Agent::Reporting::Endpoints::NG_ENDPOINTS[:agent_startup])
135
+ request = case event.event_method
136
+ when :PUT
137
+ Net::HTTP::Put.new(event.event_endpoint)
138
+ else # :POST
139
+ Net::HTTP::Post.new(event.event_endpoint)
119
140
  end
120
141
  build_headers(request)
121
- if event.cs__is_a?(Contrast::Agent::Reporting::ReportingEvent)
122
- event.attach_headers(request)
123
- request.body = event.to_controlled_hash.to_json
124
- else
125
- request.body = event.to_json
126
- end
142
+ event.attach_headers(request)
143
+ request.body = event.to_controlled_hash.to_json
127
144
  request
128
145
  end
129
146
  end
130
-
131
- # Send Agent Startup event
132
- #
133
- # @param connection [Net::HTTP] open connection
134
- # @return response [Net::HTTP::Response] response from TS
135
- def send_agent_startup connection
136
- logger.debug('Preparing to send startup messages')
137
- startup = Contrast::APP_CONTEXT.build_agent_startup_message
138
- request = build_request(startup)
139
- response = connection.request(request)
140
- process_response(response)
141
- rescue StandardError => e
142
- handle_error(startup, e)
143
- end
144
-
145
- # Sent different events to different endpoints
146
- #
147
- # @param event [Contrast::Api::Dtm,Contrast::Agent::Reporting::ReportingEvent] Main reporting event, all events
148
- # inherit it
149
- # @param connection [Net::HTTP] open connection
150
- def send_events event, connection
151
- request = build_request(event)
152
- response = connection.request(request)
153
- process_response(response)
154
- rescue StandardError => e
155
- handle_error(event, e)
156
- end
157
-
158
- # Eventually here we'll handle more response types and etc
159
147
  end
160
148
  end
161
149
  end
@@ -53,7 +53,7 @@ module Contrast
53
53
  end
54
54
 
55
55
  # @param rule_id [String] the rule_id
56
- # @return [Hash, nil] return array with key and value of the pair
56
+ # @return [Array, nil] return array with key and value of the pair
57
57
  def find_by_rule_id rule_id
58
58
  return unless rule_id
59
59
 
@@ -13,16 +13,26 @@ module Contrast
13
13
  # At least one, but not necessarily all, setting will differ from the agent's current set.
14
14
  # Agents are able to replace all application settings with those in this message.
15
15
  #
16
- # @return application_settings [Contrast::Agent::Reporting::Settings::ApplicationSettings]
17
- def application_settings
18
- @_application_settings ||= Contrast::Agent::Reporting::Settings::ApplicationSettings.new
19
- end
16
+ # @return [Contrast::Agent::Reporting::Settings::ApplicationSettings, nil]
17
+ attr_accessor :application_settings
20
18
 
21
19
  # All of the feature server_features
22
20
  #
23
- # @return server_features [Contrast::Agent::Reporting::Settings::FeatureSettings]
24
- def server_features
25
- @_server_features ||= Contrast::Agent::Reporting::Settings::ServerFeatures.new
21
+ # @return [Contrast::Agent::Reporting::Settings::FeatureSettings, nil]
22
+ attr_accessor :server_features
23
+
24
+ class << self
25
+ def application_response
26
+ res = new
27
+ res.application_settings = Contrast::Agent::Reporting::Settings::ApplicationSettings.new
28
+ res
29
+ end
30
+
31
+ def server_response
32
+ res = new
33
+ res.server_features = Contrast::Agent::Reporting::Settings::ServerFeatures.new
34
+ res
35
+ end
26
36
  end
27
37
  end
28
38
  end
@@ -0,0 +1,100 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ module Contrast
5
+ module Agent
6
+ module Reporting
7
+ # This module will hold the methods for TS response conversion to settings objects.
8
+ module ResponseExtractor
9
+ private
10
+
11
+ # @param response_data [Hash]
12
+ # @param res [Contrast::Agent::Reporting::Response]
13
+ def extract_assess response_data, res
14
+ assessments = response_data[:settings][:assessment]
15
+ return unless assessments
16
+
17
+ res.application_settings.assess.disabled_rules = assessments[:disabledRules]
18
+ res.application_settings.assess.session_id = assessments[:session_id]
19
+ end
20
+
21
+ # @param response_data [Hash]
22
+ # @param res [Contrast::Agent::Reporting::Response]
23
+ def extract_protect response_data, res
24
+ protect = response_data[:settings][:defend]
25
+ return unless protect
26
+
27
+ # TODO: RUBY-1636 should this be `:rules` or `:protectionRules`
28
+ res.application_settings.protect.protection_rules = protect[:protectionRules]
29
+ res.application_settings.protect.virtual_patches = protect[:virtualPatches]
30
+ end
31
+
32
+ # @param response_data [Hash]
33
+ # @param res [Contrast::Agent::Reporting::Response]
34
+ def extract_exclusions response_data, res
35
+ exclusions = response_data[:settings][:exceptions]
36
+ return unless exclusions
37
+
38
+ res.application_settings.exclusions.code_exclusions = exclusions[:codeExceptions]
39
+ res.application_settings.exclusions.input_exclusions = exclusions[:inputExceptions]
40
+ res.application_settings.exclusions.url_exclusions = exclusions[:urlExceptions]
41
+ end
42
+
43
+ # @param response_data [Hash]
44
+ # @param res [Contrast::Agent::Reporting::Response]
45
+ def extract_reactions response_data, res
46
+ res.application_settings.reactions = response_data[:settings][:reactions]
47
+ end
48
+
49
+ # @param response_data [Hash]
50
+ # @param res [Contrast::Agent::Reporting::Response]
51
+ def extract_assess_server_features response_data, res
52
+ assess = response_data[:features][:assessment]
53
+ return unless assess
54
+
55
+ res.server_features.assess.enabled = assess[:enabled]
56
+ res.server_features.assess.sampling = assess[:sampling]
57
+ res.server_features.assess.sanitizers = assess[:sanitizers]
58
+ res.server_features.assess.validators = assess[:validators]
59
+ end
60
+
61
+ # @param response_data [Hash]
62
+ # @param res [Contrast::Agent::Reporting::Response]
63
+ def extract_protect_server_features response_data, res
64
+ protect = response_data[:features][:defend]
65
+ return unless protect
66
+
67
+ res.server_features.protect.enabled = protect[:enabled]
68
+ res.server_features.protect.bot_blocker = protect[:'bot-blocker']
69
+ # TODO: RUBY-1636 should this be `:rules` or `:protectionRules`
70
+ # process the botBlockers field
71
+ res.server_features.protect.syslog = protect[:syslog]
72
+ end
73
+
74
+ # @param response_data [Hash]
75
+ # @param res [Contrast::Agent::Reporting::Response]
76
+ def extract_protect_lists response_data, res
77
+ protect = response_data[:features][:defend]
78
+ return unless protect
79
+
80
+ res.server_features.protect.ip_allowlist = protect[:ipAllowlist]
81
+ res.server_features.protect.ip_denylist = protect[:ipDenyList]
82
+ res.server_features.protect.log_enchancers = protect[:logEnhancers]
83
+ res.server_features.protect.rule_definition_list = protect[:ruleDefinitionList]
84
+ end
85
+
86
+ # Here we extract the rules and state for the sensitive data masking policy
87
+ # Received from TS.
88
+ #
89
+ # @param response_data [Hash]
90
+ # @param res [Contrast::Agent::Reporting::Response]
91
+ def extract_sensitive_data_policy response_data, res
92
+ sensitive_data = response_data[:settings][:sensitive_data_masking_policy]
93
+ res.application_settings.sensitive_data_masking.mask_http_body = sensitive_data[:mask_http_body]
94
+ res.application_settings.sensitive_data_masking.mask_attack_vector = sensitive_data[:mask_attack_vector]
95
+ res.application_settings.sensitive_data_masking.build_rules_form_settings(sensitive_data[:rules])
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -5,6 +5,7 @@ require 'contrast/api/communication/response_processor'
5
5
  require 'contrast/api/decorators/application_settings'
6
6
  require 'contrast/agent/reporting/reporting_utilities/response'
7
7
  require 'contrast/agent/reporting/reporting_utilities/response_handler_utils'
8
+ require 'contrast/agent/reporting/reporting_utilities/response_handler_mode'
8
9
  require 'contrast/api/decorators/server_features'
9
10
  require 'contrast/components/logger'
10
11
  require 'json'
@@ -13,44 +14,105 @@ module Contrast
13
14
  module Agent
14
15
  module Reporting
15
16
  # This class will facilitate the Response capture and analysis functionality.
16
- class ResponseHandler < Contrast::Api::Communication::ResponseProcessor
17
+ class ResponseHandler
17
18
  include Contrast::Components::Logger::InstanceMethods
18
19
  include Contrast::Agent::Reporting::ResponseHandlerUtils
20
+ # 15 min
21
+ TIMEOUT = 900.cs__freeze
22
+
19
23
  # Process the response from TS
20
24
  #
21
25
  # @param response [Net::HTTP::Response, nil]
22
26
  # @return response [Net::HTTP::Response, nil]
23
27
  def process response
24
28
  logger.debug('Reporter Received a response')
25
- return unless analyze_response_code? response&.code
26
-
27
- # handle the response body and obtain server_features or app_settings
28
- report_response = convert_response response
29
+ return unless analyze_response?(response)
29
30
 
31
+ # Handle the response body and obtain server_features or app_settings
32
+ report_response = convert_response(response)
30
33
  return unless report_response
31
34
 
32
- update_agent_settings report_response
33
- update_reaction report_response
34
- # this one is called from super needs to be placed here after protobuf
35
- update_features report_response.server_features, report_response.application_settings
36
- logger.trace('Agent settings updated in response to Service', protect_on: ::Contrast::PROTECT.enabled?,
37
- assess_on: ::Contrast::ASSESS.enabled?)
35
+ # Update Server Features and Application Settings to provide current agent settings
36
+ update_agent_settings(report_response)
37
+ # Process any reactions, including message logging and shutting down
38
+ update_reaction(report_response)
39
+ update_ruleset(report_response)
40
+ logger.trace('Agent settings updated in response to TeamServer', protect_on: ::Contrast::PROTECT.enabled?,
41
+ assess_on: ::Contrast::ASSESS.enabled?)
38
42
  response
39
43
  rescue StandardError => e
40
44
  logger.error('Unable to process response from TeamServer', e)
41
45
  nil
42
46
  end
43
47
 
44
- # if sleep is true puts reporting service to sleep
48
+ # If sleep is true puts reporting service to sleep.
45
49
  def sleep?
46
50
  @_sleep = wake_up if @_sleep.nil?
47
51
  @_sleep
48
52
  end
49
53
 
50
- # wakes the reporting service
54
+ # For how long the agent should wait until retry
55
+ # to send message
56
+ #
57
+ # @return timeout [Integer] the time for reporter
58
+ # to be suspended.
59
+ def timeout
60
+ @_timeout ||= TIMEOUT
61
+ end
62
+
63
+ def mode
64
+ @_mode ||= Contrast::Agent::Reporting::ResponseHandlerMode.new
65
+ end
66
+
67
+ # Wakes the reporting service
51
68
  def wake_up
52
69
  @_sleep = false
53
70
  end
71
+
72
+ private
73
+
74
+ # Handles the errors code received from TS and takes appropriate action.
75
+ # If we are here the response.code is an error that needs handling [4XX]
76
+ #
77
+ # @param response [Net::HTTP::Response]
78
+ def handle_error response
79
+ case response&.code
80
+ when ERROR_CODES[:message_not_sent]
81
+ handle_response_errors(response, UNSUCCESSFULLY_RECEIVED_MSG, mode.running)
82
+ when ERROR_CODES[:access_forbidden]
83
+ handle_response_errors(response, FORBIDDEN_MSG, mode.running)
84
+ when ERROR_CODES[:access_forbidden_no_action]
85
+ handle_response_errors(response, FORBIDDEN_NO_ACTION_MSG, mode.running)
86
+ when ERROR_CODES[:application_do_not_exist]
87
+ handle_response_errors(response, APP_NON_EXISTENT_MSG, mode.disabled)
88
+ when ERROR_CODES[:unprocessable_entity]
89
+ handle_response_errors(response, UNPROCESSABLE_ENTITY_MSG, mode.disabled)
90
+ when ERROR_CODES[:too_many_requests]
91
+ handle_response_errors(response, RETRY_AFTER_MSG, mode.resending)
92
+ else
93
+ logger.debug('Response Error code could not be processed')
94
+ end
95
+ end
96
+
97
+ # Suspend the reporter and try again in time. If not set
98
+ # the timeout is set to 15 min As default:
99
+ #
100
+ # @param message [String] Message to log.
101
+ # @param timeout [Integer,nil] The timeout to wait and retry after.
102
+ # @param error_message [String, nil] Error message if any received.
103
+ def suspend_reporting message, timeout, error_message
104
+ @_timeout = timeout || Contrast::Agent::Reporting::ResponseHandler::TIMEOUT
105
+ log_debug_msg(message, timeout: @_timeout, error_message: error_message || 'none')
106
+ @_sleep = true
107
+ end
108
+
109
+ # Log what we've received.
110
+ #
111
+ # @param message [String] Message to log
112
+ # @param info_hash [Hash] information about the context to log.
113
+ def log_debug_msg message, info_hash
114
+ logger.debug(message, info_hash)
115
+ end
54
116
  end
55
117
  end
56
118
  end
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ module Contrast
5
+ module Agent
6
+ module Reporting
7
+ # This class will hold the mode state in which the reporter will send
8
+ # event ot TS.
9
+ class ResponseHandlerMode
10
+ # Reader for the running mode type.
11
+ #
12
+ # @return [Symbol] Reporter's client and Response Handler are running
13
+ # and responses are being processed.
14
+ attr_reader :running
15
+ # Reader for the disabled mode type.
16
+ #
17
+ # @return [Symbol] Reporter's client and Response Handler are disabled
18
+ # due to received Error. The Reporting is disabled for this application.
19
+ attr_reader :disabled
20
+ # Reader for the resending/retry mode type.
21
+ #
22
+ # @return [Symbol] Reporter's client and Response Handler are suspended
23
+ # for a TS received amount of time and will try to resend the previous
24
+ # request after that.
25
+ attr_reader :resending
26
+ # Reader for all supported modes.
27
+ #
28
+ # @return [Array<Symbol>] Reporter's client and Response Handler all
29
+ # available modes of operation.
30
+ attr_reader :modes
31
+
32
+ def initialize
33
+ @running = :running
34
+ @disabled = :disabled
35
+ @resending = :resending
36
+ @modes = [@running, @disabled, @resending].cs__freeze
37
+ end
38
+
39
+ # Current mode.
40
+ #
41
+ # @return [Symbol] Reporter's client and Response Handler
42
+ # current mode of operation.
43
+ def status
44
+ @_status ||= running
45
+ end
46
+
47
+ # Set current mode.
48
+ #
49
+ # @return [Symbol] Reporter's client and Response Handler
50
+ # current mode of operation.
51
+ def status= mode
52
+ @_status = mode if mode.cs__is_a?(Symbol) && modes.include?(mode)
53
+ end
54
+
55
+ # Reset mode
56
+ #
57
+ def reset_mode
58
+ @_status = running
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end