contrast-agent 6.0.0 → 6.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) 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_basic_object/cs__assess_basic_object.c +5 -1
  6. data/ext/cs__assess_regexp/cs__assess_regexp.c +15 -2
  7. data/ext/cs__assess_regexp/cs__assess_regexp.h +2 -0
  8. data/ext/cs__assess_string/cs__assess_string.c +8 -0
  9. data/ext/cs__assess_test/cs__assess_test.h +9 -0
  10. data/ext/cs__assess_test/cs__assess_tests.c +22 -0
  11. data/ext/cs__assess_test/extconf.rb +5 -0
  12. data/ext/cs__common/cs__common.c +101 -0
  13. data/ext/cs__common/cs__common.h +29 -5
  14. data/ext/cs__contrast_patch/cs__contrast_patch.c +1 -1
  15. data/ext/cs__tests/cs__tests.c +12 -0
  16. data/ext/cs__tests/cs__tests.h +3 -0
  17. data/ext/cs__tests/extconf.rb +5 -0
  18. data/ext/extconf_common.rb +1 -1
  19. data/lib/contrast/agent/assess/contrast_object.rb +16 -16
  20. data/lib/contrast/agent/assess/events/source_event.rb +17 -19
  21. data/lib/contrast/agent/assess/finalizers/hash.rb +2 -2
  22. data/lib/contrast/agent/assess/policy/policy.rb +9 -10
  23. data/lib/contrast/agent/assess/policy/policy_node.rb +9 -10
  24. data/lib/contrast/agent/assess/policy/policy_scanner.rb +2 -16
  25. data/lib/contrast/agent/assess/policy/propagation_method.rb +3 -3
  26. data/lib/contrast/agent/assess/policy/propagation_node.rb +2 -3
  27. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  28. data/lib/contrast/agent/assess/policy/propagator/buffer.rb +2 -1
  29. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
  30. data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
  31. data/lib/contrast/agent/assess/policy/propagator/split.rb +17 -21
  32. data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
  33. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  34. data/lib/contrast/agent/assess/policy/trigger_method.rb +10 -18
  35. data/lib/contrast/agent/assess/policy/trigger_node.rb +16 -16
  36. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  37. data/lib/contrast/agent/assess/property/evented.rb +2 -2
  38. data/lib/contrast/agent/assess/property/tagged.rb +2 -2
  39. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +6 -8
  40. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +6 -7
  41. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +12 -7
  42. data/lib/contrast/agent/assess/rule/response/base_rule.rb +13 -6
  43. data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +66 -43
  44. data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +4 -4
  45. data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +6 -6
  46. data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +4 -4
  47. data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +4 -4
  48. data/lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb +4 -4
  49. data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +3 -4
  50. data/lib/contrast/agent/assess/tag.rb +13 -14
  51. data/lib/contrast/agent/at_exit_hook.rb +12 -1
  52. data/lib/contrast/agent/inventory/database_config.rb +22 -7
  53. data/lib/contrast/agent/middleware.rb +9 -6
  54. data/lib/contrast/agent/patching/policy/after_load_patch.rb +3 -5
  55. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +2 -2
  56. data/lib/contrast/agent/patching/policy/method_policy_extend.rb +4 -4
  57. data/lib/contrast/agent/patching/policy/patch.rb +20 -19
  58. data/lib/contrast/agent/patching/policy/patch_status.rb +10 -3
  59. data/lib/contrast/agent/patching/policy/patcher.rb +1 -1
  60. data/lib/contrast/agent/patching/policy/policy.rb +13 -15
  61. data/lib/contrast/agent/patching/policy/policy_node.rb +19 -21
  62. data/lib/contrast/agent/patching/policy/trigger_node.rb +1 -1
  63. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +126 -122
  64. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -2
  65. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +1 -1
  66. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
  67. data/lib/contrast/agent/protect/policy/rule_applicator.rb +4 -4
  68. data/lib/contrast/agent/protect/rule/base.rb +30 -18
  69. data/lib/contrast/agent/protect/rule/base_service.rb +31 -14
  70. data/lib/contrast/agent/protect/rule/cmd_injection.rb +16 -9
  71. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +3 -3
  72. data/lib/contrast/agent/protect/rule/default_scanner.rb +2 -1
  73. data/lib/contrast/agent/protect/rule/deserialization.rb +18 -7
  74. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +74 -74
  75. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +71 -53
  76. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +3 -3
  77. data/lib/contrast/agent/protect/rule/no_sqli.rb +15 -16
  78. data/lib/contrast/agent/protect/rule/path_traversal.rb +13 -3
  79. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -2
  80. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +1 -1
  81. data/lib/contrast/agent/protect/rule/sqli.rb +16 -23
  82. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +61 -61
  83. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +29 -29
  84. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +32 -32
  85. data/lib/contrast/agent/protect/rule/xss.rb +17 -0
  86. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +14 -13
  87. data/lib/contrast/agent/protect/rule/xxe.rb +25 -3
  88. data/lib/contrast/agent/reaction_processor.rb +1 -1
  89. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +36 -36
  90. data/lib/contrast/agent/reporting/masker/masker.rb +18 -21
  91. data/lib/contrast/agent/reporting/masker/masker_utils.rb +10 -6
  92. data/lib/contrast/agent/reporting/reporter.rb +11 -16
  93. data/lib/contrast/agent/reporting/reporter_heartbeat.rb +49 -0
  94. data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +6 -2
  95. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +51 -0
  96. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +96 -0
  97. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +70 -0
  98. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +182 -0
  99. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +56 -0
  100. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +22 -0
  101. data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +70 -0
  102. data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +6 -2
  103. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +60 -0
  104. data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +27 -0
  105. data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +15 -11
  106. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +7 -12
  107. data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +1 -1
  108. data/lib/contrast/agent/reporting/reporting_events/finding.rb +9 -3
  109. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +2 -4
  110. data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +3 -3
  111. data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +6 -2
  112. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +7 -3
  113. data/lib/contrast/agent/reporting/reporting_events/poll.rb +6 -2
  114. data/lib/contrast/agent/reporting/reporting_events/preflight.rb +10 -8
  115. data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +6 -10
  116. data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +12 -20
  117. data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +27 -0
  118. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +17 -27
  119. data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +38 -0
  120. data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +8 -0
  121. data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
  122. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -2
  123. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +15 -10
  124. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +54 -67
  125. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +17 -7
  126. data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +9 -6
  127. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +17 -17
  128. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +47 -32
  129. data/lib/contrast/agent/reporting/settings/application_settings.rb +1 -1
  130. data/lib/contrast/agent/reporting/settings/assess.rb +5 -5
  131. data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +3 -3
  132. data/lib/contrast/agent/reporting/settings/exclusions.rb +3 -3
  133. data/lib/contrast/agent/reporting/settings/protect.rb +21 -6
  134. data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +6 -6
  135. data/lib/contrast/agent/reporting/settings/reaction.rb +3 -3
  136. data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +2 -2
  137. data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +2 -2
  138. data/lib/contrast/agent/reporting/settings/server_features.rb +2 -2
  139. data/lib/contrast/agent/request.rb +5 -5
  140. data/lib/contrast/agent/request_context.rb +23 -19
  141. data/lib/contrast/agent/request_context_extend.rb +11 -24
  142. data/lib/contrast/agent/request_handler.rb +4 -4
  143. data/lib/contrast/agent/response.rb +2 -0
  144. data/lib/contrast/agent/rule_set.rb +2 -2
  145. data/lib/contrast/agent/scope.rb +1 -1
  146. data/lib/contrast/agent/service_heartbeat.rb +6 -48
  147. data/lib/contrast/agent/static_analysis.rb +1 -1
  148. data/lib/contrast/agent/telemetry/base.rb +155 -0
  149. data/lib/contrast/agent/telemetry/events/event.rb +35 -0
  150. data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +119 -0
  151. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +44 -36
  152. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +29 -21
  153. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +91 -73
  154. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +62 -44
  155. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +50 -33
  156. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +20 -0
  157. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions_report.rb +30 -0
  158. data/lib/contrast/agent/telemetry/events/metric_event.rb +28 -0
  159. data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +123 -0
  160. data/lib/contrast/agent/thread_watcher.rb +52 -68
  161. data/lib/contrast/agent/version.rb +1 -1
  162. data/lib/contrast/agent/worker_thread.rb +8 -0
  163. data/lib/contrast/agent.rb +1 -3
  164. data/lib/contrast/api/communication/messaging_queue.rb +29 -12
  165. data/lib/contrast/api/communication/response_processor.rb +7 -10
  166. data/lib/contrast/api/communication/service_lifecycle.rb +1 -1
  167. data/lib/contrast/api/communication/socket.rb +1 -1
  168. data/lib/contrast/api/communication/socket_client.rb +1 -1
  169. data/lib/contrast/api/communication/speedracer.rb +3 -3
  170. data/lib/contrast/api/decorators/activity.rb +33 -0
  171. data/lib/contrast/api/decorators/agent_startup.rb +10 -9
  172. data/lib/contrast/api/decorators/application_settings.rb +1 -1
  173. data/lib/contrast/api/decorators/application_startup.rb +4 -4
  174. data/lib/contrast/api/decorators/http_request.rb +1 -1
  175. data/lib/contrast/api/decorators/response_type.rb +4 -17
  176. data/lib/contrast/components/agent.rb +1 -1
  177. data/lib/contrast/components/base.rb +1 -1
  178. data/lib/contrast/components/config.rb +19 -28
  179. data/lib/contrast/components/contrast_service.rb +13 -1
  180. data/lib/contrast/components/sampling.rb +1 -1
  181. data/lib/contrast/components/settings.rb +58 -24
  182. data/lib/contrast/config/agent_configuration.rb +21 -11
  183. data/lib/contrast/config/api_configuration.rb +12 -8
  184. data/lib/contrast/config/api_proxy_configuration.rb +7 -3
  185. data/lib/contrast/config/application_configuration.rb +15 -11
  186. data/lib/contrast/config/assess_configuration.rb +13 -9
  187. data/lib/contrast/config/assess_rules_configuration.rb +6 -2
  188. data/lib/contrast/config/base_configuration.rb +3 -35
  189. data/lib/contrast/config/certification_configuration.rb +9 -5
  190. data/lib/contrast/config/exception_configuration.rb +10 -7
  191. data/lib/contrast/config/heap_dump_configuration.rb +13 -9
  192. data/lib/contrast/config/inventory_configuration.rb +9 -6
  193. data/lib/contrast/config/logger_configuration.rb +9 -6
  194. data/lib/contrast/config/protect_configuration.rb +9 -6
  195. data/lib/contrast/config/protect_rule_configuration.rb +12 -8
  196. data/lib/contrast/config/protect_rules_configuration.rb +19 -18
  197. data/lib/contrast/config/request_audit_configuration.rb +10 -7
  198. data/lib/contrast/config/root_configuration.rb +29 -12
  199. data/lib/contrast/config/ruby_configuration.rb +14 -11
  200. data/lib/contrast/config/sampling_configuration.rb +11 -8
  201. data/lib/contrast/config/server_configuration.rb +13 -9
  202. data/lib/contrast/config/service_configuration.rb +14 -11
  203. data/lib/contrast/configuration.rb +23 -14
  204. data/lib/contrast/extension/assess/array.rb +1 -1
  205. data/lib/contrast/extension/assess/erb.rb +1 -1
  206. data/lib/contrast/extension/assess/marshal.rb +1 -1
  207. data/lib/contrast/extension/assess/string.rb +1 -1
  208. data/lib/contrast/extension/extension.rb +2 -2
  209. data/lib/contrast/framework/base_support.rb +8 -8
  210. data/lib/contrast/framework/grape/support.rb +3 -3
  211. data/lib/contrast/framework/manager.rb +5 -5
  212. data/lib/contrast/framework/manager_extend.rb +1 -1
  213. data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
  214. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +14 -3
  215. data/lib/contrast/framework/rails/patch/assess_configuration.rb +3 -3
  216. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
  217. data/lib/contrast/framework/rails/patch/support.rb +14 -46
  218. data/lib/contrast/framework/rails/support.rb +2 -2
  219. data/lib/contrast/framework/sinatra/support.rb +1 -1
  220. data/lib/contrast/logger/aliased_logging.rb +94 -0
  221. data/lib/contrast/logger/application.rb +0 -4
  222. data/lib/contrast/logger/cef_log.rb +14 -14
  223. data/lib/contrast/logger/format.rb +1 -1
  224. data/lib/contrast/logger/log.rb +8 -8
  225. data/lib/contrast/tasks/config.rb +30 -21
  226. data/lib/contrast/tasks/service.rb +2 -2
  227. data/lib/contrast/utils/assess/tracking_util.rb +4 -4
  228. data/lib/contrast/utils/class_util.rb +6 -10
  229. data/lib/contrast/utils/findings.rb +3 -3
  230. data/lib/contrast/utils/hash_digest.rb +6 -7
  231. data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
  232. data/lib/contrast/utils/invalid_configuration_util.rb +2 -2
  233. data/lib/contrast/utils/log_utils.rb +6 -4
  234. data/lib/contrast/utils/lru_cache.rb +1 -1
  235. data/lib/contrast/utils/metrics_hash.rb +1 -1
  236. data/lib/contrast/utils/middleware_utils.rb +6 -6
  237. data/lib/contrast/utils/net_http_base.rb +4 -4
  238. data/lib/contrast/utils/object_share.rb +1 -1
  239. data/lib/contrast/utils/os.rb +1 -1
  240. data/lib/contrast/utils/patching/policy/patch_utils.rb +2 -2
  241. data/lib/contrast/utils/request_utils.rb +2 -2
  242. data/lib/contrast/utils/sha256_builder.rb +4 -4
  243. data/lib/contrast/utils/stack_trace_utils.rb +31 -13
  244. data/lib/contrast/utils/telemetry.rb +22 -7
  245. data/lib/contrast/utils/telemetry_client.rb +27 -15
  246. data/lib/contrast/utils/telemetry_hash.rb +41 -0
  247. data/lib/contrast/utils/telemetry_identifier.rb +18 -3
  248. data/lib/contrast/utils/timer.rb +1 -1
  249. data/lib/contrast.rb +9 -0
  250. data/resources/assess/policy.json +1 -1
  251. data/ruby-agent.gemspec +1 -1
  252. data/service_executables/VERSION +1 -1
  253. data/service_executables/linux/contrast-service +0 -0
  254. data/service_executables/mac/contrast-service +0 -0
  255. metadata +41 -16
  256. data/lib/contrast/agent/telemetry/events/metric_telemetry_event.rb +0 -26
  257. data/lib/contrast/agent/telemetry/events/startup_metrics_telemetry_event.rb +0 -121
  258. data/lib/contrast/agent/telemetry/events/telemetry_event.rb +0 -33
  259. data/lib/contrast/agent/telemetry/telemetry.rb +0 -150
  260. data/lib/contrast/utils/exclude_key.rb +0 -20
