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
@@ -6,25 +6,12 @@ require 'protobuf/message'
6
6
 
7
7
  module Contrast
8
8
  module Api
9
- module Decorators
10
- # Used to decorate the {Contrast::Api::Dtm::AttackResult::ResponseType} protobuf
11
- # model so it can add SUSPICIOUS.
12
- module ResponseType
13
- ::Protobuf::Enum.define(:SUSPICIOUS, 6)
14
-
15
- def self.included klass
16
- klass.extend(ClassMethods)
17
- end
18
-
19
- # Used to add class methods to the class on inclusion of the decorator
20
- module ClassMethods
21
- def build
22
- new
23
- end
9
+ module Dtm
10
+ class AttackResult < ::Protobuf::Message
11
+ class ResponseType < ::Protobuf::Enum
12
+ define :SUSPICIOUS, 6
24
13
  end
25
14
  end
26
15
  end
27
16
  end
28
17
  end
29
-
30
- Contrast::Api::Dtm::AttackResult::ResponseType.include(Contrast::Api::Decorators::ResponseType)
@@ -75,7 +75,7 @@ module Contrast
75
75
 
76
76
  # Insert ourselves into the application, keeping our middleware at the outermost layer of the onion
77
77
  def insert_middleware app
78
- app.middleware.insert_before 0, Contrast::Agent::Middleware
78
+ app.middleware.insert_before(0, Contrast::Agent::Middleware)
79
79
  end
80
80
 
81
81
  def enable_tracepoint
@@ -56,7 +56,7 @@ module Contrast
56
56
  def file_exists? path
57
57
  return false unless path
58
58
 
59
- File.exist? path
59
+ File.exist?(path)
60
60
  end
61
61
  end
62
62
  end
@@ -28,6 +28,12 @@ module Contrast
28
28
  CONTRAST_NAME = 'Contrast Agent'
29
29
 
30
30
  class Interface # :nodoc:
31
+ SESSION_VARIABLES = 'Invalid configuration. '\
32
+ "Setting both application.session_id and application.session_metadata is not allowed.\n"
33
+ API_URL = "Invalid configuration. Missing a required connection value 'url' is not set."
34
+ API_KEY = "Invalid configuration. Missing a required connection value 'api_key' is not set."
35
+ API_SERVICE_KEY = "Invalid configuration. Missing a required connection value 'service_tag' is not set."
36
+ API_USERNAME = "Invalid configuration. Missing a required connection value 'user_name' is not set."
31
37
  def initialize
32
38
  build
33
39
  end
@@ -72,14 +78,21 @@ module Contrast
72
78
  @config.loggable
73
79
  end
74
80
 
81
+ # Typically, this would be accessed through Contrast::SETTINGS, but we're specifically checking for the user
82
+ # provided value here rather than that echoed back by TeamServer.
83
+ #
84
+ # @return [String,nil] the value of the session id set in the configuration, or nil if unset
85
+ def session_id
86
+ root.application.session_id
87
+ end
88
+
89
+ # @return [String,nil] the value of the session metadata set in the configuration, or nil if unset
90
+ def session_metadata
91
+ root.application.session_metadata
92
+ end
93
+
75
94
  private
76
95
 
77
- SESSION_VARIABLES = 'Invalid configuration. '\
78
- "Setting both application.session_id and application.session_metadata is not allowed.\n"
79
- API_URL = "Invalid configuration. Missing a required connection value 'url' is not set."
80
- API_KEY = "Invalid configuration. Missing a required connection value 'api_key' is not set."
81
- API_SERVICE_KEY = "Invalid configuration. Missing a required connection value 'service_tag' is not set."
82
- API_USERNAME = "Invalid configuration. Missing a required connection value 'user_name' is not set."
83
96
  # The config has information about how to construct the logger. If the config is invalid, and you want to know
84
97
  # about it, then you have a circular dependency if you try to log it, so we use basic proto_logger to do this
85
98
  # job.
@@ -127,28 +140,6 @@ module Contrast
127
140
  end
128
141
  end
129
142
 
