contrast-agent 4.3.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -1
  3. data/Gemfile +1 -1
  4. data/LICENSE.txt +1 -1
  5. data/Rakefile +1 -1
  6. data/exe/contrast_service +1 -1
  7. data/ext/build_funchook.rb +1 -1
  8. data/ext/cs__assess_active_record_named/cs__active_record_named.c +1 -1
  9. data/ext/cs__assess_active_record_named/extconf.rb +1 -1
  10. data/ext/cs__assess_array/cs__assess_array.c +1 -1
  11. data/ext/cs__assess_array/extconf.rb +1 -1
  12. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +1 -1
  13. data/ext/cs__assess_basic_object/extconf.rb +1 -1
  14. data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
  15. data/ext/cs__assess_fiber_track/extconf.rb +1 -1
  16. data/ext/cs__assess_hash/cs__assess_hash.c +4 -2
  17. data/ext/cs__assess_hash/extconf.rb +1 -1
  18. data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -1
  19. data/ext/cs__assess_kernel/extconf.rb +1 -1
  20. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +1 -1
  21. data/ext/cs__assess_marshal_module/extconf.rb +1 -1
  22. data/ext/cs__assess_module/cs__assess_module.c +1 -1
  23. data/ext/cs__assess_module/extconf.rb +1 -1
  24. data/ext/cs__assess_regexp/cs__assess_regexp.c +1 -1
  25. data/ext/cs__assess_regexp/extconf.rb +1 -1
  26. data/ext/cs__assess_string/cs__assess_string.c +1 -1
  27. data/ext/cs__assess_string/extconf.rb +1 -1
  28. data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c +1 -1
  29. data/ext/cs__assess_string_interpolation26/extconf.rb +1 -1
  30. data/ext/cs__assess_yield_track/cs__assess_yield_track.c +1 -1
  31. data/ext/cs__assess_yield_track/extconf.rb +1 -1
  32. data/ext/cs__common/cs__common.c +5 -5
  33. data/ext/cs__common/cs__common.h +4 -4
  34. data/ext/cs__common/extconf.rb +1 -1
  35. data/ext/cs__contrast_patch/cs__contrast_patch.c +22 -25
  36. data/ext/cs__contrast_patch/extconf.rb +1 -1
  37. data/ext/cs__protect_kernel/cs__protect_kernel.c +1 -1
  38. data/ext/cs__protect_kernel/extconf.rb +1 -1
  39. data/ext/extconf_common.rb +1 -1
  40. data/lib/contrast-agent.rb +1 -1
  41. data/lib/contrast.rb +20 -1
  42. data/lib/contrast/agent.rb +6 -2
  43. data/lib/contrast/agent/assess.rb +1 -10
  44. data/lib/contrast/agent/assess/contrast_event.rb +54 -71
  45. data/lib/contrast/agent/assess/contrast_object.rb +6 -3
  46. data/lib/contrast/agent/assess/events/event_factory.rb +1 -1
  47. data/lib/contrast/agent/assess/events/source_event.rb +7 -2
  48. data/lib/contrast/agent/assess/finalizers/freeze.rb +1 -1
  49. data/lib/contrast/agent/assess/finalizers/hash.rb +33 -34
  50. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +30 -15
  51. data/lib/contrast/agent/assess/policy/patcher.rb +1 -1
  52. data/lib/contrast/agent/assess/policy/policy.rb +1 -1
  53. data/lib/contrast/agent/assess/policy/policy_node.rb +1 -1
  54. data/lib/contrast/agent/assess/policy/policy_scanner.rb +1 -1
  55. data/lib/contrast/agent/assess/policy/preshift.rb +1 -1
  56. data/lib/contrast/agent/assess/policy/propagation_method.rb +30 -19
  57. data/lib/contrast/agent/assess/policy/propagation_node.rb +1 -1
  58. data/lib/contrast/agent/assess/policy/propagator.rb +1 -1
  59. data/lib/contrast/agent/assess/policy/propagator/append.rb +29 -14
  60. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  61. data/lib/contrast/agent/assess/policy/propagator/center.rb +1 -1
  62. data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
  63. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +22 -17
  64. data/lib/contrast/agent/assess/policy/propagator/insert.rb +1 -1
  65. data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
  66. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +1 -1
  67. data/lib/contrast/agent/assess/policy/propagator/next.rb +1 -1
  68. data/lib/contrast/agent/assess/policy/propagator/prepend.rb +1 -1
  69. data/lib/contrast/agent/assess/policy/propagator/remove.rb +1 -1
  70. data/lib/contrast/agent/assess/policy/propagator/replace.rb +1 -1
  71. data/lib/contrast/agent/assess/policy/propagator/reverse.rb +1 -1
  72. data/lib/contrast/agent/assess/policy/propagator/select.rb +1 -1
  73. data/lib/contrast/agent/assess/policy/propagator/splat.rb +24 -14
  74. data/lib/contrast/agent/assess/policy/propagator/split.rb +15 -8
  75. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +31 -15
  76. data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
  77. data/lib/contrast/agent/assess/policy/rewriter_patch.rb +1 -1
  78. data/lib/contrast/agent/assess/policy/source_method.rb +87 -76
  79. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  80. data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +8 -6
  81. data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
  82. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +3 -3
  83. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +7 -8
  84. data/lib/contrast/agent/assess/policy/trigger_method.rb +106 -64
  85. data/lib/contrast/agent/assess/policy/trigger_node.rb +31 -10
  86. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +59 -0
  87. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +2 -3
  88. data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +7 -5
  89. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +3 -5
  90. data/lib/contrast/agent/assess/properties.rb +1 -3
  91. data/lib/contrast/agent/assess/property/evented.rb +1 -1
  92. data/lib/contrast/agent/assess/property/tagged.rb +38 -20
  93. data/lib/contrast/agent/assess/property/updated.rb +1 -1
  94. data/lib/contrast/agent/assess/rule/provider.rb +1 -1
  95. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +1 -1
  96. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -1
  97. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +1 -1
  98. data/lib/contrast/agent/assess/tag.rb +1 -1
  99. data/lib/contrast/agent/assess/tracker.rb +2 -2
  100. data/lib/contrast/agent/at_exit_hook.rb +1 -1
  101. data/lib/contrast/agent/class_reopener.rb +1 -1
  102. data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
  103. data/lib/contrast/agent/deadzone/policy/policy.rb +1 -1
  104. data/lib/contrast/agent/disable_reaction.rb +1 -1
  105. data/lib/contrast/agent/exclusion_matcher.rb +1 -1
  106. data/lib/contrast/agent/inventory.rb +1 -2
  107. data/lib/contrast/agent/inventory/dependencies.rb +1 -1
  108. data/lib/contrast/agent/inventory/dependency_analysis.rb +1 -1
  109. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +35 -23
  110. data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
  111. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  112. data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
  113. data/lib/contrast/agent/middleware.rb +87 -58
  114. data/lib/contrast/agent/module_data.rb +1 -1
  115. data/lib/contrast/agent/patching/policy/after_load_patch.rb +1 -1
  116. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +5 -1
  117. data/lib/contrast/agent/patching/policy/method_policy.rb +1 -1
  118. data/lib/contrast/agent/patching/policy/module_policy.rb +1 -1
  119. data/lib/contrast/agent/patching/policy/patch.rb +8 -6
  120. data/lib/contrast/agent/patching/policy/patch_status.rb +2 -2
  121. data/lib/contrast/agent/patching/policy/patcher.rb +59 -54
  122. data/lib/contrast/agent/patching/policy/policy.rb +1 -1
  123. data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
  124. data/lib/contrast/agent/patching/policy/trigger_node.rb +6 -3
  125. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +1 -1
  126. data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +1 -1
  127. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
  128. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +1 -1
  129. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -1
  130. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
  131. data/lib/contrast/agent/protect/policy/policy.rb +1 -1
  132. data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
  133. data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
  134. data/lib/contrast/agent/protect/rule.rb +1 -1
  135. data/lib/contrast/agent/protect/rule/base.rb +7 -18
  136. data/lib/contrast/agent/protect/rule/base_service.rb +2 -2
  137. data/lib/contrast/agent/protect/rule/cmd_injection.rb +2 -2
  138. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  139. data/lib/contrast/agent/protect/rule/deserialization.rb +1 -1
  140. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +1 -1
  141. data/lib/contrast/agent/protect/rule/no_sqli.rb +2 -2
  142. data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -1
  143. data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -1
  144. data/lib/contrast/agent/protect/rule/sqli.rb +18 -12
  145. data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +1 -1
  146. data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +1 -1
  147. data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +2 -2
  148. data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
  149. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -1
  150. data/lib/contrast/agent/protect/rule/xss.rb +1 -1
  151. data/lib/contrast/agent/protect/rule/xxe.rb +1 -1
  152. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +1 -1
  153. data/lib/contrast/agent/railtie.rb +1 -1
  154. data/lib/contrast/agent/reaction_processor.rb +1 -1
  155. data/lib/contrast/agent/request.rb +2 -1
  156. data/lib/contrast/agent/request_context.rb +17 -10
  157. data/lib/contrast/agent/request_handler.rb +1 -1
  158. data/lib/contrast/agent/response.rb +1 -1
  159. data/lib/contrast/agent/rewriter.rb +1 -1
  160. data/lib/contrast/agent/rule_set.rb +3 -3
  161. data/lib/contrast/agent/scope.rb +1 -1
  162. data/lib/contrast/agent/service_heartbeat.rb +1 -1
  163. data/lib/contrast/agent/static_analysis.rb +1 -1
  164. data/lib/contrast/agent/thread.rb +2 -2
  165. data/lib/contrast/agent/thread_watcher.rb +21 -6
  166. data/lib/contrast/agent/tracepoint_hook.rb +1 -1
  167. data/lib/contrast/agent/version.rb +2 -2
  168. data/lib/contrast/agent/worker_thread.rb +1 -1
  169. data/lib/contrast/api.rb +1 -1
  170. data/lib/contrast/api/communication.rb +1 -1
  171. data/lib/contrast/api/communication/connection_status.rb +1 -1
  172. data/lib/contrast/api/communication/messaging_queue.rb +19 -22
  173. data/lib/contrast/api/communication/response_processor.rb +9 -2
  174. data/lib/contrast/api/communication/service_lifecycle.rb +1 -1
  175. data/lib/contrast/api/communication/socket.rb +1 -1
  176. data/lib/contrast/api/communication/socket_client.rb +23 -15
  177. data/lib/contrast/api/communication/speedracer.rb +3 -3
  178. data/lib/contrast/api/communication/tcp_socket.rb +1 -1
  179. data/lib/contrast/api/communication/unix_socket.rb +1 -1
  180. data/lib/contrast/api/decorators.rb +3 -1
  181. data/lib/contrast/api/decorators/address.rb +1 -1
  182. data/lib/contrast/api/decorators/agent_startup.rb +58 -0
  183. data/lib/contrast/api/decorators/application_settings.rb +1 -1
  184. data/lib/contrast/api/decorators/application_startup.rb +53 -0
  185. data/lib/contrast/api/decorators/application_update.rb +1 -1
  186. data/lib/contrast/api/decorators/http_request.rb +1 -1
  187. data/lib/contrast/api/decorators/input_analysis.rb +1 -1
  188. data/lib/contrast/api/decorators/instrumentation_mode.rb +37 -0
  189. data/lib/contrast/api/decorators/library.rb +1 -1
  190. data/lib/contrast/api/decorators/library_usage_update.rb +1 -1
  191. data/lib/contrast/api/decorators/message.rb +1 -1
  192. data/lib/contrast/api/decorators/rasp_rule_sample.rb +1 -1
  193. data/lib/contrast/api/decorators/route_coverage.rb +16 -6
  194. data/lib/contrast/api/decorators/server_features.rb +1 -1
  195. data/lib/contrast/api/decorators/trace_event.rb +43 -15
  196. data/lib/contrast/api/decorators/trace_event_object.rb +1 -1
  197. data/lib/contrast/api/decorators/trace_event_signature.rb +1 -1
  198. data/lib/contrast/api/decorators/trace_taint_range.rb +1 -1
  199. data/lib/contrast/api/decorators/trace_taint_range_tags.rb +1 -1
  200. data/lib/contrast/api/decorators/user_input.rb +1 -1
  201. data/lib/contrast/common_agent_configuration.rb +1 -1
  202. data/lib/contrast/components/agent.rb +3 -1
  203. data/lib/contrast/components/app_context.rb +5 -23
  204. data/lib/contrast/components/assess.rb +1 -1
  205. data/lib/contrast/components/config.rb +1 -1
  206. data/lib/contrast/components/contrast_service.rb +1 -1
  207. data/lib/contrast/components/heap_dump.rb +1 -1
  208. data/lib/contrast/components/interface.rb +1 -1
  209. data/lib/contrast/components/inventory.rb +1 -1
  210. data/lib/contrast/components/logger.rb +1 -1
  211. data/lib/contrast/components/protect.rb +4 -2
  212. data/lib/contrast/components/sampling.rb +49 -7
  213. data/lib/contrast/components/scope.rb +1 -1
  214. data/lib/contrast/components/settings.rb +7 -6
  215. data/lib/contrast/config.rb +1 -1
  216. data/lib/contrast/config/agent_configuration.rb +1 -1
  217. data/lib/contrast/config/application_configuration.rb +1 -1
  218. data/lib/contrast/config/assess_configuration.rb +1 -1
  219. data/lib/contrast/config/assess_rules_configuration.rb +1 -1
  220. data/lib/contrast/config/base_configuration.rb +1 -1
  221. data/lib/contrast/config/default_value.rb +1 -1
  222. data/lib/contrast/config/exception_configuration.rb +1 -1
  223. data/lib/contrast/config/heap_dump_configuration.rb +1 -1
  224. data/lib/contrast/config/inventory_configuration.rb +1 -1
  225. data/lib/contrast/config/logger_configuration.rb +1 -1
  226. data/lib/contrast/config/protect_configuration.rb +1 -1
  227. data/lib/contrast/config/protect_rule_configuration.rb +23 -1
  228. data/lib/contrast/config/protect_rules_configuration.rb +1 -1
  229. data/lib/contrast/config/root_configuration.rb +1 -1
  230. data/lib/contrast/config/ruby_configuration.rb +1 -1
  231. data/lib/contrast/config/sampling_configuration.rb +1 -1
  232. data/lib/contrast/config/server_configuration.rb +1 -1
  233. data/lib/contrast/config/service_configuration.rb +1 -1
  234. data/lib/contrast/configuration.rb +1 -1
  235. data/lib/contrast/delegators/input_analysis.rb +12 -0
  236. data/lib/contrast/extension/assess.rb +1 -1
  237. data/lib/contrast/extension/assess/array.rb +1 -1
  238. data/lib/contrast/extension/assess/erb.rb +1 -1
  239. data/lib/contrast/extension/assess/eval_trigger.rb +1 -5
  240. data/lib/contrast/extension/assess/exec_trigger.rb +1 -5
  241. data/lib/contrast/extension/assess/fiber.rb +1 -1
  242. data/lib/contrast/extension/assess/hash.rb +1 -1
  243. data/lib/contrast/extension/assess/kernel.rb +1 -1
  244. data/lib/contrast/extension/assess/marshal.rb +1 -5
  245. data/lib/contrast/extension/assess/regexp.rb +1 -1
  246. data/lib/contrast/extension/assess/string.rb +1 -1
  247. data/lib/contrast/extension/delegator.rb +1 -1
  248. data/lib/contrast/extension/inventory.rb +1 -1
  249. data/lib/contrast/extension/kernel.rb +1 -1
  250. data/lib/contrast/extension/module.rb +1 -1
  251. data/lib/contrast/extension/protect.rb +1 -1
  252. data/lib/contrast/extension/protect/kernel.rb +1 -1
  253. data/lib/contrast/extension/protect/psych.rb +1 -1
  254. data/lib/contrast/extension/thread.rb +1 -1
  255. data/lib/contrast/framework/base_support.rb +1 -1
  256. data/lib/contrast/framework/manager.rb +14 -13
  257. data/lib/contrast/framework/platform_version.rb +1 -1
  258. data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
  259. data/lib/contrast/framework/rack/patch/support.rb +1 -1
  260. data/lib/contrast/framework/rack/support.rb +1 -1
  261. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -1
  262. data/lib/contrast/framework/rails/patch/assess_configuration.rb +1 -1
  263. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +4 -4
  264. data/lib/contrast/framework/rails/patch/support.rb +1 -1
  265. data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +1 -1
  266. data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +1 -1
  267. data/lib/contrast/framework/rails/rewrite/active_record_named.rb +1 -1
  268. data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +1 -1
  269. data/lib/contrast/framework/rails/support.rb +43 -44
  270. data/lib/contrast/framework/sinatra/support.rb +101 -42
  271. data/lib/contrast/funchook/funchook.rb +1 -1
  272. data/lib/contrast/logger/application.rb +1 -1
  273. data/lib/contrast/logger/format.rb +1 -1
  274. data/lib/contrast/logger/log.rb +32 -16
  275. data/lib/contrast/logger/request.rb +1 -1
  276. data/lib/contrast/logger/time.rb +1 -1
  277. data/lib/contrast/security_exception.rb +1 -1
  278. data/lib/contrast/tasks/config.rb +1 -1
  279. data/lib/contrast/tasks/service.rb +1 -1
  280. data/lib/contrast/utils/assess/sampling_util.rb +1 -1
  281. data/lib/contrast/utils/assess/tracking_util.rb +1 -1
  282. data/lib/contrast/utils/class_util.rb +18 -4
  283. data/lib/contrast/utils/duck_utils.rb +1 -1
  284. data/lib/contrast/utils/env_configuration_item.rb +1 -1
  285. data/lib/contrast/utils/hash_digest.rb +14 -19
  286. data/lib/contrast/utils/heap_dump_util.rb +104 -88
  287. data/lib/contrast/utils/invalid_configuration_util.rb +22 -13
  288. data/lib/contrast/utils/inventory_util.rb +1 -1
  289. data/lib/contrast/utils/io_util.rb +1 -1
  290. data/lib/contrast/utils/job_servers_running.rb +1 -1
  291. data/lib/contrast/utils/object_share.rb +1 -1
  292. data/lib/contrast/utils/os.rb +1 -1
  293. data/lib/contrast/utils/preflight_util.rb +1 -1
  294. data/lib/contrast/utils/resource_loader.rb +1 -1
  295. data/lib/contrast/utils/ruby_ast_rewriter.rb +1 -1
  296. data/lib/contrast/utils/sha256_builder.rb +1 -1
  297. data/lib/contrast/utils/stack_trace_utils.rb +1 -1
  298. data/lib/contrast/utils/string_utils.rb +1 -1
  299. data/lib/contrast/utils/tag_util.rb +1 -1
  300. data/lib/contrast/utils/thread_tracker.rb +1 -1
  301. data/lib/contrast/utils/timer.rb +1 -1
  302. data/resources/assess/policy.json +8 -11
  303. data/resources/deadzone/policy.json +7 -23
  304. data/ruby-agent.gemspec +56 -19
  305. data/service_executables/VERSION +1 -1
  306. data/service_executables/linux/contrast-service +0 -0
  307. data/service_executables/mac/contrast-service +0 -0
  308. metadata +117 -161
  309. data/lib/contrast/agent/assess/rule.rb +0 -18
  310. data/lib/contrast/agent/assess/rule/base.rb +0 -52
  311. data/lib/contrast/agent/assess/rule/redos.rb +0 -67
  312. data/lib/contrast/agent/inventory/gemfile_digest_cache.rb +0 -38
  313. data/lib/contrast/framework/sinatra/patch/base.rb +0 -83
  314. data/lib/contrast/framework/sinatra/patch/support.rb +0 -27
  315. data/lib/contrast/utils/prevent_serialization.rb +0 -52
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/object_share'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -26,27 +26,37 @@ module Contrast
26
26
  end