@@ -3,9 +3,10 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # logging in the Agent.
8
- class LoggerConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the logging in the Agent.
7
+ class LoggerConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  # @return [String, nil]
10
11
  attr_accessor :path
11
12
  # @return [String, nil]
@@ -14,9 +15,11 @@ module Contrast
14
15
  attr_accessor :progname
15
16
 
16
17
  def initialize hsh = {}
17
- @path = traverse_config(hsh, :path)
18
- @level = traverse_config(hsh, :level)
19
- @progname = traverse_config(hsh, :progname)
18
+ return unless hsh
19
+
20
+ @path = hsh[:path]
21
+ @level = hsh[:level]
22
+ @progname = hsh[:progname]
20
23
  end
21
24
  end
22
25
  end
@@ -3,17 +3,20 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # protect functionality of the Agent.
8
- class ProtectConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the protect functionality of the Agent.
7
+ class ProtectConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  # @return [Boolean, nil]
10
11
  attr_accessor :enable
11
12
  attr_writer :exceptions, :rules
12
13
 
13
14
  def initialize hsh = {}
14
- @exceptions = Contrast::Config::ExceptionConfiguration.new(traverse_config(hsh, :exceptions))
15
- @rules = Contrast::Config::ProtectRulesConfiguration.new(traverse_config(hsh, :rules))
16
- @enable = traverse_config(hsh, :enable)
15
+ return unless hsh
16
+
17
+ @exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
18
+ @rules = Contrast::Config::ProtectRulesConfiguration.new(hsh[:rules])
19
+ @enable = hsh[:enable]
17
20
  end
