contrast-agent 6.7.0 → 6.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.simplecov +0 -1
  4. data/Rakefile +0 -1
  5. data/ext/cs__assess_array/cs__assess_array.c +41 -10
  6. data/ext/cs__assess_array/cs__assess_array.h +4 -1
  7. data/lib/contrast/agent/assess/policy/trigger_method.rb +3 -3
  8. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  9. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
  10. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
  11. data/lib/contrast/agent/assess/property/evented.rb +11 -11
  12. data/lib/contrast/agent/assess.rb +0 -1
  13. data/lib/contrast/agent/excluder.rb +53 -35
  14. data/lib/contrast/agent/exclusion_matcher.rb +21 -9
  15. data/lib/contrast/agent/middleware.rb +12 -6
  16. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
  17. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
  18. data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +116 -0
  19. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
  20. data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
  21. data/lib/contrast/agent/protect/rule/base.rb +47 -55
  22. data/lib/contrast/agent/protect/rule/base_service.rb +48 -24
  23. data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
  24. data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
  25. data/lib/contrast/agent/protect/rule/cmd_injection.rb +20 -2
  26. data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -5
  27. data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +22 -22
  28. data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +64 -0
  29. data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +63 -0
  30. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
  31. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  32. data/lib/contrast/agent/protect/rule/deserialization.rb +3 -14
  33. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
  34. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
  35. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
  36. data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
  37. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
  38. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
  39. data/lib/contrast/agent/protect/rule/path_traversal.rb +40 -13
  40. data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +33 -15
  41. data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +0 -14
  42. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
  43. data/lib/contrast/agent/protect/rule/sqli.rb +74 -3
  44. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
  45. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
  46. data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
  47. data/lib/contrast/agent/protect/rule/xss.rb +15 -20
  48. data/lib/contrast/agent/protect/rule/xxe.rb +4 -24
  49. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +19 -40
  50. data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
  51. data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +10 -2
  52. data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +8 -2
  53. data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
  54. data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
  55. data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
  56. data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +16 -2
  57. data/lib/contrast/agent/reporting/masker/masker.rb +2 -0
  58. data/lib/contrast/agent/reporting/report.rb +1 -0
  59. data/lib/contrast/agent/reporting/reporter.rb +35 -14
  60. data/lib/contrast/agent/reporting/reporter_heartbeat.rb +3 -9
  61. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +16 -13
  62. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +12 -7
  63. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +3 -3
  64. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -2
  65. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -1
  66. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
  67. data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +0 -1
  68. data/lib/contrast/agent/reporting/reporting_events/finding.rb +6 -6
  69. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +239 -93
  70. data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +10 -23
  71. data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -9
  72. data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +0 -5
  73. data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
  74. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +12 -0
  75. data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
  76. data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +0 -1
  77. data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +0 -1
  78. data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +8 -0
  79. data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +40 -0
  80. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +2 -2
  81. data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
  82. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +43 -1
  83. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +8 -4
  84. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
  85. data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +58 -4
  86. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +4 -6
  87. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +77 -16
  88. data/lib/contrast/agent/reporting/server_settings_worker.rb +44 -0
  89. data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +14 -2
  90. data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
  91. data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
  92. data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
  93. data/lib/contrast/agent/reporting/settings/helpers.rb +7 -0
  94. data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
  95. data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
  96. data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +39 -2
  97. data/lib/contrast/agent/reporting/settings/rule_definition.rb +3 -0
  98. data/lib/contrast/agent/reporting/settings/security_logger.rb +77 -0
  99. data/lib/contrast/agent/reporting/settings/server_features.rb +9 -0
  100. data/lib/contrast/agent/reporting/settings/syslog.rb +34 -5
  101. data/lib/contrast/agent/request.rb +3 -14
  102. data/lib/contrast/agent/request_context.rb +6 -9
  103. data/lib/contrast/agent/request_context_extend.rb +9 -148
  104. data/lib/contrast/agent/request_handler.rb +5 -10
  105. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +1 -1
  106. data/lib/contrast/agent/thread_watcher.rb +37 -18
  107. data/lib/contrast/agent/version.rb +1 -1
  108. data/lib/contrast/agent.rb +6 -11
  109. data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
  110. data/lib/contrast/agent_lib/api/init.rb +101 -0
  111. data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
  112. data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
  113. data/lib/contrast/agent_lib/api/panic.rb +87 -0
  114. data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
  115. data/lib/contrast/agent_lib/interface.rb +260 -0
  116. data/lib/contrast/agent_lib/interface_base.rb +118 -0
  117. data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
  118. data/lib/contrast/agent_lib/test.rb +29 -0
  119. data/lib/contrast/api/communication/connection_status.rb +20 -5
  120. data/lib/contrast/components/agent.rb +34 -14
  121. data/lib/contrast/components/api.rb +23 -0
  122. data/lib/contrast/components/app_context.rb +23 -5
  123. data/lib/contrast/components/app_context_extend.rb +0 -25
  124. data/lib/contrast/components/assess.rb +34 -4
  125. data/lib/contrast/components/assess_rules.rb +18 -0
  126. data/lib/contrast/components/base.rb +40 -0
  127. data/lib/contrast/components/config/sources.rb +95 -0
  128. data/lib/contrast/components/config.rb +19 -19
  129. data/lib/contrast/components/heap_dump.rb +10 -0
  130. data/lib/contrast/components/inventory.rb +15 -2
  131. data/lib/contrast/components/logger.rb +18 -0
  132. data/lib/contrast/components/polling.rb +36 -0
  133. data/lib/contrast/components/protect.rb +52 -2
  134. data/lib/contrast/components/ruby_component.rb +16 -1
  135. data/lib/contrast/components/sampling.rb +70 -13
  136. data/lib/contrast/components/security_logger.rb +13 -0
  137. data/lib/contrast/components/settings.rb +105 -90
  138. data/lib/contrast/config/certification_configuration.rb +14 -0
  139. data/lib/contrast/config/config.rb +46 -0
  140. data/lib/contrast/config/diagnostics.rb +114 -0
  141. data/lib/contrast/config/diagnostics_tools.rb +98 -0
  142. data/lib/contrast/config/effective_config.rb +65 -0
  143. data/lib/contrast/config/effective_config_value.rb +32 -0
  144. data/lib/contrast/config/exception_configuration.rb +12 -0
  145. data/lib/contrast/config/protect_rule_configuration.rb +8 -8
  146. data/lib/contrast/config/protect_rules_configuration.rb +23 -60
  147. data/lib/contrast/config/request_audit_configuration.rb +13 -0
  148. data/lib/contrast/config/server_configuration.rb +41 -2
  149. data/lib/contrast/configuration.rb +29 -12
  150. data/lib/contrast/extension/assess/array.rb +9 -0
  151. data/lib/contrast/extension/assess/erb.rb +1 -1
  152. data/lib/contrast/extension/delegator.rb +2 -0
  153. data/lib/contrast/framework/manager.rb +3 -1
  154. data/lib/contrast/framework/rails/railtie.rb +0 -1
  155. data/lib/contrast/framework/rails/support.rb +0 -1
  156. data/lib/contrast/tasks/config.rb +1 -8
  157. data/lib/contrast/utils/assess/event_limit_utils.rb +31 -9
  158. data/lib/contrast/utils/assess/trigger_method_utils.rb +5 -4
  159. data/lib/contrast/utils/duck_utils.rb +1 -0
  160. data/lib/contrast/utils/hash_digest.rb +2 -2
  161. data/lib/contrast/utils/input_classification_base.rb +155 -0
  162. data/lib/contrast/utils/os.rb +0 -20
  163. data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +81 -0
  164. data/lib/contrast/utils/response_utils.rb +0 -16
  165. data/lib/contrast/utils/routes_sent.rb +60 -0
  166. data/lib/contrast/utils/stack_trace_utils.rb +3 -15
  167. data/lib/contrast/utils/string_utils.rb +10 -7
  168. data/lib/contrast/utils/telemetry_client.rb +1 -2
  169. data/lib/contrast/utils/timer.rb +16 -0
  170. data/lib/contrast.rb +5 -4
  171. data/resources/protect/policy.json +1 -2
  172. data/ruby-agent.gemspec +7 -6
  173. metadata +69 -130
  174. data/exe/contrast_service +0 -23
  175. data/lib/contrast/agent/assess/contrast_event.rb +0 -157
  176. data/lib/contrast/agent/assess/events/event_factory.rb +0 -34
  177. data/lib/contrast/agent/assess/events/source_event.rb +0 -46
  178. data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
  179. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
  180. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
  181. data/lib/contrast/agent/reaction_processor.rb +0 -47
  182. data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +0 -36
  183. data/lib/contrast/agent/service_heartbeat.rb +0 -35
  184. data/lib/contrast/api/communication/messaging_queue.rb +0 -128
  185. data/lib/contrast/api/communication/response_processor.rb +0 -90
  186. data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
  187. data/lib/contrast/api/communication/socket.rb +0 -44
  188. data/lib/contrast/api/communication/socket_client.rb +0 -130
  189. data/lib/contrast/api/communication/speedracer.rb +0 -138
  190. data/lib/contrast/api/communication/tcp_socket.rb +0 -32
  191. data/lib/contrast/api/communication/unix_socket.rb +0 -28
  192. data/lib/contrast/api/communication.rb +0 -20
  193. data/lib/contrast/api/decorators/address.rb +0 -59
  194. data/lib/contrast/api/decorators/agent_startup.rb +0 -56
  195. data/lib/contrast/api/decorators/application_settings.rb +0 -43
  196. data/lib/contrast/api/decorators/application_startup.rb +0 -56
  197. data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
  198. data/lib/contrast/api/decorators/http_request.rb +0 -137
  199. data/lib/contrast/api/decorators/input_analysis.rb +0 -18
  200. data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
  201. data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
  202. data/lib/contrast/api/decorators/message.rb +0 -67
  203. data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -52
  204. data/lib/contrast/api/decorators/response_type.rb +0 -17
  205. data/lib/contrast/api/decorators/server_features.rb +0 -25
  206. data/lib/contrast/api/decorators/user_input.rb +0 -51
  207. data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
  208. data/lib/contrast/api/decorators.rb +0 -22
  209. data/lib/contrast/api/dtm.pb.rb +0 -363
  210. data/lib/contrast/api/settings.pb.rb +0 -500
  211. data/lib/contrast/api.rb +0 -16
  212. data/lib/contrast/components/contrast_service.rb +0 -88
  213. data/lib/contrast/components/service.rb +0 -55
  214. data/lib/contrast/tasks/service.rb +0 -84
  215. data/lib/contrast/utils/input_classification.rb +0 -73
  216. data/lib/protobuf/code_generator.rb +0 -129
  217. data/lib/protobuf/decoder.rb +0 -28
  218. data/lib/protobuf/deprecation.rb +0 -117
  219. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
  220. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
  221. data/lib/protobuf/descriptors.rb +0 -3
  222. data/lib/protobuf/encoder.rb +0 -11
  223. data/lib/protobuf/enum.rb +0 -365
  224. data/lib/protobuf/exceptions.rb +0 -9
  225. data/lib/protobuf/field/base_field.rb +0 -380
  226. data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
  227. data/lib/protobuf/field/bool_field.rb +0 -64
  228. data/lib/protobuf/field/bytes_field.rb +0 -67
  229. data/lib/protobuf/field/double_field.rb +0 -25
  230. data/lib/protobuf/field/enum_field.rb +0 -56
  231. data/lib/protobuf/field/field_array.rb +0 -102
  232. data/lib/protobuf/field/field_hash.rb +0 -122
  233. data/lib/protobuf/field/fixed32_field.rb +0 -25
  234. data/lib/protobuf/field/fixed64_field.rb +0 -28
  235. data/lib/protobuf/field/float_field.rb +0 -43
  236. data/lib/protobuf/field/int32_field.rb +0 -21
  237. data/lib/protobuf/field/int64_field.rb +0 -34
  238. data/lib/protobuf/field/integer_field.rb +0 -23
  239. data/lib/protobuf/field/message_field.rb +0 -51
  240. data/lib/protobuf/field/sfixed32_field.rb +0 -27
  241. data/lib/protobuf/field/sfixed64_field.rb +0 -28
  242. data/lib/protobuf/field/signed_integer_field.rb +0 -29
  243. data/lib/protobuf/field/sint32_field.rb +0 -21
  244. data/lib/protobuf/field/sint64_field.rb +0 -21
  245. data/lib/protobuf/field/string_field.rb +0 -51
  246. data/lib/protobuf/field/uint32_field.rb +0 -21
  247. data/lib/protobuf/field/uint64_field.rb +0 -21
  248. data/lib/protobuf/field/varint_field.rb +0 -77
  249. data/lib/protobuf/field.rb +0 -74
  250. data/lib/protobuf/generators/base.rb +0 -85
  251. data/lib/protobuf/generators/enum_generator.rb +0 -39
  252. data/lib/protobuf/generators/extension_generator.rb +0 -27
  253. data/lib/protobuf/generators/field_generator.rb +0 -193
  254. data/lib/protobuf/generators/file_generator.rb +0 -262
  255. data/lib/protobuf/generators/group_generator.rb +0 -122
  256. data/lib/protobuf/generators/message_generator.rb +0 -104
  257. data/lib/protobuf/generators/option_generator.rb +0 -17
  258. data/lib/protobuf/generators/printable.rb +0 -160
  259. data/lib/protobuf/generators/service_generator.rb +0 -50
  260. data/lib/protobuf/lifecycle.rb +0 -33
  261. data/lib/protobuf/logging.rb +0 -39
  262. data/lib/protobuf/message/fields.rb +0 -233
  263. data/lib/protobuf/message/serialization.rb +0 -85
  264. data/lib/protobuf/message.rb +0 -241
  265. data/lib/protobuf/optionable.rb +0 -72
  266. data/lib/protobuf/tasks/compile.rake +0 -80
  267. data/lib/protobuf/tasks.rb +0 -1
  268. data/lib/protobuf/varint.rb +0 -20
  269. data/lib/protobuf/varint_pure.rb +0 -31
  270. data/lib/protobuf/version.rb +0 -3
  271. data/lib/protobuf/wire_type.rb +0 -10
  272. data/lib/protobuf.rb +0 -91
  273. data/proto/dynamic_discovery.proto +0 -46
  274. data/proto/google/protobuf/compiler/plugin.proto +0 -183
  275. data/proto/google/protobuf/descriptor.proto +0 -911
  276. data/proto/rpc.proto +0 -71
  277. data/service_executables/.gitkeep +0 -0
  278. data/service_executables/VERSION +0 -1
  279. data/service_executables/linux/contrast-service +0 -0
  280. data/service_executables/mac/contrast-service +0 -0
