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
@@ -21,18 +21,6 @@ module Contrast
21
21
  MULTIPART_FIELD_NAME, XML_VALUE, DWR_VALUE
22
22
  ].cs__freeze
23
23
 
24
- class << self
25
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
26
- # @return [Hash] the details for this specific rule
27
- def extract_details attack_sample
28
- {
29
- command: attack_sample.cmdi.command,
30
- startIndex: attack_sample.cmdi.start_idx,
31
- endIndex: attack_sample.cmdi.end_idx
32
- }
33
- end
34
- end
35
-
36
24
  # CMDI infilter:
37
25
  #
38
26
  # @param context [Contrast::Agent::RequestContext] current request contest
@@ -65,11 +53,7 @@ module Contrast
65
53
  result,
66
54
  candidate_string,
67
55
  **kwargs)
68
- if mode == Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION ||
69
- mode == Contrast::Api::Settings::ProtectionRule::Mode::PERMIT
70
-
71
- return result
72
- end
56
+ return result if mode == :NO_ACTION || mode == :PERMIT
73
57
 
74
58
  result ||= build_attack_result(context)
75
59
  update_successful_attack_response(context, input_analysis_result, result, candidate_string)
@@ -96,9 +80,9 @@ module Contrast
96
80
  #
97
81
  # @param context [Contrast::Agent::RequestContext]
98
82
  # @param potential_attack_string [String, nil]
99
- # @param ia_results [Array<Contrast::Api::Settings::InputAnalysis>]
83
+ # @param ia_results [Array<Contrast::Agent::Reporting::InputAnalysis>]
100
84
  # @param **kwargs
101
- # @return [Contrast::Api::Dtm::AttackResult, nil]
85
+ # @return [Contrast::Agent::Reporting, nil]
102
86
  def find_attacker_with_results context, potential_attack_string, ia_results, **kwargs
103
87
  logger.trace('Checking vectors for attacks', rule: rule_name, input: potential_attack_string)
104
88
  result = super(context, potential_attack_string, ia_results, **kwargs) if ia_results
@@ -110,14 +94,15 @@ module Contrast
110
94
 
111
95
  # Build a subclass of the RaspRuleSample using the query string and the
112
96
  # evaluation
113
- def build_sample context, input_analysis_result, candidate_string, **_kwargs
97
+ def build_sample context, input_analysis_result, candidate_string, **kwargs
114
98
  sample = build_base_sample(context, input_analysis_result)
115
99
  sample.details = Contrast::Agent::Reporting::Details::CmdInjectionDetails.new
116
100
 
101
+ # extract data from kwargs for the agent_lib check
102
+ agent_lib_result_struct = kwargs[:result_struct]
117
103
  command = candidate_string || input_analysis_result.value
118
104
  command = Contrast::Utils::StringUtils.protobuf_safe_string(command)
119
- sample.details.cmd = command
120
- sample.details.end_idx = command.length
105
+ handle_with_agent_lib(sample, agent_lib_result_struct, command)
121
106
 
122
107
  # This is a special case where the user input is UNKNOWN_USER_INPUT but
123
108
  # we want to send the attack value
@@ -162,6 +147,21 @@ module Contrast
162
147
  def report_any_command_execution?
163
148
  ::Contrast::PROTECT.report_any_command_execution?
164
149
  end
150
+
151
+ # handle agent_lib data being attached
152
+ def handle_with_agent_lib sample, agent_lib_result_struct, command
153
+ sample.details.cmd = command
154
+ if agent_lib_result_struct&.cs__is_a?(Hash)
155
+ sample.details.start_idx = agent_lib_result_struct[:start_index]
156
+ sample.details.end_idx = if (agent_lib_result_struct[:end_index]).zero?
157
+ command.length
158
+ else
159
+ agent_lib_result_struct[:end_index]
160
+ end
161
+ else
162
+ sample.details.end_idx = command.length
163
+ end
164
+ end
165
165
  end
