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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrast-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - galen.palmer@contrastsecurity.com
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2022-03-03 00:00:00.000000000 Z
16
+ date: 2022-05-12 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -161,42 +161,42 @@ dependencies:
161
161
  requirements:
162
162
  - - '='
163
163
  - !ruby/object:Gem::Version
164
- version: 1.22.3
164
+ version: 1.26.1
165
165
  type: :development
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - '='
170
170
  - !ruby/object:Gem::Version
171
- version: 1.22.3
171
+ version: 1.26.1
172
172
  - !ruby/object:Gem::Dependency
173
173
  name: rubocop-performance
174
174
  requirement: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - '='
177
177
  - !ruby/object:Gem::Version
178
- version: 1.12.0
178
+ version: 1.13.3
179
179
  type: :development
180
180
  prerelease: false
181
181
  version_requirements: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - '='
184
184
  - !ruby/object:Gem::Version
185
- version: 1.12.0
185
+ version: 1.13.3
186
186
  - !ruby/object:Gem::Dependency
187
187
  name: rubocop-rails
188
188
  requirement: !ruby/object:Gem::Requirement
189
189
  requirements:
190
190
  - - '='
191
191
  - !ruby/object:Gem::Version
192
- version: 2.12.4
192
+ version: 2.14.2
193
193
  type: :development
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
196
196
  requirements:
197
197
  - - '='
198
198
  - !ruby/object:Gem::Version
199
- version: 2.12.4
199
+ version: 2.14.2
200
200
  - !ruby/object:Gem::Dependency
201
201
  name: rubocop-rake
202
202
  requirement: !ruby/object:Gem::Requirement
@@ -217,14 +217,14 @@ dependencies:
217
217
  requirements:
218
218
  - - '='
219
219
  - !ruby/object:Gem::Version
220
- version: 2.6.0
220
+ version: 2.9.0
221
221
  type: :development
222
222
  prerelease: false
223
223
  version_requirements: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - '='
226
226
  - !ruby/object:Gem::Version
227
- version: 2.6.0
227
+ version: 2.9.0
228
228
  - !ruby/object:Gem::Dependency
229
229
  name: simplecov
230
230
  requirement: !ruby/object:Gem::Requirement
@@ -277,16 +277,16 @@ dependencies:
277
277
  name: rails
278
278
  requirement: !ruby/object:Gem::Requirement
279
279
  requirements:
280
- - - '='
280
+ - - "~>"
281
281
  - !ruby/object:Gem::Version
282
- version: 6.0.3.5
282
+ version: '7'
283
283
  type: :development
284
284
  prerelease: false
285
285
  version_requirements: !ruby/object:Gem::Requirement
286
286
  requirements:
287
- - - '='
287
+ - - "~>"
288
288
  - !ruby/object:Gem::Version
289
- version: 6.0.3.5
289
+ version: '7'
290
290
  - !ruby/object:Gem::Dependency
291
291
  name: sinatra
292
292
  requirement: !ruby/object:Gem::Requirement
@@ -399,6 +399,20 @@ dependencies:
399
399
  - - ">="
400
400
  - !ruby/object:Gem::Version
401
401
  version: '0'
402
+ - !ruby/object:Gem::Dependency
403
+ name: benchmark-memory
404
+ requirement: !ruby/object:Gem::Requirement
405
+ requirements:
406
+ - - "~>"
407
+ - !ruby/object:Gem::Version
408
+ version: '0.1'
409
+ type: :development
410
+ prerelease: false
411
+ version_requirements: !ruby/object:Gem::Requirement
412
+ requirements:
413
+ - - "~>"
414
+ - !ruby/object:Gem::Version
415
+ version: '0.1'
402
416
  - !ruby/object:Gem::Dependency
403
417
  name: climate_control
404
418
  requirement: !ruby/object:Gem::Requirement
@@ -617,20 +631,22 @@ executables:
617
631
  - contrast_service
618
632
  extensions:
619
633
  - ext/cs__common/extconf.rb