27
27
 
28
28
  # Convert ActionDispatch::Journey::Route to Contrast::Api::Dtm::RouteCoverage
29
+ #
29
30
  # @param journey_obj [ActionDispatch::Journey::Route] a rails route
31
+ # @param url [String, nil] use url from string instead of journey object.
30
32
  # @return [Contrast::Api::Dtm::RouteCoverage]
31
- def from_action_dispatch_journey journey_obj
33
+ def from_action_dispatch_journey journey_obj, url = nil
32
34
  msg = new
33
35
  msg.route = "#{ journey_obj.defaults[:controller] }##{ journey_obj.defaults[:action] }"
34
36
 
35
37
  verb = source_or_string(journey_obj.verb)
36
38
  msg.verb = Contrast::Utils::StringUtils.force_utf8(verb)
37
39
 
38
- url = source_or_string(journey_obj.path.spec)
40
+ url ||= source_or_string(journey_obj.path.spec)
39
41
  msg.url = Contrast::Utils::StringUtils.force_utf8(url)
40
42
  msg
41
43
  end
42
44
 
43
- def from_sinatra_route clazz, method, pattern
45
+ # Convert Sinatra route data to dtm message.
46
+ #
47
+ # @param controller [::Sinatra::Base] the route's final controller.
48
+ # @param method [String] GET, PUT, POST, etc...
49
+ # @param method [::Mustermann::Sinatra] the pattern that was matched in routing.
50
+ # @param url [String, nil] use url from string instead matched pattern.
51
+ # @return [Contrast::Api::Dtm::RouteCoverage]
52
+ def from_sinatra_route controller, method, pattern, url = nil
44
53
  safe_pattern = source_or_string(pattern)