166
166
  end
167
167
  end
@@ -0,0 +1,64 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ require 'contrast/agent/protect/rule/base_service'
5
+ require 'contrast/agent/request_context'
6
+ require 'contrast/utils/object_share'
7
+ require 'contrast/agent/protect/rule/cmdi/cmdi_base_rule'
8
+
9
+ module Contrast
10
+ module Agent
11
+ module Protect
12
+ module Rule
13
+ # The Ruby implementation of the Protect Command Injection Semantic
14
+ # Chained Command sub-rule. This rule should report
15
+ class CmdiChainedCommand < Contrast::Agent::Protect::Rule::CmdiBaseRule
16
+ NAME = 'cmd-injection-semantic-chained-commands'
17
+
18
+ def rule_name
19
+ NAME
20
+ end
21
+
22
+ def sub_rules
23
+ Contrast::Utils::ObjectShare::EMPTY_ARRAY
24
+ end
25
+
26
+ protected
27
+
28
+ # Used to customize the raised error message.
29
+ #
30
+ # @param classname [String] Name of the class
31
+ # @param method [String] name of the method triggering the rule
32
+ # @raise [Contrast::SecurityException]
33
+ def raise_error classname, method
34
+ raise(Contrast::SecurityException.new(self,
35
+ 'Command Injection Semantic Chained Commands rule triggered. '\
36
+ "Call to #{ classname }.#{ method } blocked."))
37
+ end
38
+
39
+ private
40
+
41
+ def find_probable_attacker context, potential_attack_string, _ia_results, **kwargs
42
+ chained = chained_command?(potential_attack_string)
43
+ return unless chained
44
+
45
+ build_attack_with_match(context, nil, nil, potential_attack_string, **kwargs)
46
+ end
47
+
48
+ # Check if potential chained attack is detected in user input.
49
+ #
50
+ # @param command [String] command to check.
51
+ # @return index[Boolean Returns the index of the command chaining if found.
52
+ # If the chaining index is >= 0, an injection is detected. Returns -1 when no
53
+ # command chaining is found.
54
+ def chained_command? command
55
+ return false unless (agent_lib = Contrast::AGENT_LIB) && command
56
+ return false if agent_lib.chained_cmdi_index(command).negative?
57
+
58
+ true
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ require 'contrast/agent/protect/rule/base_service'
5
+ require 'contrast/agent/request_context'
6
+ require 'contrast/utils/object_share'
7
+ require 'contrast/agent/protect/rule/cmdi/cmdi_base_rule'
8
+
9
+ module Contrast
10
+ module Agent
11
+ module Protect
12
+ module Rule
13
+ # The Ruby implementation of the Protect Command Injection Semantic
14
+ # Dangerous Path sub-rule. This rule should report
15
+ class CmdiDangerousPath < Contrast::Agent::Protect::Rule::CmdiBaseRule
16
+ NAME = 'cmd-injection-semantic-dangerous-paths'
17
+
18
+ def rule_name
19
+ NAME
20
+ end
21
+
22
+ def sub_rules
23
+ Contrast::Utils::ObjectShare::EMPTY_ARRAY
24
+ end
25
+
26
+ protected
27
+
28
+ # Used to customize the raised error message.
29
+ #
30
+ # @param classname [String] Name of the class
31
+ # @param method [String] name of the method triggering the rule
32
+ # @raise [Contrast::SecurityException]
33
+ def raise_error classname, method
34
+ raise(Contrast::SecurityException.new(self,
35
+ 'Command Injection Dangerous Path rule triggered. '\
36
+ "Call to #{ classname }.#{ method } blocked."))
37
+ end
38
+
39
+ private
40
+
41
+ def find_probable_attacker context, potential_attack_string, _ia_results, **kwargs
42
+ dangerous_path = dangerous_path?(potential_attack_string)
43
+ return unless dangerous_path
44
+
45
+ build_attack_with_match(context, nil, nil, potential_attack_string, **kwargs)
46
+ end
47
+
48
+ # Checks if a given shell command is trying to access a dangerous path.
49
+ # This is used for the cmd-injection-semantic-dangerous-paths rule.
50
+ #
51
+ # @param path [String] path to check.
52
+ # @return index[Boolean] Returns true if a dangerous path is found.
53
+ # Returns false if no dangerous paths are found.
54
+ def dangerous_path? path
55
+ return false unless (agent_lib = Contrast::AGENT_LIB) && path
56
+
57
+ agent_lib.dangerous_path?(path)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,13 +1,10 @@
1
1
  # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'contrast/utils/object_share'