620
- - ext/cs__os_information/extconf.rb
621
- - ext/cs__assess_basic_object/extconf.rb
634
+ - ext/cs__assess_marshal_module/extconf.rb
622
635
  - ext/cs__assess_kernel/extconf.rb
623
- - ext/cs__assess_hash/extconf.rb
624
- - ext/cs__assess_yield_track/extconf.rb
625
- - ext/cs__assess_fiber_track/extconf.rb
626
- - ext/cs__assess_regexp/extconf.rb
627
636
  - ext/cs__assess_string/extconf.rb
637
+ - ext/cs__assess_test/extconf.rb
638
+ - ext/cs__assess_string_interpolation26/extconf.rb
639
+ - ext/cs__assess_basic_object/extconf.rb
628
640
  - ext/cs__assess_array/extconf.rb
641
+ - ext/cs__assess_regexp/extconf.rb
629
642
  - ext/cs__contrast_patch/extconf.rb
643
+ - ext/cs__assess_hash/extconf.rb
630
644
  - ext/cs__scope/extconf.rb
631
- - ext/cs__assess_string_interpolation26/extconf.rb
645
+ - ext/cs__assess_fiber_track/extconf.rb
632
646
  - ext/cs__assess_module/extconf.rb
633
- - ext/cs__assess_marshal_module/extconf.rb
647
+ - ext/cs__os_information/extconf.rb
648
+ - ext/cs__tests/extconf.rb
649
+ - ext/cs__assess_yield_track/extconf.rb
634
650
  extra_rdoc_files: []
635
651
  files:
636
652
  - ".clang-format"
@@ -676,6 +692,9 @@ files:
676
692
  - ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
677
693
  - ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.h
678
694
  - ext/cs__assess_string_interpolation26/extconf.rb
695
+ - ext/cs__assess_test/cs__assess_test.h
696
+ - ext/cs__assess_test/cs__assess_tests.c
697
+ - ext/cs__assess_test/extconf.rb
679
698
  - ext/cs__assess_yield_track/cs__assess_yield_track.c
680
699
  - ext/cs__assess_yield_track/cs__assess_yield_track.h
681
700
  - ext/cs__assess_yield_track/extconf.rb
@@ -691,6 +710,9 @@ files:
691
710
  - ext/cs__scope/cs__scope.c
692
711
  - ext/cs__scope/cs__scope.h
693
712
  - ext/cs__scope/extconf.rb
713
+ - ext/cs__tests/cs__tests.c
714
+ - ext/cs__tests/cs__tests.h
715
+ - ext/cs__tests/extconf.rb
694
716
  - ext/extconf_common.rb
695
717
  - funchook/LICENSE
696
718
  - funchook/Makefile.in
@@ -838,6 +860,7 @@ files:
838
860
  - lib/contrast/agent/assess/policy/patcher.rb
839
861
  - lib/contrast/agent/assess/policy/policy.rb
840
862
  - lib/contrast/agent/assess/policy/policy_node.rb
863
+ - lib/contrast/agent/assess/policy/policy_node_utils.rb
841
864
  - lib/contrast/agent/assess/policy/policy_scanner.rb
842
865
  - lib/contrast/agent/assess/policy/preshift.rb
843
866
  - lib/contrast/agent/assess/policy/propagation_method.rb
@@ -845,6 +868,7 @@ files:
845
868
  - lib/contrast/agent/assess/policy/propagator.rb
846
869
  - lib/contrast/agent/assess/policy/propagator/append.rb
847
870
  - lib/contrast/agent/assess/policy/propagator/base.rb
871
+ - lib/contrast/agent/assess/policy/propagator/buffer.rb
848
872
  - lib/contrast/agent/assess/policy/propagator/center.rb
849
873
  - lib/contrast/agent/assess/policy/propagator/custom.rb
850
874
  - lib/contrast/agent/assess/policy/propagator/database_write.rb
@@ -911,7 +935,6 @@ files:
911
935
  - lib/contrast/agent/inventory/policy/datastores.rb