@@ -2,11 +2,12 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/components/logger'
5
- require 'contrast/agent/service_heartbeat'
6
- require 'contrast/api/communication/messaging_queue'
7
5
  require 'contrast/agent/reporting/report'
8
6
  require 'contrast/agent/reporting/reporter_heartbeat'
7
+ require 'contrast/agent/reporting/server_settings_worker'
9
8
  require 'contrast/agent/telemetry/base'
9
+ require 'contrast/agent/protect/input_analyzer/worth_watching_analyzer'
10
+ require 'contrast/config/diagnostics'
10
11
 
11
12
  module Contrast
12
13
  module Agent
@@ -16,25 +17,23 @@ module Contrast
16
17
 
17
18
  # @return [Contrast::Utils::HeapDumpUtil]
18
19
  attr_reader :heapdump_util
19
- # @return [Contrast::Agent::ServiceHeartbeat, nil]
20
- attr_reader :heartbeat
21
- # @return [Contrast::Api::Communication::MessagingQueue, nil]
22
- attr_reader :messaging_queue
23
20
  # @return [Contrast::Agent::Reporter]
24
21
  attr_reader :reporter
25
22
  # @return [Contrast::Agent::ReporterHeartbeat]
26
23
  attr_reader :reporter_heartbeat
24
+ # @return [Contrast::Agent::Protect::WorthWatchingInputAnalyzer]
25
+ attr_reader :worth_watching_analyzer
26
+ # @return [Contrast::Agent::ServerSettingsWorker]
27
+ attr_reader :reporter_settings_worker
27
28
 