5
- require 'contrast/agent/reporting/input_analysis/input_type'
6
4
  require 'contrast/agent/protect/rule/cmd_injection'
7
5
  require 'contrast/agent/reporting/input_analysis/score_level'
8
- require 'contrast/agent/protect/rule/cmdi/cmdi_worth_watching'
9
6
  require 'contrast/agent/protect/input_analyzer/input_analyzer'
10
- require 'contrast/utils/input_classification'
7
+ require 'contrast/utils/input_classification_base'
11
8
  require 'contrast/components/logger'
12
9
 
13
10
  module Contrast
@@ -18,63 +15,10 @@ module Contrast
18
15
  # as a result input would be marked as WORTHWATCHING or IGNORE,
19
16
  # to be analyzed at the sink level.
20
17
  module CmdiInputClassification
18
+ WORTHWATCHING_MATCH = 'cmdi-worth-watching-v2'.cs__freeze
21
19
  class << self
22
20
  include InputClassificationBase
23
- include Contrast::Agent::Protect::Rule::CmdiWorthWatching
24
21
  include Contrast::Components::Logger::InstanceMethods
25
-
26
- WORTHWATCHING_MATCH = 'cmdi-worth-watching-v2'
27
- CMDI_KEYS_NEEDED = [
28
- COOKIE_VALUE, PARAMETER_VALUE, JSON_VALUE, MULTIPART_VALUE, XML_VALUE, DWR_VALUE
29
- ].cs__freeze
30
-
31
- # This method will determine actually if the user input is WORTHWATCHING
32
- #
33
- # @param input_type [Contrast::Agent::Reporting::InputType] the type of the user input
34
- # @param value [String, Array<String>] the value of the input
35
- # @param input_analysis [Contrast::Agent::Reporting::InputAnalysis] Holds all the results from the input
36
- # analysis from the current request.
37
- def classify input_type, value, input_analysis
38
- return unless Contrast::Agent::Protect::Rule::CmdInjection::APPLICABLE_USER_INPUTS.include?(input_type)
39
- return unless super
40
-
41
- rule_id = Contrast::Agent::Protect::Rule::CmdInjection::NAME
42
-
43
- Array(value).each do |val|
44
- Array(val).each do |v|
45
- input_analysis.results << cmdi_create_new_input_result(input_analysis.request, rule_id, input_type, v)
46
- end
47
- end
48
-
49
- input_analysis
50
- rescue StandardError => e
51
- logger.debug('An Error was recorded in the input classification of the cmdi.')
52
- logger.debug(e)
53
- end
54
-
55
- private
56
-
57
- # This methods checks if input is tagged WORTHWATCHING or IGNORE matches value with it's
58
- # key if needed and Creates new instance of InputAnalysisResult.
59
- #
60
- # @param request [Contrast::Agent::Request] the current request context.
61
- # @param rule_id [String] The name of the Protect Rule.
62
- # @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
63
- # @param value [String, Array<String>] the value of the input.
64
- #
65
- # @return res [Contrast::Agent::Reporting::InputAnalysisResult]
66
- def cmdi_create_new_input_result request, rule_id, input_type, value
67
- ia_result = new_ia_result(rule_id, input_type, request.path, value)
68
- if cmdi_worth_watching?(value)
69
- ia_result.score_level = WORTHWATCHING
70
- ia_result.ids << WORTHWATCHING_MATCH
71
- else
72
- ia_result.score_level = IGNORE
73
- end
74
-
75
- add_needed_key(request, ia_result, input_type, value) if CMDI_KEYS_NEEDED.include?(input_type)
76
- ia_result
77
- end
78
22
  end