912
936
  - lib/contrast/agent/inventory/policy/policy.rb
913
937
  - lib/contrast/agent/inventory/policy/trigger_node.rb
914
- - lib/contrast/agent/metric_telemetry_event.rb
915
938
  - lib/contrast/agent/middleware.rb
916
939
  - lib/contrast/agent/module_data.rb
917
940
  - lib/contrast/agent/patching/policy/after_load_patch.rb
@@ -925,6 +948,7 @@ files:
925
948
  - lib/contrast/agent/patching/policy/policy.rb
926
949
  - lib/contrast/agent/patching/policy/policy_node.rb
927
950
  - lib/contrast/agent/patching/policy/trigger_node.rb
951
+ - lib/contrast/agent/protect/exploitable_collection.rb
928
952
  - lib/contrast/agent/protect/input_analyzer/input_analyzer.rb
929
953
  - lib/contrast/agent/protect/policy/applies_command_injection_rule.rb
930
954
  - lib/contrast/agent/protect/policy/applies_deserialization_rule.rb
@@ -939,11 +963,15 @@ files:
939
963
  - lib/contrast/agent/protect/rule/base.rb
940
964
  - lib/contrast/agent/protect/rule/base_service.rb
941
965
  - lib/contrast/agent/protect/rule/cmd_injection.rb
966
+ - lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb
967
+ - lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb
942
968
  - lib/contrast/agent/protect/rule/default_scanner.rb
943
969
  - lib/contrast/agent/protect/rule/deserialization.rb
944
970
  - lib/contrast/agent/protect/rule/http_method_tampering.rb
971
+ - lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb
945
972
  - lib/contrast/agent/protect/rule/no_sqli.rb
946
973
  - lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb
974
+ - lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb
947
975
  - lib/contrast/agent/protect/rule/path_traversal.rb
948
976
  - lib/contrast/agent/protect/rule/sql_sample_builder.rb
949
977
  - lib/contrast/agent/protect/rule/sqli.rb
@@ -954,17 +982,38 @@ files:
954
982
  - lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb
955
983
  - lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb
956
984
  - lib/contrast/agent/protect/rule/unsafe_file_upload.rb
985
+ - lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb
986
+ - lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb
957
987
  - lib/contrast/agent/protect/rule/xss.rb
958
988
  - lib/contrast/agent/protect/rule/xxe.rb
959
989
  - lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb
960
990
  - lib/contrast/agent/reaction_processor.rb
991
+ - lib/contrast/agent/reporting/attack_result/attack_result.rb
992
+ - lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb
993
+ - lib/contrast/agent/reporting/attack_result/response_type.rb
994
+ - lib/contrast/agent/reporting/attack_result/user_input.rb
961
995
  - lib/contrast/agent/reporting/input_analysis/input_analysis.rb
962
996
  - lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb
963
997
  - lib/contrast/agent/reporting/input_analysis/input_type.rb
964
998
  - lib/contrast/agent/reporting/input_analysis/score_level.rb
999
+ - lib/contrast/agent/reporting/masker/masker.rb
1000
+ - lib/contrast/agent/reporting/masker/masker_utils.rb
965
1001
  - lib/contrast/agent/reporting/report.rb
966
1002
  - lib/contrast/agent/reporting/reporter.rb
1003
+ - lib/contrast/agent/reporting/reporter_heartbeat.rb
1004
+ - lib/contrast/agent/reporting/reporting_events/agent_startup.rb
1005
+ - lib/contrast/agent/reporting/reporting_events/application_activity.rb
1006
+ - lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb
1007
+ - lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb
1008
+ - lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb
1009
+ - lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb
1010
+ - lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb
1011
+ - lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb
967
1012
  - lib/contrast/agent/reporting/reporting_events/application_inventory.rb
1013
+ - lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb
1014
+ - lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb
1015
+ - lib/contrast/agent/reporting/reporting_events/application_startup.rb
1016
+ - lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb
968
1017
  - lib/contrast/agent/reporting/reporting_events/application_update.rb