28
29
  def initialize
29
30
  @pids = {}
30
31
  @heapdump_util = Contrast::Utils::HeapDumpUtil.new
31
- unless ::Contrast::CONTRAST_SERVICE.unnecessary?
32
- @heartbeat = Contrast::Agent::ServiceHeartbeat.new
33
- @messaging_queue = Contrast::Api::Communication::MessagingQueue.new
34
- end
35
32
  @reporter = Contrast::Agent::Reporter.new
36
33
  @reporter_heartbeat = Contrast::Agent::ReporterHeartbeat.new
34
+ @reporter_settings_worker = Contrast::Agent::ServerSettingsWorker.new
37
35
  @telemetry = Contrast::Agent::Telemetry::Base.new if Contrast::Agent::Telemetry::Base.enabled?
36
+ @worth_watching_analyzer = Contrast::Agent::Protect::WorthWatchingInputAnalyzer.new unless protect_disabled?
38
37
  end
39
38
 
40
39
  # @return [Hash, nil] map of process to thread startup status
@@ -42,16 +41,18 @@ module Contrast
42
41
  return unless ::Contrast::AGENT.enabled?
43
42
 
44
43
  logger.debug('ThreadWatcher started threads')
45
- heartbeat_status = init_thread(heartbeat)
46
- messaging_status = init_thread(messaging_queue)
47
- @pids[Process.pid] = messaging_status && heartbeat_status
44
+ reporter_status = init_thread(reporter)
45
+ reporter_heartbeat_status = init_thread(reporter_heartbeat)
46
+ reporter_settings_worker_status = init_thread(reporter_settings_worker)
47
+ @pids[Process.pid] = reporter_status && reporter_heartbeat_status && reporter_settings_worker_status
48
48
  if Contrast::Agent::Telemetry::Base.enabled?