54
+ safe_url = source_or_string(url || pattern)
45
55
 
46
56
  msg = new
47
- msg.route = "#{ clazz }##{ method } #{ safe_pattern }"
57
+ msg.route = "#{ controller }##{ method } #{ safe_pattern }"
48
58
  msg.verb = Contrast::Utils::StringUtils.force_utf8(method)
49
- msg.url = Contrast::Utils::StringUtils.force_utf8(safe_pattern)
59
+ msg.url = Contrast::Utils::StringUtils.force_utf8(safe_url)
50
60
  msg
51
61
  end
52
62
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -13,8 +13,38 @@ module Contrast
13
13
  klass.extend(ClassMethods)
14
14
  end
15
15
 
16
+ # The TeamServer uses the Event's type and action to render it in the Details page. These values control the
17
+ # left-hand "What happened" column and the data shown in the right-hand data
18
+ #
19
+ # @param contrast_event [Contrast::Agent::Assess::ContrastEvent]
20
+ # @return [Contrast::Api::Dtm::TraceEvent]
21
+ def build_display_params! contrast_event
22
+ self.type = contrast_event.policy_node.node_type
23
+ self.action = contrast_event.policy_node.build_action
24
+ self
25
+ end
26
+
27
+ # The TeamServer uses the Event's representation of the data to render the actual data used in the dataflow on
28
+ # the Details page.
29
+ #
30
+ # @param contrast_event [Contrast::Agent::Assess::ContrastEvent]
31
+ # @return [Contrast::Api::Dtm::TraceEvent]
32
+ def build_dataflow! contrast_event
33
+ # Figure out what the target of this event was. This can't be pulled into the decorator because SourceEvent
34
+ # has a custom impl :/
35
+ taint_target = contrast_event.determine_taint_target(self)
36
+ truncate_obj = Contrast::Utils::ObjectShare::OBJECT_KEY != taint_target
37
+ self.object = Contrast::Api::Dtm::TraceEventObject.build(contrast_event.object, truncate_obj)
38
+ truncate_ret = Contrast::Utils::ObjectShare::RETURN_KEY != taint_target
39
+ self.ret = Contrast::Api::Dtm::TraceEventObject.build(contrast_event.ret, truncate_ret)
40
+ build_event_args!(contrast_event, taint_target)
41
+ build_taint_ranges!(contrast_event)
42
+ self
43
+ end
44
+
16
45
  # Wrapper around build_event_object for the args array. Handles