130
- # Typically, this would be accessed through
131
- # Contrast::Components::AppContext, but we're too early in the
132
- # initialization of the Agent to use that mechanism, so we look it up
133
- # directly for ourselves
134
- #
135
- # @return [String,nil] the value of the session id set in the
136
- # configuration, or nil if unset
137
- def session_id
138
- root.application.session_id
139
- end
140
-
141
- # Typically, this would be accessed through
142
- # Contrast::Components::AppContext, but we're too early in the
143
- # initialization of the Agent to use that mechanism, so we look it up
144
- # directly for ourselves
145
- #
146
- # @return [String,nil] the value of the session metadata set in the
147
- # configuration, or nil if unset
148
- def session_metadata
149
- root.application.session_metadata
150
- end
151
-
152
143
  # Typically, the following values would be accessed through Contrast::Components::AppContext
153
144
  # and Contrast::Components::API, but we're too early in the initialization of the Agent to use
154
145
  # that mechanism, so we look it up directly for ourselves.
@@ -18,7 +18,10 @@ module Contrast
18
18
  DEFAULT_SERVICE_LEVEL = :TRACE
19
19
  # The Rails ActionDispatch regexp for localhost IP + literal localhost
20
20
  # https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb#L32
21
- LOCALHOST = Regexp.union [/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, /^::1$/, /^0:0:0:0:0:0:0:1(%.*)?$/, /^localhost$/]
21
+ LOCALHOST = Regexp.union([
22
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, /^::1$/, /^0:0:0:0:0:0:0:1(%.*)?$/,
23
+ /^localhost$/
24
+ ])
22
25
 
23
26
  def use_bundled_service?
24
27
  # Validates the config to decide if it's suitable for starting
@@ -38,6 +41,15 @@ module Contrast
38
41
  @_use_agent_communication = true?(::Contrast::CONFIG.root.agent.service.bypass)
39
42
  end
40
43
 
44
+ # If we're using the agent directly and not using protect, then there is no need to start the service. Because
45
+ # we only know this at startup when hardcoded as such (b/c TS could turn protect on otherwise), we can only do
46
+ # so when bypass is on and protect is off in local config
47
+ #
48
+ # @return [Boolean]
49
+ def unnecessary?
50
+ ::Contrast::CONTRAST_SERVICE.use_agent_communication? && ::Contrast::PROTECT.forcibly_disabled?
51
+ end
52
+
41
53
  def host
42
54
  @_host ||=
43
55
  (::Contrast::CONFIG.root.agent.service.host || Contrast::Config::ServiceConfiguration::DEFAULT_HOST).to_s
@@ -25,7 +25,7 @@ module Contrast
25
25
  def sampling_control
26
26
  @_sampling_control ||= begin
27
27
  config_settings = ::Contrast::CONFIG.root.assess&.sampling