49
49
  telemetry_status = init_thread(telemetry_queue)
50
50
  @pids[Process.pid] = @pids[Process.pid] && telemetry_status
51
51
  end
52
- reporter_status = init_thread(reporter)
53
- reporter_heartbeat_status = init_thread(reporter_heartbeat)
54
- @pids[Process.pid] = @pids[Process.pid] && reporter_status && reporter_heartbeat_status
52
+ unless protect_disabled?
53
+ worth_watching_analyzer_status = init_thread(worth_watching_analyzer)
54
+ @pids[Process.pid] = @pids[Process.pid] && worth_watching_analyzer_status
55
+ end
55
56
  @pids
56
57
  end
57
58
 
@@ -62,13 +63,27 @@ module Contrast
62
63
  startup!
63
64
  end
64
65
 
66
+ # This method will check the config and if the config is invalid - it will kill the agent
67
+ def self.check_before_start
68
+ return if Contrast::CONFIG.send(:validate)
69
+
70
+ @_diagnostics = Contrast::Agent::DiagnosticsConfig::Diagnostics.new(Contrast::AGENT.logger.path ||
71
+ Contrast::Components::Config::CONTRAST_LOG)
72
+ @_diagnostics.config.populate_fail_connection
73
+ @_diagnostics.write_to_file_logic(false, reset: false)
74
+ # kill agent
75
+ Contrast::AGENT.disable_agent!
76
+ # TODO: RUBY-1822
77
+ # set the in_application_scope to 1 so we short circuit it
78
+ end
79
+
65
80
  def shutdown!
66
- heartbeat&.stop!
67
- messaging_queue&.stop!
68
81
  heapdump_util&.stop!
69
82
  telemetry_queue&.stop!
70
83
  reporter&.stop!
71
84
  reporter_heartbeat&.stop!
85
+ worth_watching_analyzer&.stop!
86
+ reporter_settings_worker&.stop!
72
87
  end
73
88
 
74
89
  # @return [Contrast::Agent::Telemetry::Base]
@@ -93,6 +108,10 @@ module Contrast
93
108
  logger.debug('Thread status', type: watcher.to_s, alive: result)
94
109
  result
95
110
  end
111
+
112
+ def protect_disabled?
113
+ ::Contrast::PROTECT.forcibly_disabled?
114
+ end
96
115
  end
97
116
  end
98
117
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Contrast
5
5
  module Agent
6
- VERSION = '6.7.0'
6
+ VERSION = '6.9.0'
7
7
  end
8
8
  end
@@ -42,9 +42,6 @@ require 'contrast/utils/thread_tracker'
42
42
  # Framework support
43
43
  require 'contrast/framework/manager'
44
44
 
45
- # Communication to SR
46
- require 'contrast/api/communication'
47
-
48
45
  require 'contrast/agent/thread_watcher'
49
46
 
50
47
  module Contrast
@@ -66,11 +63,6 @@ module Contrast
66
63
  thread_watcher.heapdump_util
67
64
  end
68
65
 