17
46
  # tainting the correct argument.
47
+ # @return [Contrast::Api::Dtm::TraceEvent]
18
48
  def build_event_args! contrast_event, taint_target
19
49
  contrast_event.args.each_index do |idx|
20
50
  truncate_arg = taint_target != idx
@@ -29,6 +59,7 @@ module Contrast
29
59
  # their DTM form in order to report this.
30
60
  #
31
61
  # @param contrast_event [Contrast::Agent::AssessContrastEvent]
62
+ # @return [Contrast::Api::Dtm::TraceEvent]
32
63
  def build_taint_ranges! contrast_event
33
64
  # If there's no taint_target, this isn't a dataflow trace, but a
34
65
  # trigger one
@@ -38,6 +69,10 @@ module Contrast
38
69
  self
39
70
  end
40
71
 
72
+ # For each Parent in the ContrastEvent, capture its id and report it to TeamServer.
73
+ #
74
+ # @param contrast_event [Contrast::Agent::AssessContrastEvent]
75
+ # @return [Contrast::Api::Dtm::TraceEvent]
41
76
  def build_parent_ids! contrast_event
42
77
  contrast_event&.parent_events&.each do |event|
43
78
  next unless event
@@ -49,6 +84,10 @@ module Contrast
49
84
  self
50
85
  end