28
- settings = ::Contrast::SETTINGS&.assess_state&.[](:sampling_settings)
28
+ settings = ::Contrast::SETTINGS&.assess_state&.sampling_settings
29
29
  {
30
30
  enabled: enabled?(config_settings, settings),
31
31
  baseline: baseline(config_settings, settings),
@@ -86,6 +86,10 @@ module Contrast
86
86
  # Rules to follow when using the masking. Each rules contains Id [String]
87
87
  # and Keywords [Array<String>].
88
88
  attr_reader :sensitive_data_masking
89
+ # @return [Integer] the time, in ms, that application settings last changed
90
+ attr_reader :last_app_update_ms
91
+ # @return [Integer] the time, in ms, that server settings last changed
92
+ attr_reader :last_server_update_ms
89
93
 
90
94
  def initialize
91
95
  reset_state
@@ -95,39 +99,31 @@ module Contrast
95
99
  @application_state.exclusion_matchers.select(&:code?)
96
100
  end
97
101
 
98
- # @param features [Contrast::Api::Settings::ServerFeatures, Contrast::Agent::Reporting::Response]
99
- def update_from_server_features features
100
- if features.cs__is_a?(Contrast::Agent::Reporting::Response)
101
- server_features = features.server_features
102
- log_file = server_features.log_file
103
- log_level = server_features.log_level
104
- Contrast::Logger::Log.instance.update(log_file, log_level) if log_file || log_level
105
- @protect_state.enabled = server_features.protect.enabled?
106
- @assess_state.enabled = server_features.assess.enabled?
107
- @assess_state.sampling_settings = server_features.assess.sampling
102
+ # @param features_response [Contrast::Api::Settings::ServerFeatures, Contrast::Agent::Reporting::Response]
103
+ def update_from_server_features features_response
104
+ if features_response.cs__is_a?(Contrast::Agent::Reporting::Response)
105
+ update_from_response(features_response)
108
106
  else
109
- @protect_state.enabled = features.protect_enabled?
110
- @assess_state.enabled = features.assess_enabled?
111
- @assess_state.sampling_settings = features.assess.sampling
107
+ @protect_state.enabled = features_response.protect_enabled?
108
+ @assess_state.enabled = features_response.assess_enabled?
109
+ @assess_state.sampling_settings = features_response.assess.sampling
110
+ @last_server_update_ms = Contrast::Utils::Timer.now_ms
112
111
  end
112
+ @last_server_update_ms = Contrast::Utils::Timer.now_ms
113
113
  end
114
114
 
115
- # @param features [Contrast::Api::Settings::ApplicationSettings, Contrast::Agent::Reporting::Response]
116
- def update_from_application_settings features
117
- if features&.class == Contrast::Agent::Reporting::Response
118
- settings = features.application_settings
119
- @application_state.modes_by_id = settings.protect.protection_rules_to_settings_hash
120
- # TODO: RUBY-1438 this needs to be translated
121
- # @application_state.exclusion_matchers = new_vals[:exclusion_matchers]
122
- update_sensitive_data_policy(settings.sensitive_data_masking)
123
- @assess_state.disabled_assess_rules = settings.assess.disabled_rules
124
- @assess_state.session_id = settings.assess.session_id if settings.assess.session_id
115
+ # @param settings_response [Contrast::Api::Settings::ApplicationSettings, Contrast::Agent::Reporting::Response]
116
+ def update_from_application_settings settings_response
117
+ if settings_response&.cs__class == Contrast::Agent::Reporting::Response
118
+ update_from_response(settings_response)
125
119
  else
126
- new_vals = features.application_state_translation
120
+ new_vals = settings_response.application_state_translation
127
121
  @application_state.modes_by_id = new_vals[:modes_by_id]
128
122
  @application_state.exclusion_matchers = new_vals[:exclusion_matchers]
129
123
  @assess_state.disabled_assess_rules = new_vals[:disabled_assess_rules]
124
+ @last_app_update_ms = Contrast::Utils::Timer.now_ms
130
125
  end
126
+ @last_app_update_ms = Contrast::Utils::Timer.now_ms
131
127
  end
132
128
 
133
129
  # Wipe state to zero.
@@ -174,6 +170,44 @@ module Contrast
174
170
 
175
171
  private
176
172
 
173
+ # @param response [Contrast::Agent::Reporting::Response]
174
+ def update_from_response response
175
+ if (server_features = response.server_features)
176
+ update_server_features(server_features)
177
+ end
178
+ return unless (app_settings = response.application_settings)
179
+
180
+ update_application_settings(app_settings)
181
+ end
182
+
183
+ # @param server_features [Contrast::Agent::Reporting::Settings::FeatureSettings]
184
+ def update_server_features server_features
185
+ return unless server_features
186
+
187
+ log_file = server_features.log_file
188
+ log_level = server_features.log_level
189
+ Contrast::Logger::Log.instance.update(log_file, log_level) if log_file || log_level
190
+ @protect_state.enabled = server_features.protect.enabled?
191
+ @assess_state.enabled = server_features.assess.enabled?
192
+ @assess_state.sampling_settings = server_features.assess.sampling
193
+ @last_server_update_ms = Contrast::Utils::Timer.now_ms
194
+ end
195
+
196
+ # @param app_settings [Contrast::Agent::Reporting::Settings::ApplicationSettings]
197
+ def update_application_settings app_settings
198
+ return unless app_settings
199
+
200
+ @application_state.modes_by_id = app_settings.protect.protection_rules_to_settings_hash
201
+ # TODO: RUBY-1438 this needs to be translated
202
+ # @application_state.exclusion_matchers = new_vals[:exclusion_matchers]
203
+ update_sensitive_data_policy(app_settings.sensitive_data_masking)
204
+ @assess_state.disabled_assess_rules = app_settings.assess.disabled_rules
205
+ if app_settings.assess.session_id && !app_settings.assess.session_id.blank?
206
+ @assess_state.session_id = app_settings.assess.session_id
207
+ end
208
+ @last_app_update_ms = Contrast::Utils::Timer.now_ms
209
+ end
210
+
177
211
  # check if settings are empty and return true if so.
178
212
  #
179
213
  # @param settings [String, Boolean, Array, Hash]
@@ -9,23 +9,33 @@ require 'contrast/config/api_configuration'
9
9
 
10
10
  module Contrast
11
11
  module Config
12
- # Common Configuration settings. Those in this section pertain to the
13
- # core functionality of the Agent.
14
- class AgentConfiguration < BaseConfiguration
12
+ # Common Configuration settings. Those in this section pertain to the core functionality of the Agent.
13
+ class AgentConfiguration
14
+ include Contrast::Config::BaseConfiguration
15
+
15
16
  # @return [Boolean, nil]
16
17
  attr_accessor :enable
17
18
  # @return [Boolean, nil]
18
19
  attr_accessor :omit_body
19
- attr_writer :ruby, :service, :logger, :heap_dump
20
+ # @return [Contrast::Config::RubyConfiguration]
21
+ attr_writer :ruby
22
+ # @return [Contrast::Config::ServiceConfiguration]
23
+ attr_writer :service
24
+ # @return [ Contrast::Config::LoggerConfiguration]
25
+ attr_writer :logger
26
+ # @return [Contrast::Config::HeapDumpConfiguration]
27
+ attr_writer :heap_dump
20
28
 
21
29
  def initialize hsh = {}
22
- @enable = traverse_config(hsh, :enable)
23
- @start_bundled_service = traverse_config(hsh, :start_bundled_service)
24
- @omit_body = traverse_config(hsh, :omit_body)
25
- @service = Contrast::Config::ServiceConfiguration.new(traverse_config(hsh, :service))
26
- @logger = Contrast::Config::LoggerConfiguration.new(traverse_config(hsh, :logger))
27
- @ruby = Contrast::Config::RubyConfiguration.new(traverse_config(hsh, :ruby))
28
- @heap_dump = Contrast::Config::HeapDumpConfiguration.new(traverse_config(hsh, :heap_dump))
30
+ return unless hsh
31
+
32
+ @enable = hsh[:enable]
33
+ @start_bundled_service = hsh[:start_bundled_service]
34
+ @omit_body = hsh[:omit_body]
35
+ @service = Contrast::Config::ServiceConfiguration.new(hsh[:service])
36
+ @logger = Contrast::Config::LoggerConfiguration.new(hsh[:logger])
37
+ @ruby = Contrast::Config::RubyConfiguration.new(hsh[:ruby])
38
+ @heap_dump = Contrast::Config::HeapDumpConfiguration.new(hsh[:heap_dump])
29
39
  end
30
40
 
31
41
  # @return [Boolean, true]
@@ -8,7 +8,9 @@ require 'contrast/config/request_audit_configuration'
8
8
  module Contrast
9
9
  module Config
10
10
  # Api keys configuration
11
- class ApiConfiguration < BaseConfiguration
11
+ class ApiConfiguration
12
+ include Contrast::Config::BaseConfiguration
13
+
12
14
  # @return [String]
13
15
  attr_accessor :api_key
14
16
  # @return [String]
@@ -20,13 +22,15 @@ module Contrast
20
22
  DEFAULT_URL = 'https://app.contrastsecurity.com/Contrast'
21
23
 
22
24
  def initialize hsh = {}
23
- @api_key = traverse_config(hsh, :api_key)
24
- @url = traverse_config(hsh, :url)
25
- @user_name = traverse_config(hsh, :user_name)
26
- @service_key = traverse_config(hsh, :service_key)
27
- @proxy = Contrast::Config::ApiProxyConfiguration.new(traverse_config(hsh, :proxy))
28
- @request_audit = Contrast::Config::RequestAuditConfiguration.new(traverse_config(hsh, :request_audit))
29
- @certificate = Contrast::Config::CertificationConfiguration.new(traverse_config(hsh, :certificate))
25
+ return unless hsh
26
+
27
+ @api_key = hsh[:api_key]
28
+ @url = hsh[:url]
29
+ @user_name = hsh[:user_name]
30
+ @service_key = hsh[:service_key]
31
+ @proxy = Contrast::Config::ApiProxyConfiguration.new(hsh[:proxy])
32
+ @request_audit = Contrast::Config::RequestAuditConfiguration.new(hsh[:request_audit])
33
+ @certificate = Contrast::Config::CertificationConfiguration.new(hsh[:certificate])
30
34
  end
31
35
 
32
36
  def url
@@ -4,14 +4,18 @@
4
4
  module Contrast
5
5
  module Config
6
6
  # Api Proxy keys configuration
7
- class ApiProxyConfiguration < BaseConfiguration
7
+ class ApiProxyConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
8
10
  # @return [String] proxy url
9
11
  attr_accessor :url
10
12
  attr_writer :enable
11
13
 
12
14
  def initialize hsh = {}
13
- @enable = traverse_config(hsh, :enable)
14
- @url = traverse_config(hsh, :url)
15
+ return unless hsh
16
+
17
+ @enable = hsh[:enable]
18
+ @url = hsh[:url]
15
19
  end
16
20
 
17
21
  # @return [Boolean, false]
@@ -7,7 +7,9 @@ module Contrast
7
7
  module Config
8
8
  # Common Configuration settings. Those in this section pertain to the
9
9
  # application identification functionality of the Agent.
10
- class ApplicationConfiguration < BaseConfiguration
10
+ class ApplicationConfiguration
11
+ include Contrast::Config::BaseConfiguration
12
+
11
13
  # @return [String]
12
14
  attr_accessor :name
13
15
  # @return [String]
@@ -27,16 +29,18 @@ module Contrast
27
29
  attr_writer :session_id, :session_metadata
28
30
 
29
31
  def initialize hsh = {}
30
- @name = traverse_config(hsh, :name)
31
- @version = traverse_config(hsh, :version)
32
- @language = traverse_config(hsh, :language)
33
- @path = traverse_config(hsh, :path)
34
- @group = traverse_config(hsh, :group)
35
- @tags = traverse_config(hsh, :tags)
36
- @code = traverse_config(hsh, :code)
37
- @metadata = traverse_config(hsh, :metadata)
38
- @session_id = traverse_config(hsh, :session_id)
39
- @session_metadata = traverse_config(hsh, :session_metadata)
32
+ return unless hsh
33
+
34
+ @name = hsh[:name]
35
+ @version = hsh[:version]
36
+ @language = hsh[:language]
37
+ @path = hsh[:path]
38
+ @group = hsh[:group]
39
+ @tags = hsh[:tags]
40
+ @code = hsh[:code]
41
+ @metadata = hsh[:metadata]
42
+ @session_id = hsh[:session_id]
43
+ @session_metadata = hsh[:session_metadata]
40
44
  end
41
45
 
42
46
  # @return [String, Contrast::Utils::ObjectShare::EMPTY_STRING]
@@ -5,7 +5,9 @@ module Contrast
5
5
  module Config
6
6
  # Common Configuration settings. Those in this section pertain to the
7
7
  # assess functionality of the Agent.
8
- class AssessConfiguration < BaseConfiguration
8
+ class AssessConfiguration
9
+ include Contrast::Config::BaseConfiguration
10
+
9
11
  # @return [String, nil]
10
12
  attr_accessor :tags
11
13
  # @return [Boolean, nil]
@@ -15,14 +17,16 @@ module Contrast
15
17
  DEFAULT_STACKTRACES = 'ALL'
16
18
 
17
19
  def initialize hsh = {}
18
- @enable = traverse_config(hsh, :enable)
19
- @tags = traverse_config(hsh, :tags)
20
- @enable_scan_response = traverse_config(hsh, :enable_scan_response)
21
- @enable_dynamic_sources = traverse_config(hsh, :enable_dynamic_sources)
22
- @enable_original_object = traverse_config(hsh, :enable_original_object)
23
- @sampling = Contrast::Config::SamplingConfiguration.new(traverse_config(hsh, :sampling))
24
- @rules = Contrast::Config::AssessRulesConfiguration.new(traverse_config(hsh, :rules))
25
- @stacktraces = traverse_config(hsh, :stacktraces)
20
+ return unless hsh
21
+
22
+ @enable = hsh[:enable]
23
+ @tags = hsh[:tags]
24
+ @enable_scan_response = hsh[:enable_scan_response]
25
+ @enable_dynamic_sources = hsh[:enable_dynamic_sources]
26
+ @enable_original_object = hsh[:enable_original_object]
27
+ @sampling = Contrast::Config::SamplingConfiguration.new(hsh[:sampling])
28
+ @rules = Contrast::Config::AssessRulesConfiguration.new(hsh[:rules])
29
+ @stacktraces = hsh[:stacktraces]
26
30
  end
27
31
 
28
32
  # @return [Boolean, true]
@@ -5,13 +5,17 @@ module Contrast
5
5
  module Config
6
6
  # Common Configuration settings. Those in this section pertain to the
7
7
  # disabled assess rule functionality of the Agent.
8
- class AssessRulesConfiguration < BaseConfiguration
8
+ class AssessRulesConfiguration
9
+ include Contrast::Config::BaseConfiguration
10
+
9
11
  SPEC_KEY = :disabled_rules.cs__freeze
10
12
  # @return [Array, nil] list of disabled assess rules
11
13
  attr_accessor :disabled_rules
12
14
 
13
15
  def initialize hsh = {}
14
- @disabled_rules = cast_disabled_rules hsh
16
+ return unless hsh
17
+
18
+ @disabled_rules = cast_disabled_rules(hsh)
15
19
  end
16
20
 
17
21
  private
@@ -6,20 +6,11 @@ require 'contrast/utils/object_share'
6
6
 
7
7
  module Contrast
8
8
  module Config
9
- # This is the base for our configuration classes. It is intended to
10
- # facilitate the translation of the Common Configuration settings to usable
11
- # Ruby classes.
12
- class BaseConfiguration
9
+ # This is the base for our configuration classes. It is intended to facilitate the translation of the Common
10
+ # Configuration settings to usable Ruby classes.
11
+ module BaseConfiguration
13
12
  extend Forwardable
14
13
 
15
- EMPTY_VALUE = :EMPTY_VALUE
16
-
17
- def initialize hsh = {}, keys = {}
18
- # holds configuration key value pairs
19
- # each configuration class can contain nested BaseConfigurations
20
- traverse_config(hsh, keys)
21
- end
22
-
23
14
  def to_hash
24
15
  hsh = {}
25
16
  instance_variables.each do |iv|
@@ -42,29 +33,6 @@ module Contrast
42
33
  end
43
34
  nil
44
35
  end
45
-
46
- private
47
-
48
- # Traverse the given entity to build out the configuration graph.
49
- #
50
- # The values will be either a hash, indicating internal nodes to
51
- # traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
52
- # leaf node.
53
- #
54
- # The spec_key are the Contrast defined keys based on the instance variables of
55
- # a given configuration.
56
- def traverse_config values, spec_key
57
- internal_nodes = values.cs__respond_to?(:has_key?)
58
- val = internal_nodes ? value_from_key_config(spec_key, values) : nil
59
- val == EMPTY_VALUE ? nil : val
60
- end
61
-
62
- def value_from_key_config key, config_hash
63
- return config_hash[key] if config_hash.key?(key)
64
- return config_hash.fetch(key.to_sym, nil) if key.is_a?(String)
65
-
66
- config_hash.fetch(key.to_s, nil)
67
- end
68
36
  end
69
37
  end
70
38
  end
@@ -4,7 +4,9 @@
4
4
  module Contrast
5
5
  module Config
6
6
  # Certificate Configuration
7
- class CertificationConfiguration < BaseConfiguration
7
+ class CertificationConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
8
10
  # @return [String] path to CA Cert file
9
11
  attr_accessor :ca_file
10
12
  # @return [String] path to Certification file
@@ -14,10 +16,12 @@ module Contrast
14
16
  attr_writer :enable
15
17
 
16
18
  def initialize hsh = {}
17
- @enable = traverse_config(hsh, :enable)
18
- @ca_file = traverse_config(hsh, :ca_file)
19
- @cert_file = traverse_config(hsh, :cert_file)
20
- @key_file = traverse_config(hsh, :key_file)
19
+ return unless hsh
20
+
21
+ @enable = hsh[:enable]
22
+ @ca_file = hsh[:ca_file]
23
+ @cert_file = hsh[:cert_file]
24
+ @key_file = hsh[:key_file]
21
25
  end
22
26
 
23
27
  # @return [Boolean, false]
@@ -3,10 +3,11 @@
3
3
 
4
4
  module Contrast
5
5
  module Config
6
- # Common Configuration settings. Those in this section pertain to the
7
- # exception handling in Ruby, allowing for the override of Response Code
8
- # and Message when Security Exceptions are raised.
9
- class ExceptionConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the exception handling in Ruby, allowing for the
7
+ # override of Response Code and Message when Security Exceptions are raised.
8
+ class ExceptionConfiguration
9
+ include Contrast::Config::BaseConfiguration
10
+
10
11
  # @return [Integer] the HTTP status code override
11
12
  attr_accessor :override_status
12
13
  # @return [String] the message text override
@@ -14,9 +15,11 @@ module Contrast
14
15
  attr_writer :capture
15
16
 
16
17
  def initialize hsh = {}
17
- @capture = traverse_config(hsh, :capture)
18
- @override_status = traverse_config(hsh, :override_status)
19
- @override_message = traverse_config(hsh, :override_message)
18
+ return unless hsh
19
+
20
+ @capture = hsh[:capture]
21
+ @override_status = hsh[:override_status]
22
+ @override_message = hsh[:override_message]
20
23
  end
21
24
 
22
25
  # @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
- # Heap Dump collection functionality of the Agent.
8
- class HeapDumpConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the Heap Dump collection functionality of the
7
+ # Agent.
8
+ class HeapDumpConfiguration
9
+ include Contrast::Config::BaseConfiguration
10
+
9
11
  DEFAULT_PATH = 'contrast_heap_dumps' # saved
10
12
  DEFAULT_MS = 10_000
11
13
  DEFAULT_COUNT = 5
@@ -13,12 +15,14 @@ module Contrast
13
15
  attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean
14
16
 
15
17
  def initialize hsh = {}
16
- @enable = traverse_config(hsh, :enable)
17
- @path = traverse_config(hsh, :path)
18
- @delay_ms = traverse_config(hsh, :delay_ms)
19
- @window_ms = traverse_config(hsh, :window_ms)
20
- @count = traverse_config(hsh, :count)
21
- @clean = traverse_config(hsh, :clean)
18
+ return unless hsh
19
+
20
+ @enable = hsh[:enable]
21
+ @path = hsh[:path]
22
+ @delay_ms = hsh[:delay_ms]
23
+ @window_ms = hsh[:window_ms]
24
+ @count = hsh[:count]
25
+ @clean = hsh[:clean]
22
26
  end
23
27
 
24
28
  # @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken
@@ -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
- # inventory functionality of the Agent.
8
- class InventoryConfiguration < BaseConfiguration
6
+ # Common Configuration settings. Those in this section pertain to the inventory functionality of the Agent.
7
+ class InventoryConfiguration
8
+ include Contrast::Config::BaseConfiguration
9
+
9
10
  # @return [Array, nil] tags
10
11
  attr_accessor :tags
11
12
  attr_writer :enable, :analyze_libraries
12
13
 
13
14
  def initialize hsh = {}
14
- @enable = traverse_config(hsh, :enable)
15
- @analyze_libraries = traverse_config(hsh, :analyze_libraries)
16
- @tags = traverse_config(hsh, :tags)
15
+ return unless hsh
16
+
17
+ @enable = hsh[:enable]
18
+ @analyze_libraries = hsh[:analyze_libraries]
19
+ @tags = hsh[:tags]
17
20
  end
18
21
 
19
22
  # @return [Boolean, true]