79
23
  end
80
24
  end
@@ -5,7 +5,7 @@
5
5
  # state, indicating a successful attack using SQL or NoSQL Injection.
6
6
  #
7
7
  # @deprecated RUBY-356: this class and those that extend it are being phased out
8
- # in favor of the more performant code in the Service.
8
+ # in favor of the more performant code in the Agent Library.
9
9
  class Contrast::Agent::Protect::Rule::DefaultScanner # rubocop:disable Style/ClassAndModuleChildren
10
10
  OPERATOR_PATTERN = %r{[+=*^/%><!-]}.cs__freeze
11
11
 
@@ -43,17 +43,6 @@ module Contrast
43
43
  # Used to indicate to TeamServer the gadget is an Arel module
44
44
  AREL = 'Arel'
45
45
 
46
- class << self
47
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
48
- # @return [Hash] the details for this specific rule
49
- def extract_details attack_sample
50
- {
51
- command: attack_sample.untrusted_deserialization.command,
52
- deserializer: attack_sample.untrusted_deserialization.deserializer
53
- }
54
- end
55
- end
56
-
57
46
  # Return the TeamServer understood id / name of this rule.
58
47
  # @return [String] the TeamServer understood id / name of this rule.
59
48
  def rule_name
@@ -127,7 +116,7 @@ module Contrast
127
116
  # Build the RaspRuleSample for the detected Deserialization attack.
128
117
  # @param context [Contrast::Agent::RequestContext] the request
129
118
  # context in which this attack is occurring.
130
- # @param input_analysis_result [Contrast::Api::Settings::InputAnalysisResult]
119
+ # @param input_analysis_result [Contrast::Agent::Reporting::InputAnalysis]
131
120
  # the result of the analysis done by this rule.
132
121
  # @param _candidate_string [nil] unused.
133
122
  # @param kwargs [Hash, nil] Hash of inputs used by this rule to flesh
@@ -156,10 +145,10 @@ module Contrast
156
145
  # @param gadget_string [String] the input to be deserialized in which
157
146
  # the gadget exists or the command that resulted from deserializing
158
147
  # an input not detected in the initial infilter.
159
- # @return [Contrast::Api::Settings::InputAnalysisResult] the result
148
+ # @return [Contrast::Agent::Reporting::InputAnalysisResult] the result
160
149
  # of the analysis done by this rule.
161
150
  def build_evaluation gadget_string
162
- ia_result = Contrast::Api::Settings::InputAnalysisResult.new
151
+ ia_result = Contrast::Agent::Reporting::InputAnalysisResult.new
163
152
  ia_result.rule_id = rule_name
164
153
  ia_result.input_type = :UNKNOWN
165
154
  ia_result.key = INPUT_NAME
@@ -5,7 +5,7 @@ require 'contrast/utils/object_share'
5
5
  require 'contrast/agent/protect/input_analyzer/input_analyzer'
6
6
  require 'contrast/agent/reporting/attack_result/attack_result'
7
7
  require 'contrast/agent/reporting/attack_result/rasp_rule_sample'
8
- require 'contrast/utils/input_classification'
8
+ require 'contrast/utils/input_classification_base'
9
9
 
10
10
  module Contrast
11
11
  module Agent
@@ -36,7 +36,7 @@ module Contrast
36
36
  #
37
37
  # attack_result = build_attack_result ia_result, rule_id