69
- # @return [nil, Contrast::Api::Communication::MessagingQueue]
70
- def self.messaging_queue
71
- thread_watcher.messaging_queue
72
- end
73
-
74
66
  # @return [nil, Contrast::Agent::Telemetry::Base]
75
67
  def self.telemetry_queue
76
68
  thread_watcher.telemetry_queue
@@ -81,20 +73,23 @@ module Contrast
81
73
  thread_watcher.reporter
82
74
  end
83
75
 
76
+ # @return [Contrast::Agent::Protect::WorthWatchingAnalyzer]
77
+ def self.worth_watching_analyzer
78
+ thread_watcher.worth_watching_analyzer
79
+ end
80
+
81
+ # @return [Contrast::Agent::ThreadWatcher]
84
82
  def self.thread_watcher
85
83
  @_thread_watcher ||= Contrast::Agent::ThreadWatcher.new
86
84
  end
87
85
  end
88
86
  end
89
87
 
90
- require 'contrast/api'
91
-
92
88
  require 'contrast/utils/resource_loader'
93
89
  require 'contrast/utils/duck_utils'
94
90
  require 'contrast/agent/tracepoint_hook'
95
91
  require 'contrast/agent/at_exit_hook'
96
92
 
97
- # communication with contrast service
98
93
  require 'contrast/agent/exclusion_matcher'
99
94
 
100
95
  # threads that handle contrast scope