51
86
 
87
+ # Convert the caller into the Stack DTM TeamServer consumes
88
+ #
89
+ # @param contrast_event [Contrast::Agent::AssessContrastEvent]
90
+ # @return [Contrast::Api::Dtm::TraceEvent]
52
91
  def build_stack! contrast_event
53
92
  # We delayed doing this as long as possible b/c it's expensive
54
93
  stack_dtms = Contrast::Utils::StackTraceUtils.build_assess_stack_array(contrast_event.stack_trace)
@@ -60,23 +99,12 @@ module Contrast
60
99
  module ClassMethods
61
100
  def build contrast_event
62
101
  event_dtm = new
63
- # Figure out what the target of this event was. It's a little
64
- # annoying for us since P can be named (thanks, Ruby) where
65
- # as for everyone else it is idx based.
66
- taint_target = contrast_event.determine_taint_target(event_dtm) # This can't be pulled into the decorator because SourceEvent has a custom impl :/
67
-
68
- event_dtm.type = contrast_event.policy_node.node_type
69
- event_dtm.action = contrast_event.policy_node.build_action
102
+ event_dtm.build_display_params!(contrast_event)
103
+ event_dtm.build_dataflow!(contrast_event)
104
+ event_dtm.build_stack!(contrast_event)
70
105
  event_dtm.timestamp_ms = contrast_event.time.to_i