38
38
  #
39
- # if Contrast::Api::Settings::ProtectionRule::Mode::BLOCK != Contrast::PROTECT.rule_mode(rule_id)
39
+ # if :BLOCK != Contrast::PROTECT.rule_mode(rule_id)
40
40
  # attack_result.response = :EXPLOITED
41
41
  # Contrast::Agent::EXPLOITS.push attack_result
42
42
  # return input_analysis
@@ -20,17 +20,6 @@ module Contrast
20
20
  # UNLOCK UPDATE VERSION-CONTROL
21
21
  # ].cs__freeze
22
22
 
23
- class << self
24
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
25
- # @return [Hash] the details for this specific rule
26
- def extract_details attack_sample
27
- {
28
- method: attack_sample.method_tampering.method, # rubocop:disable Security/Object/Method
29
- responseCode: attack_sample.method_tampering.response_code
30
- }
31
- end
32
- end
33
-
34
23
  def rule_name
35
24
  NAME
36
25
  end
@@ -4,7 +4,7 @@
4
4
  require 'contrast/utils/object_share'
5
5
  require 'contrast/agent/protect/rule/no_sqli'
6
6
  require 'contrast/agent/protect/input_analyzer/input_analyzer'
7
- require 'contrast/utils/input_classification'
7
+ require 'contrast/utils/input_classification_base'
8
8
 
9
9
  module Contrast
10
10
  module Agent
@@ -50,33 +50,26 @@ module Contrast
50
50
  NOSQL_WORTH_WATCHING_THRESHOLD = 1
51
51
  NOSQL_CONFIDENCE_THRESHOLD = 3
52
52
  MAX_DISTANCE = 10
53
-
54
- # Input Classification stage is done to determine if an user input is
55
- # WORTHWATCHING or to be ignored.
56
- #
57
- # @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
58
- # @param value [String, Array<String>] the value of the input.
59
- # @param input_analysis [Contrast::Agent::Reporting::InputAnalysis] Holds all the results from the
60
- # agent analysis from the current
61
- # Request.
62
- # @return ia [Contrast::Agent::Reporting::InputAnalysis] with updated results.
63
- def classify input_type, value, input_analysis
64
- return unless input_analysis.request
65
-
66
- rule_id = Contrast::Agent::Protect::Rule::NoSqli::NAME
67
-
68
- # double check the input to avoid calling match? on array
69
- Array(value).each do |val|
70
- Array(val).each do |v|
71
- input_analysis.results << nosqli_create_new_input_result(input_analysis.request,
72
- rule_id,
73
- input_type,
74
- v)
75
- end
76
- end
77
-
78
- input_analysis
79
- end
53
+ DEFAULT_RULE_DEFINITIONS = [
54
+ {
55
+ keywords: [],
56
+ name: 'nosql-injection',
57
+ patterns: [
58
+ {
59
+ caseSensitive: false,
60
+ id: 'NO-SQLI-1',
61
+ score: 1,
62
+ value: '(?:\\{\\s*\".*\"\\s*:.*\\})'
63
+ },
64
+ {
65
+ id: 'NO-SQLI-2',
66
+ caseSensitive: true,
67
+ score: 3,
68
+ value: "(?:\"|')?\\$(?:gte|gt|lt|lte|eq|ne|in|nin|where|mod|all|size|exists|type|slice|or)(?:\"|')?\\s*:.*" # rubocop:disable Layout/LineLength
69
+ }
70
+ ]
71
+ }
72
+ ].cs__freeze
80
73
 
81
74
  private
82
75
 
@@ -102,7 +95,7 @@ module Contrast
102
95
  # @param value [String, Array<String>] the value of the input.
103
96
  #
104
97
  # @return res [Contrast::Agent::Reporting::InputAnalysisResult]
105
- def nosqli_create_new_input_result request, rule_id, input_type, value
98
+ def create_new_input_result request, rule_id, input_type, value
106
99
  score = evaluate_patterns(value)