@@ -0,0 +1,46 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: false
3
+
4
+ require 'ffi'
5
+ # require the gem
6
+ require 'contrast-agent-lib'
7
+
8
+ module Contrast
9
+ module AgentLib
10
+ # This module is defined in Rust as external, we used it here.
11
+ # Initializes the AgentLib. Here will be all methods from
12
+ # the C bindings contrast_c::cmdi_semantic_chained_command module.
13
+ module CommandInjection
14
+ extend FFI::Library
15
+ ffi_lib ContrastAgentLib::CONTRAST_C
16
+
17
+ attach_function :get_index_of_chained_command, [:string], :long_long
18
+ attach_function :does_command_contain_dangerous_path, [:string], :int
19
+
20
+ private
21
+
22
+ # Checks that a given shell command contained a chained command.
23
+ # This is used for the cmd-injection-semantic-chained-commands rule.
24
+ #
25
+ # @param cmd [String] command to check.
26
+ # @return index[Integer] Returns the index of the command chaining if found.
27
+ # If the chaining index is >= 0, an injection is detected. Returns -1 when
28
+ # no command chaining is found.
29
+ def dl__index_of_chained_command cmd
30
+ get_index_of_chained_command(cmd)
31
+ end
32
+
33
+ # Checks if a given shell command is trying to access a dangerous path.
34
+ # This is used for the cmd-injection-semantic-dangerous-paths rule.
35
+ #
36
+ # @param path [String] path to check.
37
+ # @return index[Boolean] Returns 1 if a dangerous path is found.
38
+ # Returns 0 if no dangerous paths are found.
39
+ def dl__dangerous_path? path
40
+ return false if does_command_contain_dangerous_path(path).zero?
41
+
42
+ true
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,101 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: false
3
+
4
+ require 'ffi'
5
+ # require the gem
6
+ require 'contrast-agent-lib'
7
+
8
+ module Contrast
9
+ module AgentLib
10
+ # This module is defined in Rust as external, we used it here.
11
+ # Initializes the AgentLib. Here will be all methods from
12
+ # the C bindings agent_init mod.
13
+ module Init
14
+ extend FFI::Library
15
+ ffi_lib ContrastAgentLib::CONTRAST_C
16
+
17
+ # Init
18
+ #
19
+ # 0 => OK, -1 => Err
20
+ # The attach function could be called also like this:
21
+ # attach_function :ruby_name, :c_name, [ :params ], :returns, { :options => values }
22
+ # an that way we define a ruby_name for the C method, but we alias to make a documentation
23
+ # for the method.
24
+ #
25
+ # Also we extend the FFI::Library inside this module so we could also redefine the
26
+ # attach_function to our taste, not worry about it leaking outside of this module.
27
+ #
28
+ # @param [Symbol] Name of required function.
29
+ # @param [Array] An array of argument types.
30
+ # @return [Integer] Return type of the function.
31
+ attach_function :init, [], :int
32
+
33
+ # TODO: RUBY-1693
34
+ # Initialize agent lib without any optional settings. To set optional settings consider using
35
+ # `init_with_options` instead If you want to enable logging, it must be set using environment variables
36
+ # `CONTRAST_AGENTLIB_LOG_LEVEL` - set to log level. Must of one of ERROR, WARN, INFO, DEBUG or TRACE
37
+ # `CONTRAST_AGENTLIB_LOG_DIR` - must point to an accessible directory where logs will be written.
38
+ # The name of the log file
39
+ # is auto-generated and cannot be set. The format is 'libcontrast_<date>_<process_id>.log'
40
+ #
41
+ # If these environment variables are not present during `init`, agent-lib will be initialized with
42
+ # logging disabled and you will not be able to re-enable it using `change_log_settings`
43
+ # @param [Symbol] Name of required function.
44
+ # @param [Array] An array of argument types.
45
+ # @return [Integer] Return type of the function.
46
+ attach_function :init_with_options, %i[bool string string], :int
47
+
48
+ # TODO: RUBY-1693
49
+ # Change log settings for agent lib after it's been initialized. This api must be used after init
50
+ #
51
+ # Safety
52
+ # The `log_level` parameter must point to must point to an UTF-8 encoded string C-string
53
+ # @param enable_logging [Boolean] flag to enable or disable logging.
54
+ # @param log_level [String] UTF-8 encoded string indicating the maximum log level
55
+ # if logging is enabled
56
+ attach_function :change_log_settings, %i[bool string], :int
57
+
58
+ # TODO: RUBY-1693
59
+ # Initialize AgentLib with options.
60
+ # If init returns 0 = successful setup with options
61
+ # if init returns 1 = unsuccessful setup with options
62
+ #
63
+ # @param enable_logging [Boolean] flag to enable or disable logging.
64
+ # @param log_dir [String] path to existing log directory.
65
+ # @param log_level [String] OFF, ERROR, WARN, INFO, DEBUG or TRACE.
66
+ # @return [Boolean] true if initialized false if not.
67
+ def dl__init_with_options enable_logging, log_dir, log_level
68
+ # This is useful for scope sensitive string pointers, if function ends and
69
+ # you need them to be picked up after the C function.
70
+ init_with_options(enable_logging, log_dir, log_level).zero?
71
+ end
72
+
73
+ private
74
+
75
+ # Initialize AgentLib without options. Log level could not be set after.
76
+ # If you want to set the log levels you can do it be ENV variables:
77
+ # EVN [CONTRAST_AGENTLIB_LOG_LEVEL] - set to log level. Must of one of ERROR, WARN, INFO, DEBUG or TRACE
78
+ # ENV['CONTRAST_AGENTLIB_LOG_DIR'] - must point to an accessible directory where logs will be written.
79
+ # The name of the log file.
80
+ #
81
+ # @return [Boolean] true if initialized, false if not.
82
+ def dl__init
83
+ init.zero?
84
+ end
85
+
86
+ # TODO: RUBY-1693
87
+ # Change the log settings. This api must be called after the dl__init_with_options.
88
+ #
89
+ # @param enable_log [Boolean] flag to enable or disable logging this sets the inner flag.
90
+ # @param log_level [String] OFF, ERROR, WARN, INFO, DEBUG or TRACE.
91
+ # @return [Boolean] true if initialized false if not.
92
+ def dl__change_log_settings enable_log, log_level
93
+ # transform to C strings pointers here and pass to function.
94
+ log_dir_pointer = FFI::MemoryPointer.from_string(log_level.dup.force_encoding('UTF-8'))
95
+ return true if change_log_settings(enable_log, log_dir_pointer).zero?
96
+
97
+ false
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,267 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: false
3
+
4
+ require 'ffi'
5
+ # require the gem
6
+ require 'contrast-agent-lib'
7
+ require 'contrast/components/logger'
8
+
9
+ module Contrast
10
+ module AgentLib
11
+ # This module is defined in Rust as external, we used it here.
12
+ # Initializes the AgentLib. Here will be all methods from
13
+ # the C bindings contrast_c::input_tracing module.
14
+ module InputTracing
15
+ # Struct could be used as parameter to C functions,
16
+ # and also to save the return data. This is like
17
+ # specifying a type for pointer.
18
+ #
19
+ # Expected struct:
20
+ # pub struct CCheckQuerySinkResult {
21
+ # pub start_index: u64,
22
+ # pub end_index: u64,
23
+ # pub boundary_overrun_index: u64,
24
+ # pub input_boundary_index: u64,
25
+ # }
26
+ #
27
+ class QuerySinkResult < FFI::ManagedStruct
28
+ layout :start_index, :ulong_long,
29
+ :end_index, :ulong_long,
30
+ :boundary_overrun_index, :ulong_long,
31
+ :input_boundary_index, :ulong_long
32
+
33
+ # when QuerySinkResult object gets out of scope it will be GCed.
34
+ def self.release ptr
35
+ Contrast::AgentLib::InputTracing.dl__free_check(ptr)
36
+ end
37
+ end
38
+
39
+ # This class will be used to hold the return type from input tracings
40
+ # done with the AgentLib. Using the ManagedStruct will automatically
41
+ # call the release function, and since the memory is allocated by the
42
+ # AgentLib is should be GC also there.
43
+ class CEvalResult < FFI::ManagedStruct
44
+ layout :rule_id, :ulong_long, :input_type, :ulong_long, :score, :double
45
+
46
+ def self.release ptr
47
+ Contrast::AgentLib::InputTracing.dl__free_eval(ptr)
48
+ end
49
+ end
50
+
51
+ extend FFI::Library
52
+ include Contrast::Components::Logger::InstanceMethods
53
+ ffi_lib ContrastAgentLib::CONTRAST_C
54
+ ffi_convention :stdcall
55
+
56
+ DbType = enum(:DB2, :MySQL, :Oracle, :Postgres, :Sqlite, :SqlServer, :Unknown)
57
+
58
+ # Returns 0 if evaluation was successful, -1 if there was an unexpected error.
59
+ attach_function :check_cmd_injection_query, %i[int int string pointer], :int
60
+ # Return 0 if evaluation was successful, -1 iif there was an unexpected error.
61
+ attach_function :check_sql_injection_query, [:int, :int, DbType, :string, :pointer], :int
62
+ # Free function for all input tracing results pass to check functions.
63
+ attach_function :free_check_query_sink_result, [:pointer], :int
64
+ # Evaluate header input:
65
+ attach_function :evaluate_header_input, %i[string string uint64 uint64 pointer pointer], :int
66
+ # Evaluate input:
67
+ attach_function :evaluate_input, %i[string uint64 uint64 uint64 pointer pointer], :int
68
+ # Free input evaluation:
69
+ attach_function :free_eval_result, [:pointer], :int
70
+ # function init
71
+ attach_function :init, [], :int
72
+
73
+ # Once we have pointer or returned data the lib
74
+ # expect us to free it, so it could GCd.
75
+ # Most of the time we would receive result pointer.
76
+ # Used with dl__check_cmdi_query and dl__check_sqli_query.
77
+ #
78
+ # @param result [Pointer]
79
+ def self.dl__free_check result
80
+ free_check_query_sink_result(result)
81
+ end
82
+
83
+ # Free the input evaluation result received from
84
+ # dl__eval_input, and dl__eval_header_input
85
+ #
86
+ # @param result [Pointer]
87
+ def self.dl__free_eval result
88
+ free_eval_result(result)
89
+ end
90
+
91
+ private
92
+
93
+ # Evaluate a subset of executing shell command for token boundaries being crossed.
94
+ # This is used by the cmd-injection rule during sink time. If a previously
95
+ # worth-watching input is contained in the shell command it crosses token
96
+ # boundaries then an injection should be raised.
97
+ #
98
+ # @param input_index [Integer] index in the cmdText string where user input was found.
99
+ # @param input_length [Integer] length of the user input.
100
+ # @return result [Hash, nil] output parameter which will contain the result of the evaluation.
101
+ def dl__check_cmdi_query input_index, input_length, input_cmd
102
+ # The memory for the result is allocated by AgentLib/Rust. So we need to create just an empty pointer
103
+ # This pointer will be populated by the output parameter of check_cmd_injection_query#
104
+ result_ptr = FFI::MemoryPointer.new(:pointer)
105
+ result_code = check_cmd_injection_query(input_index, input_length, input_cmd, result_ptr)
106
+
107
+ unless result_code == -1
108
+ struct = QuerySinkResult.new(result_ptr.read_pointer)
109
+ result_hash = dl__struct_to_result(struct)
110
+
111
+ return result_hash
112
+ end
113
+
114
+ nil
115
+ end
116
+
117
+ # This function will call the check sql injection query
118
+ # SAFETY DISCLAIMER
119
+ # The sql_query parameter must point to an allocated C-string in UTF-8 encoding
120
+ # The result MUST be free'd using free_check_query_sink_result as soon as result has been processed.
121
+ #
122
+ # @param input_index[Integer] index in the sqlQuery string where user input was found
123
+ # @param input_length[Integer] length of the user input
124
+ # @param sql_query[String] full SQL query being evaluated
125
+ # @param db_type[Integer] database engine being evaluated. Must be one of the DbType enum values
126
+ # @return [Hash, nil] Returns 0 if evaluation was successful, -1 if there was an unexpected error.
127
+ def dl__check_sql_injection_query input_index, input_length, db_type, sql_query
128
+ db_type = :Sqlite if db_type.to_s.casecmp('sqlite3').zero?
129
+ dbtype = DbType[db_type]
130
+ pointer = FFI::MemoryPointer.new(:pointer)
131
+ check = check_sql_injection_query(input_index, input_length, dbtype, sql_query, pointer)
132
+
133
+ return if check == -1
134
+
135
+ struct = QuerySinkResult.new(pointer.read_pointer)
136
+ dl__struct_to_result(struct)
137
+ rescue RuntimeError => e
138
+ # silence the runtime error from the agent lib
139
+ logger.debug('Following RuntimeError was recording during input tracing: ', e: e)
140
+ nil
141
+ ensure
142
+ pointer.free unless pointer.nil? && pointer.address
143
+ end
144
+
145
+ # Evaluates a header for input tracing rules.
146
+ #
147
+ # @param header_name [String] key/name of the header to be evaluated.
148
+ # NOTE: the only header names used are "custom", "accept", and "user-agent".
149
+ # Header-name-used is part of the output because the accept and user-agent
150
+ # headers get special handling by agent-lib, so they are evaluated twice -
151
+ # once exactly like all other headers and once with the specific header that
152
+ # gets special handling.
153
+ # @param header_value [String] header value
154
+ # @param rule_set [Integer] one or more bit flag of input tracing rules to be evaluated.
155
+ # The bit flags must match the RuleType enum. Currently supported types:
156
+ # [RuleType::CmdInjection, RuleType::PathTraversal, RuleType::SqlInjection,
157
+ # RuleType::UnsafeFileUpload, RuleType::ReflectedXss, RuleType::BotBlocker]
158
+ # public enum RuleType : ulong
159
+ # {
160
+ # UnsafeFileUpload = 1 << 0,
161
+ # PathTraversal = 1 << 1,
162
+ # ReflectedXss = 1 << 2,
163
+ # SqlInjection = 1 << 3,
164
+ # CmdInjection = 1 << 4,
165
+ # NosqlInjectionMongo = 1 << 5,
166
+ # BotBlocker = 1 << 6
167
+ # }
168
+ # @param eval_options [Integer] u64 representation of the EvalOptions enum.
169
+ # public enum EvalOptions : ulong
170
+ # {
171
+ # None = 0,
172
+ # PreferWorthWatching = 1 << 0,
173
+ # }
174
+ def dl__eval_header_input header_name, header_value, rule_set, eval_options
175
+ # The memory for the result is allocated by AgentLib/Rust. So we need to create just an empty pointer
176
+ # This pointer will be populated by the output parameter of check_cmd_injection_query#
177
+ result_ptr = FFI::MemoryPointer.new(:pointer)
178
+ result_size = FFI::MemoryPointer.new(:uint32)
179
+ # @param result_size [Integer] output parameter which will contain the number of Results after evaluation:
180
+ # 0 if no result.
181
+ evaluate_header_input(header_name, header_value, rule_set, eval_options, result_size, result_ptr)
182
+
183
+ size = result_size.read_int
184
+ result_size&.free
185
+
186
+ unless size.zero?
187
+ struct = CEvalResult.new(result_ptr.read_pointer)
188
+ return dl__eval_struct_to_result(struct)
189
+ end
190
+ nil
191
+ end
192
+
193
+ # Evaluates an input part for input tracing rules. This should be used for all input parts except headers.
194
+ #
195
+ # @param input [String] input value to be evaluated.
196
+ # @param input_type [Symbol] type of the input. This needs to be a u64 representation of the
197
+ # supported InputType enum values:
198
+ # {
199
+ # CookieName = 1,
200
+ # CookieValue = 2,
201
+ # HeaderKey = 3,
202
+ # HeaderValue = 4,
203
+ # JsonKey = 5,
204
+ # JsonValue = 6,
205
+ # Method = 7,
206
+ # ParameterKey = 8,
207
+ # ParameterValue = 9,
208
+ # UriPath = 10,
209
+ # UrlParameter = 11,
210
+ # MultipartName = 12,
211
+ # XmlValue = 13
212
+ # }
213
+ # @param rule_set [Integer] one or more bit flag of input tracing rules to be evaluated.
214
+ # The bit flags must match the RuleType enum. Currently supported types:
215
+ # [RuleType::CmdInjection, RuleType::PathTraversal, RuleType::SqlInjection,
216
+ # RuleType::UnsafeFileUpload, RuleType::ReflectedXss, RuleType::BotBlocker]
217
+ # @param eval_options [Integer] u64 representation of the EvalOptions enum.
218
+ # public enum EvalOptions : ulong
219
+ # {
220
+ # None = 0,
221
+ # PreferWorthWatching = 1 << 0,
222
+ # }
223
+ def dl__eval_input input, input_type, rule_set, eval_options
224
+ # The memory for the result is allocated by AgentLib/Rust. So we need to create just an empty pointer
225
+ # This pointer will be populated by the output parameter of check_cmd_injection_query#
226
+ result_ptr = FFI::MemoryPointer.new(:pointer)
227
+ result_size = FFI::MemoryPointer.new(:uint32)
228
+ # @param result_size [Integer] output parameter which will contain the number of Results after evaluation:
229
+ # 0 if no result.
230
+ evaluate_input(input, input_type, rule_set, eval_options, result_size, result_ptr)
231
+ size = result_size.read_int
232
+ result_size&.free
233
+
234
+ unless size.zero?
235
+ struct = CEvalResult.new(result_ptr.read_pointer)
236
+ return dl__eval_struct_to_result(struct)
237
+ end
238
+ nil
239
+ end
240
+
241
+ # Convert c_struct cmdi result to ruby hash
242
+ #
243
+ # @param struct [Contrast::AgentLib::QuerySinkResult]
244
+ # @return hash [Hash]
245
+ def dl__struct_to_result struct
246
+ hash = {}
247
+ hash[:start_index] = struct[:start_index]
248
+ hash[:end_index] = struct[:end_index]
249
+ hash[:boundary_overrun_index] = struct[:boundary_overrun_index]
250
+ hash[:input_boundary_index] = struct[:input_boundary_index]
251
+ hash
252
+ end
253
+
254
+ # Convert c_struct evaluated input to ruby hash
255
+ #
256
+ # @param struct [Contrast::AgentLib::QuerySinkResult]
257
+ # @return hash [Hash]
258
+ def dl__eval_struct_to_result struct
259
+ hash = {}
260
+ hash[:rule_id] = struct[:rule_id]
261
+ hash[:input_type] = struct[:input_type]
262
+ hash[:score] = struct[:score]
263
+ hash
264
+ end
265
+ end
266
+ end
267
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: false
3
+
4
+ require 'ffi'
5
+ # require the gem
6
+ require 'contrast-agent-lib'
7
+
8
+ module Contrast
9
+ module AgentLib
10
+ # This module is for method tempering bindings: contrast_c::method_tampering
11
+ module MethodTempering
12
+ # TODO: RUBY-1632
13
+ # extend FFI::Library
14
+ # ffi_lib ContrastAgentLib::CONTRAST_C
15
+ #
16
+ # # returns 1 => true, 0 => false
17
+ # attach_function :is_method_tampering, [:string], :int32
18
+ #
19
+ # # Check to see if method is being tempered or not.
20
+ # # Used with Protect method-tampering rule.
21
+ # #
22
+ # # @param method [String] method to check
23
+ # # @return [Boolean]
24
+ # def dl__method_tempered? method
25
+ # is_method_tampering(method).positive?
26
+ # end
27
+ end
28
+ end
29
+ end