71
106
  event_dtm.thread = Contrast::Utils::StringUtils.force_utf8(contrast_event.thread)
72
- truncate_obj = Contrast::Utils::ObjectShare::OBJECT_KEY != taint_target
73
- event_dtm.object = Contrast::Api::Dtm::TraceEventObject.build(contrast_event.object, truncate_obj)
74
- truncate_ret = Contrast::Utils::ObjectShare::RETURN_KEY != taint_target
75
- event_dtm.ret = Contrast::Api::Dtm::TraceEventObject.build(contrast_event.ret, truncate_ret)
76
- event_dtm.build_event_args!(contrast_event, taint_target)
77
107
  event_dtm.build_parent_ids!(contrast_event)
78
- event_dtm.build_taint_ranges!(contrast_event)
79
- event_dtm.build_stack!(contrast_event)
80
108
  event_dtm.object_id = contrast_event.event_id.to_i
81
109
  event_dtm.signature = Contrast::Api::Dtm::TraceEventSignature.build(contrast_event.ret, contrast_event.policy_node, contrast_event.args)
82
110
  event_dtm
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/object_share'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # rubocop:disable Style/MissingRespondToMissing
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'rubygems/version'
@@ -31,6 +31,8 @@ module Contrast
31
31
 
32
32
  def disable!