107
100
  score = evaluate_rules(value, score)
108
101
 
@@ -113,8 +106,9 @@ module Contrast
113
106
  else
114
107
  IGNORE
115
108
  end
116
-
117
- new_ia_result(rule_id, input_type, score_level, request.path, value)
109
+ result = new_ia_result(rule_id, input_type, score_level, request.path, value)
110
+ add_needed_key(request, result, input_type, value)
111
+ result
118
112
  end
119
113
 
120
114
  # This method evaluates the patterns relevant to NoSQL Injection to check whether
@@ -125,7 +119,7 @@ module Contrast
125
119
  # point is returned.
126
120
  #
127
121
  # @param value [String] the value of the input.
128
- # @param value [Integer] the total score thus far.
122
+ # @param total_score [Integer] the total score thus far.
129
123
  #
130
124
  # @return res [Integer]
131
125
  def evaluate_patterns value, total_score = 0
@@ -159,7 +153,7 @@ module Contrast
159
153
  # point is returned.
160
154
  #
161
155
  # @param value [String] the value of the input.
162
- # @param value [Integer] the total score thus far.
156
+ # @param total_score [Integer] the total score thus far.
163
157
  #
164
158
  # @return res [Integer]
165
159
  def evaluate_rules value, total_score = 0
@@ -209,7 +203,8 @@ module Contrast
209
203
  def nosqli_patterns
210
204
  server_features = Contrast::Agent::Reporting::Settings::ServerFeatures.new
211
205
  rule_definitions = server_features&.protect&.rule_definition_list
212
- rule_definitions&.find { |r| r[:name] == Contrast::Agent::Protect::Rule::NoSqli::NAME }&.dig(:patterns)
206
+ rule_definitions = DEFAULT_RULE_DEFINITIONS if rule_definitions.empty?
207
+ rule_definitions.find { |r| r[:name] == Contrast::Agent::Protect::Rule::NoSqli::NAME }&.dig(:patterns)
213
208
  end
214
209
 
215
210
  def matches_by_position value, pattern
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'contrast/agent/protect/rule/base_service'
5
5
  require 'contrast/agent/protect/rule/sql_sample_builder'
6
+ require 'contrast/agent/reporting/input_analysis/input_type'
6
7
 
7
8
  module Contrast
8
9
  module Agent
@@ -15,22 +16,16 @@ module Contrast
15
16
  include SqlSampleBuilder::NoSqliSample
16
17
  # Defining build_attack_with_match method
17
18
  include SqlSampleBuilder::AttackBuilder
19
+ include Contrast::Agent::Reporting::InputType
18
20
 
19
21
  NAME = 'nosql-injection'
20
22
  BLOCK_MESSAGE = 'NoSQLi rule triggered. Response blocked.'
21
- class << self
22
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
23
- # @return [Hash] the details for this specific rule
24
- def extract_details attack_sample
25
- {
26
- start: attack_sample.no_sqli.start_idx,
27
- end: attack_sample.no_sqli.end_idx,
28
- boundaryOverrunIndex: attack_sample.no_sqli.boundary_overrun_idx,
29
- inputBoundaryIndex: attack_sample.no_sqli.input_boundary_idx,
30
- query: attack_sample.no_sqli.query
31
- }
32
- end
33
- end
23
+ APPLICABLE_USER_INPUTS = [
24
+ BODY, COOKIE_NAME, COOKIE_VALUE, HEADER,
25
+ PARAMETER_NAME, PARAMETER_VALUE, JSON_VALUE,
26
+ MULTIPART_VALUE, MULTIPART_FIELD_NAME,
27
+ XML_VALUE, DWR_VALUE
28
+ ].cs__freeze
34
29
 
35
30
  def rule_name
36
31
  NAME
@@ -40,6 +35,10 @@ module Contrast
40
35
  BLOCK_MESSAGE