969
1018
  - lib/contrast/agent/reporting/reporting_events/architecture_component.rb
970
1019
  - lib/contrast/agent/reporting/reporting_events/discovered_route.rb
@@ -990,8 +1039,10 @@ files:
990
1039
  - lib/contrast/agent/reporting/reporting_events/route_discovery.rb
991
1040
  - lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb
992
1041
  - lib/contrast/agent/reporting/reporting_events/server_activity.rb
1042
+ - lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb
993
1043
  - lib/contrast/agent/reporting/reporting_events/trace_event_source.rb
994
1044
  - lib/contrast/agent/reporting/reporting_utilities/audit.rb
1045
+ - lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb
995
1046
  - lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb
996
1047
  - lib/contrast/agent/reporting/reporting_utilities/endpoints.rb
997
1048
  - lib/contrast/agent/reporting/reporting_utilities/headers.rb
@@ -999,7 +1050,9 @@ files:
999
1050
  - lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb
1000
1051
  - lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb
1001
1052
  - lib/contrast/agent/reporting/reporting_utilities/response.rb
1053
+ - lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb
1002
1054
  - lib/contrast/agent/reporting/reporting_utilities/response_handler.rb
1055
+ - lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb
1003
1056
  - lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb
1004
1057
  - lib/contrast/agent/reporting/settings/application_settings.rb
1005
1058
  - lib/contrast/agent/reporting/settings/assess.rb
@@ -1008,6 +1061,9 @@ files:
1008
1061
  - lib/contrast/agent/reporting/settings/protect.rb
1009
1062
  - lib/contrast/agent/reporting/settings/protect_server_feature.rb
1010
1063
  - lib/contrast/agent/reporting/settings/reaction.rb
1064
+ - lib/contrast/agent/reporting/settings/sampling.rb
1065
+ - lib/contrast/agent/reporting/settings/sensitive_data_masking.rb
1066
+ - lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb
1011
1067
  - lib/contrast/agent/reporting/settings/server_features.rb
1012
1068
  - lib/contrast/agent/request.rb
1013
1069
  - lib/contrast/agent/request_context.rb
@@ -1017,10 +1073,19 @@ files:
1017
1073
  - lib/contrast/agent/rule_set.rb
1018
1074
  - lib/contrast/agent/scope.rb
1019
1075
  - lib/contrast/agent/service_heartbeat.rb
1020
- - lib/contrast/agent/startup_metrics_telemetry_event.rb
1021
1076
  - lib/contrast/agent/static_analysis.rb
1022
- - lib/contrast/agent/telemetry.rb
1023
- - lib/contrast/agent/telemetry_event.rb
1077
+ - lib/contrast/agent/telemetry/base.rb
1078
+ - lib/contrast/agent/telemetry/events/event.rb
1079
+ - lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb
1080
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb
1081
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb
1082
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb
1083
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb
1084
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb
1085
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb
1086
+ - lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions_report.rb
1087
+ - lib/contrast/agent/telemetry/events/metric_event.rb
1088
+ - lib/contrast/agent/telemetry/events/startup_metrics_event.rb
1024
1089
  - lib/contrast/agent/thread.rb
1025
1090
  - lib/contrast/agent/thread_watcher.rb
1026
1091
  - lib/contrast/agent/tracepoint_hook.rb
@@ -1039,6 +1104,7 @@ files:
1039
1104
  - lib/contrast/api/communication/tcp_socket.rb
1040
1105
  - lib/contrast/api/communication/unix_socket.rb
1041
1106
  - lib/contrast/api/decorators.rb
1107
+ - lib/contrast/api/decorators/activity.rb
1042
1108
  - lib/contrast/api/decorators/address.rb
1043
1109
  - lib/contrast/api/decorators/agent_startup.rb
1044
1110
  - lib/contrast/api/decorators/application_settings.rb
@@ -1055,6 +1121,7 @@ files:
1055
1121
  - lib/contrast/api/decorators/library_usage_update.rb