18
21
 
19
22
  # @return [Contrast::Config::ExceptionConfiguration]
@@ -5,22 +5,26 @@ require 'set'
5
5
 
6
6
  module Contrast
7
7
  module Config
8
- # Common Configuration settings. Those in this section pertain to the
9
- # rule mode of a single protect rule in the Agent.
10
- class ProtectRuleConfiguration < BaseConfiguration
8
+ # Common Configuration settings. Those in this section pertain to the rule mode of a single protect rule in the
9
+ # Agent.
10
+ class ProtectRuleConfiguration
11
+ include Contrast::Config::BaseConfiguration
12
+
11
13
  # @return [Boolean, nil]
12
14
  attr_accessor :enable
13
15
  # @return [String, nil]
14
16
  attr_accessor :mode
15
- # @retrun [Boolean, nil]
17
+ # @return [Boolean, nil]
16
18
  attr_accessor :disable_system_commands
17
19
  attr_writer :detect_custom_code_accessing_system_files
18
20
 
19
21
  def initialize hsh = {}
20
- @enable = traverse_config(hsh, :enable)
21
- @mode = traverse_config(hsh, :mode)
22
- @disable_system_commands = traverse_config(hsh, :disable_system_commands)
23
- @detect_custom_code_accessing_system_files = traverse_config(hsh, :detect_custom_code_accessing_system_files)
22
+ return unless hsh
23
+
24
+ @enable = hsh[:enable]
25
+ @mode = hsh[:mode]
26
+ @disable_system_commands = hsh[:disable_system_commands]
27
+ @detect_custom_code_accessing_system_files = hsh[:detect_custom_code_accessing_system_files]
24
28
  end