41
36
  end
42
37
 
38
+ def applicable_user_inputs
39
+ APPLICABLE_USER_INPUTS
40
+ end
41
+
43
42
  # @raise [Contrast::SecurityException] if the attack is blocked
44
43
  # raised with BLOCK_MESSAGE
45
44
  def infilter context, database, query_string
@@ -55,11 +54,7 @@ module Contrast
55
54
  end
56
55
 
57
56
  def build_attack_with_match context, input_analysis_result, result, candidate_string, **kwargs
58
- if mode == Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION ||
59
- mode == Contrast::Api::Settings::ProtectionRule::Mode::PERMIT
60
-
61
- return result
62
- end
57
+ return result if mode == :NO_ACTION || mode == :PERMIT
63
58
 
64
59
  result ||= build_attack_result(context)
65
60
  update_successful_attack_response(context, input_analysis_result, result, candidate_string)
@@ -67,6 +62,18 @@ module Contrast
67
62
  result
68
63
  end
69
64
 
65
+ # @param context [Contrast::Agent::RequestContext]
66
+ def infilter? context
67
+ return false unless enabled?
68
+ return false unless context&.agent_input_analysis&.results&.any? do |result|
69
+ result.rule_id == rule_name
70
+ end
71
+
72
+ return false if protect_excluded_by_code?
73
+
74
+ true
75
+ end
76
+
70
77
  protected
71
78
 
72
79
  def find_attacker context, potential_attack_string, **kwargs
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ require 'contrast/utils/input_classification_base'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Protect
9
+ module Rule
10
+ # The Ruby implementation of the Protect Path Traversal rule
11
+ # Input classification
12
+ module PathTraversalInputClassification
13
+ PATH_TRAVERSAL_MATCH = 'path-traversal-input-tracing-v1'
14
+ WORTHWATCHING_MATCH = 'path-traversal-worth-watching-v2'
15
+
16
+ THRESHOLD = 90.cs__freeze
17
+ class << self
18
+ include InputClassificationBase
19
+
20
+ private
21
+
22
+ # This methods checks if input is tagged DEFINITEATTACK or IGNORE matches value with it's
23
+ # key if needed and Creates new isntance of InputAnalysisResult.
24
+ #
25
+ # @param request [Contrast::Agent::Request] the current request context.
26
+ # @param rule_id [String] The name of the Protect Rule.
27
+ # @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
28
+ # @param value [String, Array<String>] the value of the input.
29
+ #
30
+ # @return res [Contrast::Agent::Reporting::InputAnalysisResult]
31
+ def create_new_input_result request, rule_id, input_type, value
32
+ return unless Contrast::AGENT_LIB
33
+
34
+ input_eval = Contrast::AGENT_LIB.eval_input(value,
35
+ convert_input_type(input_type),
36
+ Contrast::AGENT_LIB.rule_set[rule_id],
37
+ Contrast::AGENT_LIB.eval_option[:WORTHWATCHING])
38
+
39
+ ia_result = new_ia_result(rule_id, input_type, request.path, value)
40
+ score = input_eval&.score || 0
41
+ if score >= THRESHOLD
42
+ ia_result.score_level = DEFINITEATTACK
43
+ ia_result.ids << PATH_TRAVERSAL_MATCH
44
+ elsif score == 10
45
+ # There is one pattern to match 10 and thus on its own will be reported as a probe.
46
+ # This rule can report WORTHWATCHING:
47
+ # https://protect-spec.prod.dotnet.contsec.com/rules/path-traversal.html#applicable-input-types
48
+ ia_result.score_level = WORTHWATCHING
49
+ ia_result.ids << WORTHWATCHING_MATCH
50
+ else
51
+ ia_result.score_level = IGNORE
52
+ end
53
+ add_needed_key(request, ia_result, input_type, value)
54
+ ia_result
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end