1056
1122
  - lib/contrast/api/decorators/message.rb
1057
1123
  - lib/contrast/api/decorators/rasp_rule_sample.rb
1124
+ - lib/contrast/api/decorators/response_type.rb
1058
1125
  - lib/contrast/api/decorators/route_coverage.rb
1059
1126
  - lib/contrast/api/decorators/server_features.rb
1060
1127
  - lib/contrast/api/decorators/trace_event.rb
@@ -1139,6 +1206,7 @@ files:
1139
1206
  - lib/contrast/framework/rails/support.rb
1140
1207
  - lib/contrast/framework/sinatra/support.rb
1141
1208
  - lib/contrast/funchook/funchook.rb
1209
+ - lib/contrast/logger/aliased_logging.rb
1142
1210
  - lib/contrast/logger/application.rb
1143
1211
  - lib/contrast/logger/cef_log.rb
1144
1212
  - lib/contrast/logger/format.rb
@@ -1148,6 +1216,7 @@ files:
1148
1216
  - lib/contrast/security_exception.rb
1149
1217
  - lib/contrast/tasks/config.rb
1150
1218
  - lib/contrast/tasks/service.rb
1219
+ - lib/contrast/utils/assess/object_store.rb
1151
1220
  - lib/contrast/utils/assess/propagation_method_utils.rb
1152
1221
  - lib/contrast/utils/assess/property/tagged_utils.rb
1153
1222
  - lib/contrast/utils/assess/sampling_util.rb
@@ -1158,12 +1227,12 @@ files:
1158
1227
  - lib/contrast/utils/class_util.rb
1159
1228
  - lib/contrast/utils/duck_utils.rb
1160
1229
  - lib/contrast/utils/env_configuration_item.rb
1161
- - lib/contrast/utils/exclude_key.rb
1162
1230
  - lib/contrast/utils/findings.rb
1163
1231
  - lib/contrast/utils/hash_digest.rb
1164
1232
  - lib/contrast/utils/hash_digest_extend.rb
1165
1233
  - lib/contrast/utils/head_dump_utils_extend.rb
1166
1234
  - lib/contrast/utils/heap_dump_util.rb
1235
+ - lib/contrast/utils/input_classification.rb
1167
1236
  - lib/contrast/utils/invalid_configuration_util.rb
1168
1237
  - lib/contrast/utils/io_util.rb
1169
1238
  - lib/contrast/utils/job_servers_running.rb
@@ -1186,6 +1255,7 @@ files:
1186
1255
  - lib/contrast/utils/tag_util.rb
1187
1256
  - lib/contrast/utils/telemetry.rb
1188
1257
  - lib/contrast/utils/telemetry_client.rb
1258
+ - lib/contrast/utils/telemetry_hash.rb
1189
1259
  - lib/contrast/utils/telemetry_identifier.rb
1190
1260
  - lib/contrast/utils/thread_tracker.rb
1191
1261
  - lib/contrast/utils/timer.rb
@@ -1205,7 +1275,7 @@ homepage: https://www.contrastsecurity.com
1205
1275
  licenses:
1206
1276
  - CONTRAST SECURITY (see license file)
1207
1277
  metadata:
1208
- changelog_uri: https://docs.contrastsecurity.com/release.html
1278
+ changelog_uri: https://docs.contrastsecurity.com/en/ruby-agent-release-notes-and-archive.html
1209
1279
  support_uri: https://support.contrastsecurity.com
1210
1280
  trouble_shooting_uri: https://support.contrastsecurity.com/hc/en-us/search?utf8=%E2%9C%93&query=Ruby
1211
1281
  wiki_uri: https://docs.contrastsecurity.com/
@@ -1218,7 +1288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1218
1288
  requirements:
1219
1289
  - - ">="
1220
1290
  - !ruby/object:Gem::Version
1221
- version: 2.6.0
1291
+ version: 2.7.0
1222
1292
  - - "<"
1223
1293
  - !ruby/object:Gem::Version
1224
1294
  version: 3.2.0