25
29
 
26
30
  # @return [Boolean, true]
@@ -5,30 +5,31 @@ require 'contrast/config/protect_rule_configuration'
5
5
 
6
6
  module Contrast
7
7
  module Config
8
- # Common Configuration settings. Those in this section pertain to the
9
- # protect rule modes of the Agent.
10
- class ProtectRulesConfiguration < BaseConfiguration
8
+ # Common Configuration settings. Those in this section pertain to the protect rule modes of the Agent.
9
+ class ProtectRulesConfiguration
10
+ include Contrast::Config::BaseConfiguration
11
+
11
12
  attr_accessor :disabled_rules
12
13
  attr_writer :bot_blocker, :cmd_injection, :sql_injection, :nosql_injection, :untrusted_deserialization,
13
- :method_tampering, :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
14
+ :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
14
15
 
15
16
  BASE_RULE = 'Contrast::Agent::Protect::Rule::Base'.cs__freeze
16
17
 
17
18
  def initialize hsh = {}
18
- @disabled_rules = traverse_config(hsh, :disabled_rules)
19
- @bot_blocker = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'bot-blocker'))
20
- @cmd_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'cmd-injection'))
21
- @sql_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'sql-injection'))
22
- @nosql_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'nosql-injection'))
23
- @untrusted_deserialization = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(
24
- hsh,
25
- 'untrusted-deserialization'))
26
- @method_tampering = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'method-tampering'))
27
- @xxe = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, :xxe))
28
- @path_traversal = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'path-traversal'))
29
- @reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'reflected-xss'))
30
- @unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'unsafe-file-upload'))
31
- @rule_base = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, BASE_RULE))
19
+ return unless hsh
20
+
21
+ @disabled_rules = hsh[:disabled_rules]
22
+ @rule_base = Contrast::Config::ProtectRuleConfiguration.new(hsh[BASE_RULE.to_sym])
23
+ @bot_blocker = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'bot-blocker'])
24
+ @cmd_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'cmd-injection'])
25
+ @method_tampering = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'method-tampering'])
26
+ @nosql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'nosql-injection'])
27
+ @path_traversal = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'path-traversal'])
28
+ @reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'reflected-xss'])
29
+ @sql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'sql-injection'])
30
+ @unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'unsafe-file-upload'])
31
+ @untrusted_deserialization = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'untrusted-deserialization'])
32
+ @xxe = Contrast::Config::ProtectRuleConfiguration.new(hsh[:xxe])
32
33
  end
33
34
 
34
35
  def bot_blocker
@@ -3,18 +3,21 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # This class holds the Common Settings for the
7
- # hidden functionality of the TS
8
- class RequestAuditConfiguration < BaseConfiguration
6
+ # This class holds the Common Settings for the hidden functionality of the TS
7
+ class RequestAuditConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  DEFAULT_PATH = './messages'
10
11
 
11
12
  attr_writer :enable, :requests, :responses, :path
12
13
 
13
14
  def initialize hsh = {}