33
33
  @_enabled = false
34
+ Contrast::Agent::TracePointHook.disable
35
+ Contrast::Agent.thread_watcher&.shutdown!
34
36
  end
35
37
 
36
38
  def ruleset
@@ -1,7 +1,9 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'rubygems/version'
5
+ require 'contrast/api/decorators/agent_startup'
6
+ require 'contrast/api/decorators/application_startup'
5
7
  require 'contrast/utils/object_share'
6
8
 
7
9
  module Contrast
@@ -77,31 +79,11 @@ module Contrast
77
79
  end
78
80
 
79
81
  def build_app_startup_message
80
- msg = Contrast::Api::Dtm::ApplicationCreate.new
81
-
82
- msg.group = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.group
83
- msg.app_version = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.version.to_s
84
- msg.code = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.code
85
- msg.metadata = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.metadata
86
- # Other fields have limits in TeamServer, the rest don't.
87
- msg.session_id = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.session_id, truncate: false
88
- msg.session_metadata = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.session_metadata, truncate: false
89
-
90
- msg
82
+ Contrast::Api::Dtm::ApplicationCreate.build
91
83
  end
92
84
 
93
85
  def build_agent_startup_message
94
- msg = Contrast::Api::Dtm::AgentStartup.new
95
- msg.server_name = Contrast::Utils::StringUtils.protobuf_format server_name
96
- msg.server_path = Contrast::Utils::StringUtils.protobuf_format server_path
97
- msg.server_type = Contrast::Utils::StringUtils.protobuf_format server_type
98
- msg.server_version = Contrast::Agent::VERSION
99
- msg.version = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.server.version
100
- msg.environment = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.server.environment
101
- msg.server_tags = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.server.tags
102
- msg.application_tags = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.application.tags
103
- msg.library_tags = Contrast::Utils::StringUtils.protobuf_format CONFIG.root.inventory.tags
104
- msg.finding_tags = Contrast::Utils::StringUtils.protobuf_format ASSESS.tags
86
+ msg = Contrast::Api::Dtm::AgentStartup.build(server_name, server_path, server_type)
105
87
  logger.info('Application context',
106
88
  server_name: msg.server_name,
107
89
  server_path: msg.server_path,
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/env_configuration_item'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'monitor'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'delegate'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/logger/log'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -32,7 +32,9 @@ module Contrast
32
32
  end
33
33
 
34
34
  def rule_mode rule_id
35
- CONFIG.root.protect.rules[rule_id]&.mode || SETTINGS.modes_by_id[rule_id] || :NO_ACTION
35
+ CONFIG.root.protect.rules[rule_id]&.applicable_mode ||
36
+ SETTINGS.modes_by_id[rule_id] ||
37
+ Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION
36
38
  end
37
39
 
38
40
  def rule name
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -25,14 +25,14 @@ module Contrast
25
25
 
26
26
  def sampling_control
27
27
  @_sampling_control ||= begin
28
- cas = CONFIG.root.assess&.sampling
28
+ config_settings = CONFIG.root.assess&.sampling
29
29
  settings = SETTINGS&.assess_state&.[](:sampling_settings)
30
30
  {
31
- enabled: true?([cas&.enable, settings&.enabled, DEFAULT_SAMPLING_ENABLED].reject(&:nil?)[0]),
32
- baseline: [cas&.baseline, settings&.baseline, DEFAULT_SAMPLING_BASELINE].map(&:to_i).find(&:positive?),
33
- request_frequency: [cas&.request_frequency, settings&.request_frequency, DEFAULT_SAMPLING_REQUEST_FREQUENCY].map(&:to_i).find(&:positive?),
34
- response_frequency: [cas&.response_frequency, settings&.response_frequency, DEFAULT_SAMPLING_RESPONSE_FREQUENCY].map(&:to_i).find(&:positive?),
35
- window: [cas&.window_ms, settings&.window_ms, DEFAULT_SAMPLING_WINDOW_MS].map(&:to_i).find(&:positive?)
31
+ enabled: enabled?(config_settings, settings),
32
+ baseline: baseline(config_settings, settings),
33
+ request_frequency: request_frequency(config_settings, settings),
34
+ response_frequency: response_frequency(config_settings, settings),
35
+ window: window(config_settings, settings)
36
36
  }
37
37
  end
38
38
  end
@@ -41,6 +41,48 @@ module Contrast
41
41
  def reset_sampling_control
42
42
  @_sampling_control = nil
43
43
  end
44
+
45
+ private
46
+
47
+ # @param config_settings [Contrast::Config::SamplingConfiguration] the Sampling configuration as provided by
48
+ # local user input
49
+ # @param settings [Contrast::Api::Settings::Sampling] the Sampling settings as provided by TeamServer
50
+ # @return [Boolean] the resolution of the config_settings, settings, and default value
51
+ def enabled? config_settings, settings
52
+ true?([config_settings&.enable, settings&.enabled, DEFAULT_SAMPLING_ENABLED].reject(&:nil?)[0])
53
+ end
54
+
55
+ # @param config_settings [Contrast::Config::SamplingConfiguration] the Sampling configuration as provided by
56
+ # local user input
57
+ # @param settings [Contrast::Api::Settings::Sampling] the Sampling settings as provided by TeamServer
58
+ # @return [Integer] the resolution of the config_settings, settings, and default value
59
+ def baseline config_settings, settings
60
+ [config_settings&.baseline, settings&.baseline, DEFAULT_SAMPLING_BASELINE].map(&:to_i).find(&:positive?)
61
+ end
62
+
63
+ # @param config_settings [Contrast::Config::SamplingConfiguration] the Sampling configuration as provided by
64
+ # local user input
65
+ # @param settings [Contrast::Api::Settings::Sampling] the Sampling settings as provided by TeamServer
66
+ # @return [Integer] the resolution of the config_settings, settings, and default value
67
+ def request_frequency config_settings, settings
68
+ [config_settings&.request_frequency, settings&.request_frequency, DEFAULT_SAMPLING_REQUEST_FREQUENCY].map(&:to_i).find(&:positive?)
69
+ end
70
+
71
+ # @param config_settings [Contrast::Config::SamplingConfiguration] the Sampling configuration as provided by
72
+ # local user input
73
+ # @param settings [Contrast::Api::Settings::Sampling] the Sampling settings as provided by TeamServer
74
+ # @return [Integer] the resolution of the config_settings, settings, and default value
75
+ def response_frequency config_settings, settings
76
+ [config_settings&.response_frequency, settings&.response_frequency, DEFAULT_SAMPLING_RESPONSE_FREQUENCY].map(&:to_i).find(&:positive?)
77
+ end
78
+
79
+ # @param config_settings [Contrast::Config::SamplingConfiguration] the Sampling configuration as provided by
80
+ # local user input
81
+ # @param settings [Contrast::Api::Settings::Sampling] the Sampling settings as provided by TeamServer
82
+ # @return [Integer] the resolution of the config_settings, settings, and default value
83
+ def window config_settings, settings
84
+ [config_settings&.window_ms, settings&.window_ms, DEFAULT_SAMPLING_WINDOW_MS].map(&:to_i).find(&:positive?)
85
+ end
44
86
  end
45
87
 
46
88
  module InstanceMethods #:nodoc:
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'fiber'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -28,8 +28,8 @@ module Contrast
28
28
 
29
29
  def assess_state
30
30
  @assess_state ||= { # rubocop:disable Naming/MemoizedInstanceVariableName
31
- enabled: false,
32
- sampling_features: nil
31
+ enabled: false, # Boolean
32
+ sampling_features: nil # Contrast::Api::Settings::Sampling
33
33
  }
34
34
  end
35
35
 
@@ -41,7 +41,7 @@ module Contrast
41
41
 
42
42
  def application_state
43
43
  @application_state ||= { # rubocop:disable Naming/MemoizedInstanceVariableName
44
- modes_by_id: Hash.new(:NO_ACTION),
44
+ modes_by_id: Hash.new(Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION),
45
45
  exclusion_matchers: [],
46
46
  disabled_assess_rules: []
47
47
  }
@@ -95,6 +95,7 @@ module Contrast
95
95
  exclusion_matchers.select(&:code?)
96
96
  end
97
97
 
98
+ # @param server_features [Contrast::Api::Settings::ServerFeatures]
98
99
  def update_from_server_features server_features
99
100
  # protect
100
101
 
@@ -109,6 +110,7 @@ module Contrast
109
110
  Contrast::Utils::Assess::SamplingUtil.instance.update
110
111
  end
111
112
 
113
+ # @param application_settings [Contrast::Api::Settings::ApplicationSettings]
112
114
  def update_from_application_settings application_settings
113
115
  application_state.merge!(application_settings.application_state_translation)
114
116
  end
@@ -126,9 +128,8 @@ module Contrast
126
128
  end
127
129
 
128
130
  def build_assess_rules
131
+ # TODO: RUBY-1120 actually build assess_rules.
129
132
  @assess_rules = {}
130
-
131
- Contrast::Agent::Assess::Rule::Redos.new
132
133
  end
133
134
 
134
135
  def build_protect_rules