@@ -1,26 +0,0 @@
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
- require 'contrast/utils/metrics_hash'
5
- require 'contrast/agent/telemetry_event'
6
-
7
- module Contrast
8
- module Agent
9
- # This class will hold the basic information for a Telemetry Event
10
- class MetricTelemetryEvent < Contrast::Agent::TelemetryEvent
11
- include Contrast::Utils
12
-
13
- attr_reader :fields
14
-
15
- def initialize
16
- super
17
- @fields = MetricsHash.new(Numeric)
18
- @fields['_filler'] = 0
19
- end
20
-
21
- def to_hash **_args
22
- super.merge!({ fields: @fields })
23
- end
24
- end
25
- end
26
- end
@@ -1,121 +0,0 @@
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
- require 'contrast/utils/metrics_hash'
5
- require 'contrast/agent/metric_telemetry_event'
6
- require 'contrast/agent/version'
7
- require 'contrast/utils/os'
8
-
9
- module Contrast
10
- module Agent
11
- # This class will hold the Startup Metrics Telemetry Event
12
- # The class will include initialization of the agent version, language version
13
- # os type, arch and version
14
- # application framework and version and server framework
15
- # It will be initialized and send in Middleware#agent_startup_routine
16
- class StartupMetricsTelemetryEvent < Contrast::Agent::MetricTelemetryEvent
17
- include Contrast::Utils::OS
18
-
19
- APP_AND_SERVER_DATA = ::Contrast::APP_CONTEXT.app_and_server_information.cs__freeze
20
- # Multi-tenant Production Environments
21
- SAAS_DEFAULT = { addr: 'app.contrastsecurity.com', type: 'SAAS_DEFAULT' }.cs__freeze
22
- SAAS_CS = { addr: /cs[[:digit:]]+\.contrastsecurity\.com/, type: 'SAAS_DEFAULT' }.cs__freeze
23
- SAAS_JP = { addr: 'app.contrastsecurity.jp', type: 'SAAS_DEFAULT' }.cs__freeze
24
- SAAS_CE = { addr: 'ce.contrastsecurity.com', type: 'SAAS_CE' }.cs__freeze
25
- # Multi-tenant Demo Environments
26
- SAAS_DEMO = { addr: 'apptwo.contrastsecurity.com', type: 'SAAS_DEMO' }.cs__freeze
27
- SAAS_POV = { addr: 'eval.contrastsecurity.com', type: 'SAAS_POV' }.cs__freeze
28
- # Multi-tenant Testing Environment
29
- SAAS_RESEARCH = { addr: 'security-research.contrastsecurity.com', type: 'SAAS_RESEARCH' }.cs__freeze
30
- SAAS_ALPHA = { addr: 'alpha.contrastsecurity.com', type: 'SAAS_ALPHA' }.cs__freeze
31
- SAAS_STAGING = { addr: 'teamserver-staging.contsec.com', type: 'SAAS_TESTING' }.cs__freeze
32
- SAAS_STAGING_TOKYO = { addr: 'teamserver-staging.contsec.jp', type: 'SAAS_TESTING' }.cs__freeze
33
- SAAS_TESTING = { addr: 'teamserver-darpa.contsec.com', type: 'SAAS_TESTING' }.cs__freeze
34
- SAAS_OPS_TESTING = { addr: 'teamserver-ops.contsec.com', type: 'SAAS_TESTING' }.cs__freeze
35
- # Fallback for Single-tenant Production Environments
36
- SAAS_CUSTOM = { addr: 'contrastsecurity.com', type: 'SAAS_CUSTOM' }.cs__freeze
37
- SAAS_CUSTOM_JP = { addr: 'contrastsecurity.jp', type: 'SAAS_CUSTOM' }.cs__freeze
38
-
39
- SINGLE_MAP_TENANTS = [
40
- SAAS_DEFAULT, SAAS_JP, SAAS_CE, SAAS_DEMO, SAAS_POV, SAAS_RESEARCH, SAAS_ALPHA,
41
- SAAS_STAGING, SAAS_STAGING_TOKYO, SAAS_TESTING, SAAS_OPS_TESTING
42
- ].cs__freeze
43
- REGEXP_MAP_TENANTS = [SAAS_CS].cs__freeze
44
- FALLBACK_TENANTS = [SAAS_CUSTOM, SAAS_CUSTOM_JP].cs__freeze
45
- # Fallback for Custom, most likely self-hosted, Environments
46
- EOP = 'EOP'
47
- REJECTED_VALUES = [:EMPTY_VALUE, 'NEEDS_TO_BE_SET', Contrast::Utils::ObjectShare::EMPTY_STRING].cs__freeze
48
-
49
- def initialize
50
- super
51
- @settings = []
52
- add_config_keys ::Contrast::CONFIG.root, 'root'
53
- @settings << ENV.keys.select { |v| v.starts_with?('CONTRAST') }
54
- @settings.flatten
55
- add_tags
56
- end
57
-
58
- def path
59
- '/startup'
60
- end
61
-
62
- def add_tags
63
- add_system_tags
64
- @tags['app_framework_and_version'] = APP_AND_SERVER_DATA[:application_info].to_s
65
- @tags['server_framework_and_version'] = APP_AND_SERVER_DATA[:server_info].to_s
66
- @tags['ASSESS'] = Contrast::ASSESS.enabled?.to_s
67
- @tags['PROTECT'] = Contrast::PROTECT.enabled?.to_s
68
- @tags['settings'] = @settings.join(',')
69
- end
70
-
71
- def add_config_keys config, nested_key
72
- config.configuration_map.reject! { |_k, v| REJECTED_VALUES.include?(v) }
73
-
74
- config.configuration_map.each do |k, v|
75
- unless v.cs__class <= Contrast::Config::BaseConfiguration
76
- @settings << "#{ nested_key }.#{ k }"
77
- next
78
- end
79
-
80
- add_config_keys v, "#{ nested_key }.#{ k }"
81
- end
82
- end
83
-
84
- def sys_info
85
- @sys_info ||= get_system_information if @sys_info.nil?
86
- @sys_info
87
- end
88
-
89
- private
90
-
91
- # Here we extract the TeamServer url type
92
- #
93
- # @return [String] the type of TeamServer environment to which we're connecting
94
- def teamserver_type
95
- @_teamserver_type ||= begin
96
- url = Contrast::API.api_url
97
- if (single = SINGLE_MAP_TENANTS.find { |tenant| url.include?(tenant[:addr]) })
98
- single[:type]
99
- elsif (regexp = REGEXP_MAP_TENANTS.find { |tenant| tenant[:addr].match?(url) })
100
- regexp[:type]
101
- elsif (fallback = FALLBACK_TENANTS.find { |tenant| url.include?(tenant[:addr]) })
102
- fallback[:type]
103
- else
104
- EOP
105
- end
106
- end
107
- end
108
-
109
- # Here we attach the key-value pairs of the system
110
- #
111
- def add_system_tags
112
- @tags['teamserver'] = teamserver_type
113
- @tags['agent_version'] = VERSION
114
- @tags['ruby_version'] = RUBY_VERSION
115
- @tags['os_type'] = sys_info['os_type'] == 'Darwin' ? 'MacOS' : 'Linux'
116
- @tags['os_arch'] = sys_info['os_arch']
117
- @tags['os_version'] = sys_info['os_version']
118
- end
119
- end
120
- end
121
- end
@@ -1,137 +0,0 @@
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
- require 'contrast/config/env_variables'
5
- require 'contrast/components/logger'
6
- require 'contrast/utils/telemetry_client'
7
- require 'contrast/agent/worker_thread'
8
- require 'contrast/utils/telemetry'
9
-
10
- module Contrast
11
- module Agent
12
- # This class will initialize and hold everything needed for the telemetry
13
- class Telemetry < WorkerThread
14
- include Contrast::Components::Logger::InstanceMethods
15
- # this is where we will send the data from the agents
16
- URL = 'https://telemetry.ruby.contrastsecurity.com/'
17
- # Suggested timeout after each send is to be 3 hours (10800 seconds)
18
- SUGGESTED_TIMEOUT = 10_800
19
-
20
- class << self
21
- include Contrast::Components::Logger::InstanceMethods
22
- include Contrast::Config::EnvVariables
23
-
24
- def application_id
25
- @_application_id ||= begin
26
- id = nil
27
- mac = Contrast::Utils::Telemetry::Identifier.mac
28
- app_name = Contrast::Utils::Telemetry::Identifier.app_name
29
- id = mac + app_name if mac && app_name
30
- Digest::SHA2.new(256).hexdigest(id || ('_' + SecureRandom.uuid))
31
- end
32
- end
33
-
34
- def instance_id
35
- @_instance_id ||= Digest::SHA2.new(256).hexdigest(Contrast::Utils::Telemetry::Identifier.mac ||
36
- ('_' + SecureRandom.uuid))
37
- end
38
-
39
- def enabled?
40
- @_enabled = telemetry_enabled? if @_enabled.nil?
41
- @_enabled
42
- end
43
-
44
- private
45
-
46
- def telemetry_enabled?
47
- opt_out_telemetry = return_value(:telemetry_opt_outs)
48
- return false if opt_out_telemetry.to_s.casecmp('true').zero?
49
- return false if opt_out_telemetry.to_s.casecmp('1').zero?
50
-
51
- # In case of connection error, do not create the background thread or queue,
52
- # as if the opt-out env var was set
53
- @_client = Contrast::Utils::TelemetryClient.new
54
- ip_opt_out_telemetry = @_client.initialize_connection(URL)
55
- if ip_opt_out_telemetry.nil?
56
- logger.warn('Connection was not established properly!!!')
57
- logger.warn('THE SERVICE IS GOING TO BE TERMINATED!!')
58
- return false
59
- end
60
-
61
- true
62
- end
63
- end
64
-
65
- def client
66
- @_client ||= Contrast::Utils::TelemetryClient.new
67
- end
68
-
69
- def connection
70
- @_connection ||= client.initialize_connection(URL)
71
- end
72
-
73
- def attempt_to_start?
74
- unless cs__class.enabled?
75
- logger.warn('Telemetry service is disabled!')
76
- return false
77
- end
78
-
79
- logger.debug('Attempting to start telemetry thread') unless running?
80
- true
81
- end
82
-
83
- def start_thread!
84
- return if running?
85
-
86
- # It is recommended that implementations send a single payload of
87
- # general metrics every 3 hours, starting from implementation startup.
88
- @_thread = Contrast::Agent::Thread.new do
89
- logger.debug('Starting background telemetry thread.')
90
- event = queue.pop
91
-
92
- begin
93
- logger.debug('This is the current processed event', event)
94
- res = client.send_request event, connection
95
- sleep_time = client.handle_response res
96
- sleep(sleep_time) unless sleep_time.nil?
97
- rescue StandardError => e
98
- logger.error('Could not send message to service from telemetry queue.', e)
99
- end
100
- sleep(SUGGESTED_TIMEOUT)
101
- end
102
- end
103
-
104
- def send_event event
105
- if ::Contrast::AGENT.disabled?
106
- logger.warn('Attempted to queue event with Agent disabled', caller: caller, event: event)
107
- return
108
- end
109
-
110
- return unless cs__class.enabled?
111
-
112
- logger.debug('Enqueued event for sending', event_type: event.cs__class)
113
-
114
- queue << event if event
115
- end
116
-
117
- def delete_queue!
118
- @_queue&.clear
119
- @_queue&.close
120
- @_queue = nil
121
- end
122
-
123
- def stop!
124
- return unless running?
125
-
126
- super
127
- delete_queue!
128
- end
129
-
130
- private
131
-
132
- def queue
133
- @_queue ||= Queue.new
134
- end
135
- end
136
- end
137
- end