14
- @enable = traverse_config(hsh, :enable)
15
- @requests = traverse_config(hsh, :requests)
16
- @responses = traverse_config(hsh, :responses)
17
- @path = traverse_config(hsh, :path)
15
+ return unless hsh
16
+
17
+ @enable = hsh[:enable]
18
+ @requests = hsh[:requests]
19
+ @responses = hsh[:responses]
20
+ @path = hsh[:path]
18
21
  end
19
22
 
20
23
  # @return [Boolean, false]
@@ -4,23 +4,40 @@
4
4
  module Contrast
5
5
  module Config
6
6
  # The base of the Common Configuration settings.
7
- class RootConfiguration < BaseConfiguration
8
- attr_writer :api, :agent, :application, :server, :assess, :inventory, :protect, :service
7
+ class RootConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
10
+ # @return [Contrast::Config::ApiConfiguration]
11
+ attr_writer :api
12
+ # @return [Contrast::Config::AgentConfiguration]
13
+ attr_writer :agent
14
+ # @return [Contrast::Config::ApplicationConfiguration]
15
+ attr_writer :application
16
+ # @return [Contrast::Config::ServerConfiguration]
17
+ attr_writer :server
18
+ # @return [Contrast::Config::AssessConfiguration]
19
+ attr_writer :assess
20
+ # @return [Contrast::Config::InventoryConfiguration]
21
+ attr_writer :inventory
22
+ # @return [Contrast::Config::ProtectConfiguration]
23
+ attr_writer :protect
24
+ # @return [Contrast::Config::ServiceConfiguration]
25
+ attr_writer :service
9
26
  # @return [Boolean, nil]
10
27
  attr_accessor :enable
11
28
 
12
29
  def initialize hsh = {}
13
- raise ArgumentError, 'Expected a hash' unless hsh.is_a?(Hash)
30
+ raise(ArgumentError, 'Expected a hash') unless hsh.is_a?(Hash)
14
31
 
15
- @api = Contrast::Config::ApiConfiguration.new(traverse_config(hsh, :api))
16
- @enable = traverse_config(hsh, :enable)
17
- @agent = Contrast::Config::AgentConfiguration.new(traverse_config(hsh, :agent))
18
- @application = Contrast::Config::ApplicationConfiguration.new(traverse_config(hsh, :application))
19
- @server = Contrast::Config::ServerConfiguration.new(traverse_config(hsh, :server))
20
- @assess = Contrast::Config::AssessConfiguration.new(traverse_config(hsh, :assess))
21
- @inventory = Contrast::Config::InventoryConfiguration.new(traverse_config(hsh, :inventory))
22
- @protect = Contrast::Config::ProtectConfiguration.new(traverse_config(hsh, :protect))
23
- @service = Contrast::Config::ServiceConfiguration.new(traverse_config(hsh, :service))
32
+ @api = Contrast::Config::ApiConfiguration.new(hsh[:api])
33
+ @enable = hsh[:enable]
34
+ @agent = Contrast::Config::AgentConfiguration.new(hsh[:agent])
35
+ @application = Contrast::Config::ApplicationConfiguration.new(hsh[:application])
36
+ @server = Contrast::Config::ServerConfiguration.new(hsh[:server])
37
+ @assess = Contrast::Config::AssessConfiguration.new(hsh[:assess])
38
+ @inventory = Contrast::Config::InventoryConfiguration.new(hsh[:inventory])
39
+ @protect = Contrast::Config::ProtectConfiguration.new(hsh[:protect])
40
+ @service = Contrast::Config::ServiceConfiguration.new(hsh[:service])
24
41
  end
25
42
 
26
43
  # @return [Contrast::Config::ApiConfiguration]
@@ -3,9 +3,10 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # specific settings that apply to Ruby
8
- class RubyConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the specific settings that apply to Ruby
7
+ class RubyConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  DISABLED_RAKE_TASK_LIST = %w[
10
11
  about assets:clean assets:clobber assets:environment
11
12
  assets:precompile assets:precompile:all db:create db:drop db:fixtures:load db:migrate
@@ -23,14 +24,16 @@ module Contrast
23
24
  :track_frozen_sources, :non_request_tracking, :uninstrument_namespace
24
25
 
25
26
  def initialize hsh = {}
26
- @disabled_agent_rake_tasks = traverse_config(hsh, :disabled_agent_rake_tasks)
27
- @exceptions = Contrast::Config::ExceptionConfiguration.new(traverse_config(hsh, :exceptions))
28
- @interpolate = traverse_config(hsh, :interpolate)
29
- @propagate_yield = traverse_config(hsh, :propagate_yield)
30
- @require_scan = traverse_config(hsh, :require_scan)
31
- @track_frozen_sources = traverse_config(hsh, :track_frozen_sources)
32
- @non_request_tracking = traverse_config(hsh, :non_request_tracking)
33
- @uninstrument_namespace = traverse_config(hsh, :uninstrument_namespace)
27
+ return unless hsh
28
+
29
+ @disabled_agent_rake_tasks = hsh[:disabled_agent_rake_tasks]
30
+ @exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
31
+ @interpolate = hsh[:interpolate]
32
+ @propagate_yield = hsh[:propagate_yield]
33
+ @require_scan = hsh[:require_scan]
34
+ @track_frozen_sources = hsh[:track_frozen_sources]
35
+ @non_request_tracking = hsh[:non_request_tracking]
36
+ @uninstrument_namespace = hsh[:uninstrument_namespace]
34
37
  end
35
38
 
36
39
  # These commands being detected will result the agent disabling instrumentation, generally any command
@@ -3,9 +3,10 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # sampling functionality of the Agent.
8
- class SamplingConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the sampling functionality of the Agent.
7
+ class SamplingConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  # @return [Integer, nil]
10
11
  attr_reader :baseline
11
12
  # @return [Integer, nil]
@@ -16,11 +17,13 @@ module Contrast
16
17
  attr_reader :window_ms
17
18
 
18
19
  def initialize hsh = {}
19
- @enable = traverse_config(hsh, :enable)
20
- @baseline = traverse_config(hsh, :baseline)
21
- @request_frequency = traverse_config(hsh, :request_frequency)
22
- @response_frequency = traverse_config(hsh, :response_frequency)
23
- @window_ms = traverse_config(hsh, :window_ms)
20
+ return unless hsh
21
+
22
+ @enable = hsh[:enable]
23
+ @baseline = hsh[:baseline]
24
+ @request_frequency = hsh[:request_frequency]
25
+ @response_frequency = hsh[:response_frequency]
26
+ @window_ms = hsh[:window_ms]
24
27
  end
25
28
 
26
29
  # @return [Boolean, false]
@@ -3,9 +3,11 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # server identification functionality of the Agent.
8
- class ServerConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the server identification functionality of the
7
+ # Agent.
8
+ class ServerConfiguration
9
+ include Contrast::Config::BaseConfiguration
10
+
9
11
  # @return [String, nil]
10
12
  attr_accessor :name
11
13
  # @return [String, nil]
@@ -20,12 +22,14 @@ module Contrast
20
22
  attr_accessor :version
21
23
 
22
24
  def initialize hsh = {}
23
- @path = traverse_config(hsh, :path)
24
- @name = traverse_config(hsh, :name)
25
- @type = traverse_config(hsh, :type)
26
- @tags = traverse_config(hsh, :tags)
27
- @environment = traverse_config(hsh, :environment)
28
- @version = traverse_config(hsh, :version)
25
+ return unless hsh
26
+
27
+ @path = hsh[:path]
28
+ @name = hsh[:name]
29
+ @type = hsh[:type]
30
+ @tags = hsh[:tags]
31
+ @environment = hsh[:environment]
32
+ @version = hsh[:version]
29
33
  end
30
34
  end
31
35
  end
@@ -5,11 +5,12 @@ require 'contrast/config/logger_configuration'
5
5
 
6
6
  module Contrast
7
7
  module Config
8
- # Common Configuration settings. Those in this section pertain to the
9
- # communication between the Agent & the Service.
10
- class ServiceConfiguration < BaseConfiguration
11
- # We don't set these b/c we've been asked to handle the default values of
12
- # these settings differently, logging when we have to use them.
8
+ # Common Configuration settings. Those in this section pertain to the communication between the Agent & the Service
9
+ class ServiceConfiguration
10
+ include Contrast::Config::BaseConfiguration
11
+
12
+ # We don't set these b/c we've been asked to handle the default values of these settings differently, logging
13
+ # when we have to use them.
13
14
  DEFAULT_HOST = '127.0.0.1' # rubocop:disable Style/IpAddresses
14
15
  DEFAULT_PORT = '30555'
15
16
 
@@ -24,12 +25,14 @@ module Contrast
24
25
  attr_accessor :enable
25
26
 
26
27
  def initialize hsh = {}
27
- @enable = traverse_config(hsh, :enable)
28
- @host = traverse_config(hsh, :host)
29
- @port = traverse_config(hsh, :port)
30
- @socket = traverse_config(hsh, :socket)
31
- @logger = Contrast::Config::LoggerConfiguration.new(traverse_config(hsh, :logger))
32
- @bypass = traverse_config(hsh, :bypass)
28
+ return unless hsh
29
+
30
+ @enable = hsh[:enable]
31
+ @host = hsh[:host]
32
+ @port = hsh[:port]
33
+ @socket = hsh[:socket]
34
+ @logger = Contrast::Config::LoggerConfiguration.new(hsh[:logger])
35
+ @bypass = hsh[:bypass]
33
36
  end
34
37
 
35
38
  # @return [Contrast::Config::LoggerConfiguration]
@@ -7,7 +7,6 @@ require 'fileutils'
7
7
  require 'contrast/config'
8
8
  require 'contrast/utils/object_share'
9
9
  require 'contrast/components/scope'
10
- require 'contrast/utils/exclude_key'
11
10
 
12
11
  module Contrast
13
12
  # This is how we read in the local settings for the Agent, both ENV/ CMD line
@@ -27,15 +26,17 @@ module Contrast
27
26
  MILLISECOND_MARKER = '_ms'
28
27
  CONVERSION = { 'agent.service.enable' => 'agent.start_bundled_service' }.cs__freeze
29
28
  CONFIG_BASE_PATHS = ['', 'config/', '/etc/contrast/ruby/', '/etc/contrast/', '/etc/'].cs__freeze
29
+ KEYS_TO_REDACT = %i[api_key url service_key user_name].cs__freeze
30
+ REDACTED = '**REDACTED**'
30
31
 
31
32
  def initialize cli_options = nil, default_name = DEFAULT_YAML_PATH
32
33
  @default_name = default_name
33
34
 
34
35
  # Load config_kv from file
35
- config_kv = deep_stringify_all_keys(load_config)
36
+ config_kv = deep_symbolize_all_keys(load_config)
36
37
 
37
38
  # Overlay CLI options - they take precedence over config file
38
- cli_options = deep_stringify_all_keys(cli_options)
39
+ cli_options = deep_symbolize_all_keys(cli_options)
39
40
  config_kv = deep_merge(cli_options, config_kv) if cli_options
40
41
 
41
42
  # Some in-flight rewrites to maintain backwards compatibility
@@ -93,7 +94,7 @@ module Contrast
93
94
  rescue Psych::Exception => e
94
95
  log_yaml_parse_error(path, e)
95
96
  rescue RuntimeError => e
96
- puts "WARN: Unable to load configuration. #{ e }; path: #{ path }, pwd: #{ Dir.pwd }"
97
+ puts("WARN: Unable to load configuration. #{ e }; path: #{ path }, pwd: #{ Dir.pwd }")
97
98
  end
98
99
  end
99
100
 
@@ -105,7 +106,7 @@ module Contrast
105
106
  def update_prop_keys config
106
107
  CONVERSION.each_pair do |old_method, new_method|
107
108
  # See if the old value was set and needs to be translated
108
- deprecated_keys = old_method.split('.')
109
+ deprecated_keys = old_method.split('.').map(&:to_sym)
109
110
  old_value = config
110
111
  deprecated_keys.each do |key|
111
112
  old_value = old_value[key]
@@ -114,7 +115,7 @@ module Contrast
114
115
  next if old_value.nil? # have to account for literal false
115
116
 
116
117
  log_deprecated_property(old_method, new_method)
117
- new_keys = new_method.split('.')
118
+ new_keys = new_method.split('.').map(&:to_sym)
118
119
  # We changed the seconds values into ms values. Multiply them accordingly
119
120
  old_value = old_value.to_i * 1000 if new_method.end_with?(MILLISECOND_MARKER)
120
121
  new_value = config
@@ -147,12 +148,12 @@ module Contrast
147
148
  end
148
149
  end
149
150
 
150
- def deep_stringify_all_keys hash
151
+ def deep_symbolize_all_keys hash
151
152
  return if hash.nil?
152
153
 
153
154
  new_hash = {}
154
155
  hash.each do |key, value|
155
- new_hash[key.to_s] = value.is_a?(Hash) ? deep_stringify_all_keys(value) : value
156
+ new_hash[key.to_sym] = value.is_a?(Hash) ? deep_symbolize_all_keys(value) : value
156
157
  end
157
158
  new_hash
158
159
  end
@@ -181,7 +182,7 @@ module Contrast
181
182
  if logger
182
183
  logger.warn('YAML validator found an error', hash)
183
184
  else
184
- puts "CONTRAST - WARN: YAML validator found an error. #{ hash.inspect }"
185
+ puts("CONTRAST - WARN: YAML validator found an error. #{ hash.inspect }")
185
186
  end
186
187
  end
187
188
 
@@ -189,7 +190,7 @@ module Contrast
189
190
  if logger
190
191
  logger.warn('Configuration file is not readable by current user', path: path)
191
192
  else
192
- puts "CONTRAST - WARN: Configuration file is not readable by current user; path: #{ path }"
193
+ puts("CONTRAST - WARN: Configuration file is not readable by current user; path: #{ path }")
193
194
  end
194
195
  end
195
196
 
@@ -197,7 +198,7 @@ module Contrast
197
198
  if logger
198
199
  logger.warn('Deprecated property in use', old_method: old_method, new_method: new_method)
199
200
  else
200
- puts "CONTRAST - WARN: Deprecated property in use; old_method: #{ old_method }, new_method: #{ new_method }"
201
+ puts("CONTRAST - WARN: Deprecated property in use; old_method: #{ old_method }, new_method: #{ new_method }")
201
202
  end
202
203
  end
203
204
 
@@ -219,10 +220,9 @@ module Contrast
219
220
  when Contrast::Config::BaseConfiguration
220
221
  # to_hash returns @configuration_map
221
222
  convert.to_hash.each_key do |key|
222
- next if Contrast::Utils::ExcludeKey.excludable?(key.to_s)
223
-
224
223
  # change '-' to '_' for ProtectRulesConfiguration
225
224
  hash[key] = convert_to_hash(convert.send(key.tr('-', '_').to_sym), {})
225
+ hash[key] = REDACTED if redactable?(key)
226
226
  end
227
227
  hash
228
228
  else
@@ -234,7 +234,7 @@ module Contrast
234
234
  idx = 0
235
235
  end_idx = new_keys.length - 1
236
236
  while idx < new_keys.length
237
- new_key = new_keys[idx]
237
+ new_key = new_keys[idx].to_sym
238
238
  if idx == end_idx
239
239
  new_value[new_key] = old_value if new_value[new_key].nil?
240
240
  else
@@ -245,5 +245,14 @@ module Contrast
245
245
  idx += 1
246
246
  end
247
247
  end
248
+
249
+ # Check if keys with sensitive data needs to be
250
+ # redacted.
251
+ #
252
+ # @param key [Symbol] key to check
253
+ # @return[Boolean] true | false
254
+ def redactable? key
255
+ KEYS_TO_REDACT.include?(key.to_sym)
256
+ end
248
257
  end
249
258
  end
@@ -53,7 +53,7 @@ module Contrast
53
53
  return ret unless Contrast::Agent::Assess::Tracker.tracked?(ret)
54
54
 
55
55
  properties.cleanup_tags
56
- event_data = Contrast::Agent::Assess::Events::EventData.new ARRAY_JOIN_NODE, ret, ary, ret, [separator]
56
+ event_data = Contrast::Agent::Assess::Events::EventData.new(ARRAY_JOIN_NODE, ret, ary, ret, [separator])
57
57
  properties.build_event(event_data)
58
58
  properties.event.instance_variable_set(:@_parent_events, parent_events)
59
59
  ret
@@ -20,7 +20,7 @@ module ERBPropagator
20
20
 
21
21
  erb_pre_result = preshift.object.src
22
22
  parent_events = []
23
- binding_variable_set binding_variable_set, used_binding, erb_pre_result, properties, parent_events, ret
23
+ binding_variable_set(binding_variable_set, used_binding, erb_pre_result, properties, parent_events, ret)
24
24
  properties.build_event(Contrast::Agent::Assess::Events::EventData.new(patcher,
25
25
  ret,
26
26
  preshift.object,
@@ -43,7 +43,7 @@ module Contrast
43
43
  properties.copy_from(source, ret)
44
44
 
45
45
  node = Contrast::Agent::Assess::Policy::Policy.instance.find_propagator_node('Marshal', :load, false)
46
- event_data = Contrast::Agent::Assess::Events::EventData.new node, ret, self, ret, args
46
+ event_data = Contrast::Agent::Assess::Events::EventData.new(node, ret, self, ret, args)
47
47
  properties.build_event(event_data)
48
48
  rescue StandardError => e
49
49
  logger.error('Unable to run Assess for Marshal.load', e)
@@ -43,7 +43,7 @@ module Contrast
43
43
  offset = 0
44
44
  inputs.each do |input|
45
45
  properties.copy_from(input, result, offset)
46
- add_dynamic_sources_info input, result
46
+ add_dynamic_sources_info(input, result)
47
47
  offset += input.length
48
48
  parent_event = Contrast::Agent::Assess::Tracker.properties(input)&.event
49
49
  parent_events << parent_event if parent_event
@@ -37,9 +37,9 @@ module Contrast
37
37
  def assign_value path
38
38
  case path
39
39
  when /fiber/, /interpolation26/
40
- require path if Funchook.available?
40
+ require(path) if Funchook.available?
41
41
  else
42
- require path
42
+ require(path)
43
43
  end
44
44
  true
45
45
  end
@@ -7,19 +7,19 @@ module Contrast
7
7
  module BaseSupport
8
8
  # The top level module name used by the framework
9
9
  def detection_class
10
- raise NoMethodError('Subclasses of BaseSupport should implement this method')
10
+ raise(NoMethodError('Subclasses of BaseSupport should implement this method'))
11
11
  end
12
12
 
13
13
  def version
14
- raise NoMethodError('Subclasses of BaseSupport should implement this method')
14
+ raise(NoMethodError('Subclasses of BaseSupport should implement this method'))
15
15
  end
16
16
 
17
17
  def application_name
18
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
18
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
19
19
  end
20
20
 
21
21
  def server_type
22
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
22
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
23
23
  end
24
24
 
25
25
  # Find all the predefined routes for this application and append them to the
@@ -27,19 +27,19 @@ module Contrast
27
27
  # msg should be a Contrast::Api::Dtm::ApplicationUpdate or some other msg
28
28
  # that has a routes array consisting of Contrast::Api::Dtm::RouteCoverage
29
29
  def collect_routes
30
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
30
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
31
31
  end
32
32
 
33
33
  def current_route_coverage
34
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
34
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
35
35
  end
36
36
 
37
37
  def current_route
38
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
38
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
39
39
  end
40
40
 
41
41
  def retrieve_request _env
42
- raise NoMethodError, 'Subclasses of BaseSupport should implement this method'
42
+ raise(NoMethodError, 'Subclasses of BaseSupport should implement this method')
43
43
  end
44
44
 
45
45
  # Some Frameworks require specific patching for their classes to handle
@@ -112,7 +112,7 @@ module Contrast
112
112
  full_route ||= request.env[::Rack::PATH_INFO]
113
113
 
114
114
  new_route_coverage = Contrast::Agent::Reporting::RouteCoverage.new
115
- new_route_coverage.attach_rack_based_data final_controller, method, route_pattern, full_route
115
+ new_route_coverage.attach_rack_based_data(final_controller, method, route_pattern, full_route)
116
116
  end
117
117
 
118
118
  # Search object space for grape controllers--any class that subclasses ::Grape::API.
@@ -151,7 +151,7 @@ module Contrast
151
151
  # Grape controller actually has endpoints and each endpoint
152
152
  # has routes and that's why we need to do it that way
153
153
  controller = controllers.pop
154
- return _route_recurse method, route, controllers unless controller
154
+ return _route_recurse(method, route, controllers) unless controller
155
155
 
156
156
  contr_routes = controller.endpoints&.map(&:routes)&.flatten || []
157
157
  route_pattern = contr_routes&.find do |r|
@@ -159,7 +159,7 @@ module Contrast
159
159
  end
160
160
  return controller, route_pattern unless route_pattern.nil?
161
161
 
162
- _route_recurse method, route, controllers
162
+ _route_recurse(method, route, controllers)
163
163
  end
164
164
 
165
165
  # Get route and do some cleaning