contrast-agent 6.6.4 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.gitmodules +0 -3
  4. data/.simplecov +0 -1
  5. data/Rakefile +0 -1
  6. data/ext/cs__assess_array/cs__assess_array.c +41 -10
  7. data/ext/cs__assess_array/cs__assess_array.h +4 -1
  8. data/ext/cs__scope/cs__scope.c +1 -1
  9. data/lib/contrast/agent/assess/contrast_event.rb +2 -24
  10. data/lib/contrast/agent/assess/events/source_event.rb +7 -61
  11. data/lib/contrast/agent/assess/finalizers/hash.rb +11 -0
  12. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +0 -55
  13. data/lib/contrast/agent/assess/policy/policy_node.rb +3 -3
  14. data/lib/contrast/agent/assess/policy/policy_node_utils.rb +0 -1
  15. data/lib/contrast/agent/assess/policy/propagation_node.rb +4 -4
  16. data/lib/contrast/agent/assess/policy/source_method.rb +24 -1
  17. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +7 -5
  18. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +6 -1
  19. data/lib/contrast/agent/assess/policy/trigger_method.rb +40 -121
  20. data/lib/contrast/agent/assess/policy/trigger_node.rb +3 -3
  21. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  22. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
  23. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
  24. data/lib/contrast/agent/assess/property/evented.rb +2 -12
  25. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +42 -82
  26. data/lib/contrast/agent/assess/rule/response/base_rule.rb +11 -27
  27. data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -3
  28. data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +77 -62
  29. data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
  30. data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +6 -1
  31. data/lib/contrast/agent/assess/rule/response/header_rule.rb +5 -5
  32. data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +1 -1
  33. data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +1 -1
  34. data/lib/contrast/agent/assess/tracker.rb +1 -7
  35. data/lib/contrast/agent/at_exit_hook.rb +1 -7
  36. data/lib/contrast/agent/excluder.rb +224 -0
  37. data/lib/contrast/agent/exclusion_matcher.rb +25 -7
  38. data/lib/contrast/agent/inventory/database_config.rb +18 -23
  39. data/lib/contrast/agent/middleware.rb +4 -5
  40. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
  41. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
  42. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +4 -0
  43. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
  44. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -0
  45. data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
  46. data/lib/contrast/agent/protect/rule/base.rb +98 -66
  47. data/lib/contrast/agent/protect/rule/base_service.rb +49 -24
  48. data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
  49. data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
  50. data/lib/contrast/agent/protect/rule/cmd_injection.rb +30 -99
  51. data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +132 -0
  52. data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +169 -0
  53. data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +69 -0
  54. data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +68 -0
  55. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
  56. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  57. data/lib/contrast/agent/protect/rule/deserialization.rb +10 -19
  58. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
  59. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
  60. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
  61. data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
  62. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
  63. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
  64. data/lib/contrast/agent/protect/rule/path_traversal.rb +46 -18
  65. data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +49 -29
  66. data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +37 -0
  67. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
  68. data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +67 -0
  69. data/lib/contrast/agent/protect/rule/sqli.rb +67 -22
  70. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
  71. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
  72. data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
  73. data/lib/contrast/agent/protect/rule/xss.rb +14 -20
  74. data/lib/contrast/agent/protect/rule/xxe.rb +15 -30
  75. data/lib/contrast/agent/protect/rule.rb +3 -1
  76. data/lib/contrast/agent/reporting/attack_result/attack_result.rb +8 -0
  77. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +70 -36
  78. data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
  79. data/lib/contrast/agent/reporting/attack_result/user_input.rb +11 -0
  80. data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +29 -0
  81. data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +30 -0
  82. data/lib/contrast/agent/reporting/details/details.rb +18 -0
  83. data/lib/contrast/agent/reporting/details/http_method_tempering_details.rb +27 -0
  84. data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +35 -0
  85. data/lib/contrast/agent/reporting/details/no_sqli_details.rb +36 -0
  86. data/lib/contrast/agent/reporting/details/path_traversal_details.rb +24 -0
  87. data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +32 -0
  88. data/lib/contrast/agent/reporting/details/protect_rule_details.rb +17 -0
  89. data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +22 -0
  90. data/lib/contrast/agent/reporting/details/sqli_details.rb +36 -0
  91. data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +27 -0
  92. data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +30 -0
  93. data/lib/contrast/agent/reporting/details/xss_details.rb +33 -0
  94. data/lib/contrast/agent/reporting/details/xss_match.rb +30 -0
  95. data/lib/contrast/agent/reporting/details/xxe_details.rb +36 -0
  96. data/lib/contrast/agent/reporting/details/xxe_match.rb +25 -0
  97. data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +25 -0
  98. data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
  99. data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
  100. data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
  101. data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +17 -3
  102. data/lib/contrast/agent/reporting/masker/masker.rb +80 -65
  103. data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -30
  104. data/lib/contrast/agent/reporting/reporter.rb +1 -15
  105. data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
  106. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +84 -15
  107. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -25
  108. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +19 -24
  109. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +46 -126
  110. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +5 -16
  111. data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +10 -18
  112. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -14
  113. data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +1 -1
  114. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
  115. data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +7 -22
  116. data/lib/contrast/agent/reporting/reporting_events/finding.rb +23 -53
  117. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +12 -9
  118. data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +1 -1
  119. data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +23 -21
  120. data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +5 -18
  121. data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +1 -0
  122. data/lib/contrast/{api/decorators/trace_taint_range_tags.rb → agent/reporting/reporting_events/finding_event_taint_range_tags.rb} +7 -6
  123. data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +40 -10
  124. data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
  125. data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +1 -1
  126. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +2 -2
  127. data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
  128. data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +10 -14
  129. data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +11 -0
  130. data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +3 -1
  131. data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +12 -25
  132. data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +8 -27
  133. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +3 -3
  134. data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +4 -7
  135. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -1
  136. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +2 -1
  137. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +3 -3
  138. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
  139. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +0 -3
  140. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +1 -0
  141. data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
  142. data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
  143. data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
  144. data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
  145. data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
  146. data/lib/contrast/agent/request.rb +4 -14
  147. data/lib/contrast/agent/request_context.rb +18 -24
  148. data/lib/contrast/agent/request_context_extend.rb +23 -164
  149. data/lib/contrast/agent/request_handler.rb +1 -11
  150. data/lib/contrast/agent/response.rb +0 -18
  151. data/lib/contrast/agent/telemetry/events/event.rb +1 -1
  152. data/lib/contrast/agent/telemetry/events/metric_event.rb +1 -1
  153. data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +3 -3
  154. data/lib/contrast/agent/thread_watcher.rb +3 -18
  155. data/lib/contrast/agent/version.rb +1 -1
  156. data/lib/contrast/agent.rb +0 -11
  157. data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
  158. data/lib/contrast/agent_lib/api/init.rb +101 -0
  159. data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
  160. data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
  161. data/lib/contrast/agent_lib/api/panic.rb +87 -0
  162. data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
  163. data/lib/contrast/agent_lib/interface.rb +260 -0
  164. data/lib/contrast/agent_lib/interface_base.rb +118 -0
  165. data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
  166. data/lib/contrast/agent_lib/test.rb +29 -0
  167. data/lib/contrast/api/communication/connection_status.rb +5 -5
  168. data/lib/contrast/components/agent.rb +13 -23
  169. data/lib/contrast/components/api.rb +10 -10
  170. data/lib/contrast/components/app_context.rb +9 -11
  171. data/lib/contrast/components/app_context_extend.rb +1 -26
  172. data/lib/contrast/components/assess.rb +92 -38
  173. data/lib/contrast/components/assess_rules.rb +36 -0
  174. data/lib/contrast/components/config.rb +49 -24
  175. data/lib/contrast/components/heap_dump.rb +1 -1
  176. data/lib/contrast/components/protect.rb +9 -6
  177. data/lib/contrast/components/ruby_component.rb +81 -0
  178. data/lib/contrast/components/sampling.rb +1 -1
  179. data/lib/contrast/components/security_logger.rb +23 -0
  180. data/lib/contrast/components/settings.rb +41 -85
  181. data/lib/contrast/config/base_configuration.rb +1 -1
  182. data/lib/contrast/config/protect_rule_configuration.rb +7 -7
  183. data/lib/contrast/config/protect_rules_configuration.rb +24 -48
  184. data/lib/contrast/config/server_configuration.rb +1 -1
  185. data/lib/contrast/config.rb +0 -6
  186. data/lib/contrast/configuration.rb +73 -18
  187. data/lib/contrast/extension/assess/array.rb +9 -0
  188. data/lib/contrast/extension/assess/exec_trigger.rb +3 -1
  189. data/lib/contrast/extension/assess/marshal.rb +3 -2
  190. data/lib/contrast/extension/assess/string.rb +0 -1
  191. data/lib/contrast/extension/delegator.rb +2 -0
  192. data/lib/contrast/extension/extension.rb +1 -1
  193. data/lib/contrast/framework/base_support.rb +0 -5
  194. data/lib/contrast/framework/grape/support.rb +1 -23
  195. data/lib/contrast/framework/manager.rb +3 -11
  196. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -6
  197. data/lib/contrast/framework/rails/railtie.rb +0 -1
  198. data/lib/contrast/framework/rails/support.rb +5 -59
  199. data/lib/contrast/framework/sinatra/support.rb +2 -21
  200. data/lib/contrast/logger/cef_log.rb +21 -3
  201. data/lib/contrast/logger/log.rb +1 -11
  202. data/lib/contrast/tasks/config.rb +5 -10
  203. data/lib/contrast/utils/assess/event_limit_utils.rb +28 -12
  204. data/lib/contrast/utils/assess/trigger_method_utils.rb +10 -18
  205. data/lib/contrast/utils/duck_utils.rb +1 -0
  206. data/lib/contrast/utils/findings.rb +6 -5
  207. data/lib/contrast/utils/hash_digest.rb +9 -24
  208. data/lib/contrast/utils/hash_digest_extend.rb +6 -6
  209. data/lib/contrast/utils/input_classification_base.rb +156 -0
  210. data/lib/contrast/utils/invalid_configuration_util.rb +21 -58
  211. data/lib/contrast/utils/log_utils.rb +47 -17
  212. data/lib/contrast/utils/net_http_base.rb +2 -2
  213. data/lib/contrast/utils/os.rb +0 -20
  214. data/lib/contrast/utils/patching/policy/patch_utils.rb +3 -2
  215. data/lib/contrast/utils/response_utils.rb +0 -16
  216. data/lib/contrast/utils/stack_trace_utils.rb +3 -40
  217. data/lib/contrast/utils/string_utils.rb +19 -7
  218. data/lib/contrast/utils/telemetry_client.rb +13 -7
  219. data/lib/contrast.rb +7 -13
  220. data/resources/protect/policy.json +1 -2
  221. data/ruby-agent.gemspec +2 -5
  222. metadata +78 -137
  223. data/exe/contrast_service +0 -23
  224. data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
  225. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
  226. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
  227. data/lib/contrast/agent/reaction_processor.rb +0 -47
  228. data/lib/contrast/agent/reporting/reporting_events/trace_event_source.rb +0 -30
  229. data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +0 -43
  230. data/lib/contrast/agent/service_heartbeat.rb +0 -35
  231. data/lib/contrast/api/communication/messaging_queue.rb +0 -129
  232. data/lib/contrast/api/communication/response_processor.rb +0 -90
  233. data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
  234. data/lib/contrast/api/communication/socket.rb +0 -44
  235. data/lib/contrast/api/communication/socket_client.rb +0 -130
  236. data/lib/contrast/api/communication/speedracer.rb +0 -142
  237. data/lib/contrast/api/communication/tcp_socket.rb +0 -32
  238. data/lib/contrast/api/communication/unix_socket.rb +0 -28
  239. data/lib/contrast/api/communication.rb +0 -20
  240. data/lib/contrast/api/decorators/activity.rb +0 -33
  241. data/lib/contrast/api/decorators/address.rb +0 -59
  242. data/lib/contrast/api/decorators/agent_startup.rb +0 -57
  243. data/lib/contrast/api/decorators/application_settings.rb +0 -42
  244. data/lib/contrast/api/decorators/application_startup.rb +0 -56
  245. data/lib/contrast/api/decorators/architecture_component.rb +0 -36
  246. data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
  247. data/lib/contrast/api/decorators/finding.rb +0 -29
  248. data/lib/contrast/api/decorators/http_request.rb +0 -137
  249. data/lib/contrast/api/decorators/input_analysis.rb +0 -18
  250. data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
  251. data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
  252. data/lib/contrast/api/decorators/message.rb +0 -71
  253. data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -58
  254. data/lib/contrast/api/decorators/response_type.rb +0 -17
  255. data/lib/contrast/api/decorators/route_coverage.rb +0 -91
  256. data/lib/contrast/api/decorators/server_features.rb +0 -25
  257. data/lib/contrast/api/decorators/trace_event.rb +0 -120
  258. data/lib/contrast/api/decorators/trace_event_object.rb +0 -63
  259. data/lib/contrast/api/decorators/trace_event_signature.rb +0 -69
  260. data/lib/contrast/api/decorators/trace_taint_range.rb +0 -52
  261. data/lib/contrast/api/decorators/user_input.rb +0 -51
  262. data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
  263. data/lib/contrast/api/decorators.rb +0 -28
  264. data/lib/contrast/api/dtm.pb.rb +0 -852
  265. data/lib/contrast/api/settings.pb.rb +0 -500
  266. data/lib/contrast/api.rb +0 -16
  267. data/lib/contrast/components/contrast_service.rb +0 -88
  268. data/lib/contrast/config/assess_configuration.rb +0 -93
  269. data/lib/contrast/config/assess_rules_configuration.rb +0 -32
  270. data/lib/contrast/config/root_configuration.rb +0 -90
  271. data/lib/contrast/config/ruby_configuration.rb +0 -81
  272. data/lib/contrast/config/service_configuration.rb +0 -49
  273. data/lib/contrast/tasks/service.rb +0 -84
  274. data/lib/contrast/utils/input_classification.rb +0 -73
  275. data/lib/contrast/utils/preflight_util.rb +0 -13
  276. data/lib/protobuf/code_generator.rb +0 -129
  277. data/lib/protobuf/decoder.rb +0 -28
  278. data/lib/protobuf/deprecation.rb +0 -117
  279. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
  280. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
  281. data/lib/protobuf/descriptors.rb +0 -3
  282. data/lib/protobuf/encoder.rb +0 -11
  283. data/lib/protobuf/enum.rb +0 -365
  284. data/lib/protobuf/exceptions.rb +0 -9
  285. data/lib/protobuf/field/base_field.rb +0 -380
  286. data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
  287. data/lib/protobuf/field/bool_field.rb +0 -64
  288. data/lib/protobuf/field/bytes_field.rb +0 -67
  289. data/lib/protobuf/field/double_field.rb +0 -25
  290. data/lib/protobuf/field/enum_field.rb +0 -56
  291. data/lib/protobuf/field/field_array.rb +0 -102
  292. data/lib/protobuf/field/field_hash.rb +0 -122
  293. data/lib/protobuf/field/fixed32_field.rb +0 -25
  294. data/lib/protobuf/field/fixed64_field.rb +0 -28
  295. data/lib/protobuf/field/float_field.rb +0 -43
  296. data/lib/protobuf/field/int32_field.rb +0 -21
  297. data/lib/protobuf/field/int64_field.rb +0 -34
  298. data/lib/protobuf/field/integer_field.rb +0 -23
  299. data/lib/protobuf/field/message_field.rb +0 -51
  300. data/lib/protobuf/field/sfixed32_field.rb +0 -27
  301. data/lib/protobuf/field/sfixed64_field.rb +0 -28
  302. data/lib/protobuf/field/signed_integer_field.rb +0 -29
  303. data/lib/protobuf/field/sint32_field.rb +0 -21
  304. data/lib/protobuf/field/sint64_field.rb +0 -21
  305. data/lib/protobuf/field/string_field.rb +0 -51
  306. data/lib/protobuf/field/uint32_field.rb +0 -21
  307. data/lib/protobuf/field/uint64_field.rb +0 -21
  308. data/lib/protobuf/field/varint_field.rb +0 -77
  309. data/lib/protobuf/field.rb +0 -74
  310. data/lib/protobuf/generators/base.rb +0 -85
  311. data/lib/protobuf/generators/enum_generator.rb +0 -39
  312. data/lib/protobuf/generators/extension_generator.rb +0 -27
  313. data/lib/protobuf/generators/field_generator.rb +0 -193
  314. data/lib/protobuf/generators/file_generator.rb +0 -262
  315. data/lib/protobuf/generators/group_generator.rb +0 -122
  316. data/lib/protobuf/generators/message_generator.rb +0 -104
  317. data/lib/protobuf/generators/option_generator.rb +0 -17
  318. data/lib/protobuf/generators/printable.rb +0 -160
  319. data/lib/protobuf/generators/service_generator.rb +0 -50
  320. data/lib/protobuf/lifecycle.rb +0 -33
  321. data/lib/protobuf/logging.rb +0 -39
  322. data/lib/protobuf/message/fields.rb +0 -233
  323. data/lib/protobuf/message/serialization.rb +0 -85
  324. data/lib/protobuf/message.rb +0 -241
  325. data/lib/protobuf/optionable.rb +0 -72
  326. data/lib/protobuf/tasks/compile.rake +0 -80
  327. data/lib/protobuf/tasks.rb +0 -1
  328. data/lib/protobuf/varint.rb +0 -20
  329. data/lib/protobuf/varint_pure.rb +0 -31
  330. data/lib/protobuf/version.rb +0 -3
  331. data/lib/protobuf/wire_type.rb +0 -10
  332. data/lib/protobuf.rb +0 -91
  333. data/proto/dynamic_discovery.proto +0 -46
  334. data/proto/google/protobuf/compiler/plugin.proto +0 -183
  335. data/proto/google/protobuf/descriptor.proto +0 -911
  336. data/proto/rpc.proto +0 -71
  337. data/service_executables/.gitkeep +0 -0
  338. data/service_executables/VERSION +0 -1
  339. data/service_executables/linux/contrast-service +0 -0
  340. data/service_executables/mac/contrast-service +0 -0
@@ -0,0 +1,58 @@
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 Reflected XSS rule
11
+ # Input classification
12
+ module ReflectedXssInputClassification
13
+ REFLECTED_XSS_MATCH = 'reflected-xss-input-tracing-v1'.cs__freeze
14
+ WORTHWATCHING_MATCH = 'xss-worth-watching-v2'.cs__freeze
15
+ class << self
16
+ include InputClassificationBase
17
+
18
+ private
19
+
20
+ # This methods checks if input is tagged WORTHWATCHING or IGNORE matches value with it's
21
+ # key if needed and Creates new isntance of InputAnalysisResult.
22
+ #
23
+ # @param request [Contrast::Agent::Request] the current request context.
24
+ # @param rule_id [String] The name of the Protect Rule.
25
+ # @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
26
+ # @param value [String, Array<String>] the value of the input.
27
+ #
28
+ # @return res [Contrast::Agent::Reporting::InputAnalysisResult]
29
+ def create_new_input_result request, rule_id, input_type, value
30
+ return unless Contrast::AGENT_LIB
31
+
32
+ input_eval = Contrast::AGENT_LIB.eval_input(value,
33
+ convert_input_type(input_type),
34
+ Contrast::AGENT_LIB.rule_set[rule_id],
35
+ Contrast::AGENT_LIB.
36
+ eval_option[:WORTHWATCHING])
37
+
38
+ score = input_eval&.score || 0
39
+ ia_result = new_ia_result(rule_id, input_type, request.path, value)
40
+ if score >= THRESHOLD
41
+ ia_result.score_level = DEFINITEATTACK
42
+ ia_result.ids << REFLECTED_XSS_MATCH
43
+ elsif score >= WORTHWATCHING_THRESHOLD
44
+ ia_result.score_level = WORTHWATCHING
45
+ ia_result.ids << WORTHWATCHING_MATCH
46
+ else
47
+ ia_result.score_level = IGNORE
48
+ end
49
+
50
+ add_needed_key(request, ia_result, input_type, value)
51
+ ia_result
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -9,37 +9,31 @@ module Contrast
9
9
  module Rule
10
10
  # The Ruby implementation of the Protect Cross-Site Scripting rule.
11
11
  class Xss < Contrast::Agent::Protect::Rule::BaseService
12
+ include Contrast::Agent::Reporting::InputType
12
13
  NAME = 'reflected-xss'
13
14
  BLOCK_MESSAGE = 'XSS rule triggered. Response blocked.'
14
15
 
15
- class << self
16
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
17
- # @return [Hash] the details for this specific rule
18
- def extract_details attack_sample
19
- # TODO: RUBY-1702 - figure out why xss isn't populated when reported; probably something to do w/
20
- # suspicious
21
- return Contrast::Utils::ObjectShare::EMPTY_HASH unless attack_sample&.xss
22
-
23
- {
24
- input: attack_sample.xss.input,
25
- matches: attack_sample.xss.matches.map do |match|
26
- {
27
- evidenceStart: match.evidence_start_ms,
28
- evidence: match.evidence,
29
- offset: match.offset
30
- }
31
- end
32
- }
33
- end
34
- end
16
+ APPLICABLE_USER_INPUTS = [
17
+ BODY, PARAMETER_NAME, PARAMETER_VALUE, JSON_VALUE,
18
+ MULTIPART_VALUE, MULTIPART_FIELD_NAME, XML_VALUE,
19
+ DWR_VALUE, URI, QUERYSTRING
20
+ ].cs__freeze
35
21
 
36
22
  def rule_name
37
23
  NAME
38
24
  end
39
25
 
26
+ def block_message
27
+ BLOCK_MESSAGE
28
+ end
29
+
40
30
  def stream_safe?
41
31
  false
42
32
  end
33
+
34
+ def applicable_user_inputs
35
+ APPLICABLE_USER_INPUTS
36
+ end
43
37
  end
44
38
  end
45
39
  end
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/protect/rule/base'
5
+ require 'contrast/agent/reporting/details/xxe_details'
6
+ require 'contrast/agent/reporting/details/xxe_match'
7
+ require 'contrast/agent/reporting/details/xxe_wrapper'
5
8
  require 'contrast/utils/timer'
6
9
  require 'contrast/components/logger'
7
10
 
@@ -19,28 +22,6 @@ module Contrast
19
22
  BLOCK_MESSAGE = 'XXE rule triggered. Response blocked.'
20
23
  EXTERNAL_ENTITY_PATTERN = /<!ENTITY\s+[a-zA-Z0-f]+\s+(?:SYSTEM|PUBLIC)\s+(.*?)>/.cs__freeze
21
24
 
22
- class << self
23
- # @param attack_sample [Contrast::Api::Dtm::RaspRuleSample]
24
- # @return [Hash] the details for this specific rule
25
- def extract_details attack_sample
26
- {
27
- xml: attack_sample.xxe.xml,
28
- declaredEntities: attack_sample.xxe.declared_entities.map do |entity|
29
- {
30
- start: entity.start_idx,
31
- end: entity.end_idx
32
- }
33
- end,
34
- entitiesResolved: attack_sample.xxe.entities_resolved.map do |entity|
35
- {
36
- systemId: entity.system_id,
37
- publicId: entity.public_id
38
- }
39
- end
40
- }
41
- end
42
- end
43
-
44
25
  def rule_name
45
26
  NAME
46
27
  end
@@ -56,13 +37,15 @@ module Contrast
56
37
  # @raise [Contrast::SecurityException] Security exception if an XXE
57
38
  # attack is found and the rule is in block mode.
58
39
  def infilter context, framework, xml
40
+ return if protect_excluded_by_url?(context)
41
+
59
42
  result = find_attacker(context, xml, framework: framework)
60
43
  return unless result
61
44
 
62
45
  append_to_activity(context, result)
63
46
  return unless blocked?
64
47
 
65
- cef_logging(result, :successful_attack, xml)
48
+ cef_logging(result, :successful_attack, value: xml)
66
49
  raise(Contrast::SecurityException.new(self, BLOCK_MESSAGE))
67
50
  end
68
51
 
@@ -76,7 +59,7 @@ module Contrast
76
59
  # @param xml [String] the literal value of the XML being checked for
77
60
  # external entity resolution
78
61
  # @param _kwargs [Hash]
79
- # @return [Contrast::Api::Dtm::AttackResult, nil] the determination
62
+ # @return [Contrast::Agent::Reporting, nil] the determination
80
63
  # as to whether or not this XML has an XXE attack in it.
81
64
  def find_attacker context, xml, **_kwargs
82
65
  return unless xml
@@ -105,7 +88,7 @@ module Contrast
105
88
  entity_wrapper = Contrast::Agent::Protect::Rule::Xxe::EntityWrapper.new(ss.matched)
106
89
  next unless entity_wrapper.external_entity?
107
90
 
108
- xxe_details ||= Contrast::Api::Dtm::XxeDetails.new
91
+ xxe_details ||= Contrast::Agent::Reporting::Details::XxeDetails.new
109
92
  xxe_details.declared_entities << build_match(ss)
110
93
  xxe_details.entities_resolved << build_wrapper(entity_wrapper)
111
94
  end
@@ -119,12 +102,12 @@ module Contrast
119
102
  def build_sample context, ia_result, _url, **kwargs
120
103
  sample = build_base_sample(context, ia_result)
121
104
  sample.user_input = build_user_input(ia_result)
122
- sample.xxe = kwargs[:details]
105
+ sample.details = kwargs[:details]
123
106
  sample
124
107
  end
125
108
 
126
109
  def build_user_input ia_result
127
- input = Contrast::Api::Dtm::UserInput.new
110
+ input = Contrast::Agent::Reporting::UserInput.new
128
111
  input.key = INPUT_NAME
129
112
  input.input_type = :UNKNOWN
130
113
  input.document_type = :XML
@@ -137,8 +120,10 @@ module Contrast
137
120
  # We know that this attack happened, so the result is always matched
138
121
  # and the level is always critical. Only variable is the XML value
139
122
  # supplied by the attacker.
123
+ #
124
+ # @return [Contrast::Agent::Reporting::InputAnalysisResult]
140
125
  def build_evaluation xml
141
- ia_result = Contrast::Api::Settings::InputAnalysisResult.new
126
+ ia_result = Contrast::Agent::Reporting::InputAnalysisResult.new
142
127
  ia_result.rule_id = rule_name
143
128
  ia_result.input_type = :UNKNOWN
144
129
  ia_result.value = Contrast::Utils::StringUtils.protobuf_safe_string(xml)
@@ -146,14 +131,14 @@ module Contrast
146
131
  end
147
132
 
148
133
  def build_match string_scanner
149
- match = Contrast::Api::Dtm::XxeMatch.new
134
+ match = Contrast::Agent::Reporting::Details::XxeMatch.new
150
135
  match.end_idx = string_scanner.pos.to_i
151
136
  match.start_idx = match.end_idx - string_scanner.matched_size
152
137
  match
153
138
  end
154
139
 
155
140
  def build_wrapper entity_wrapper
156
- wrapper = Contrast::Api::Dtm::XxeWrapper.new
141
+ wrapper = Contrast::Agent::Reporting::Details::XxeWrapper.new
157
142
  wrapper.system_id = Contrast::Utils::StringUtils.protobuf_safe_string(entity_wrapper.system_id)
158
143
  wrapper.public_id = Contrast::Utils::StringUtils.protobuf_safe_string(entity_wrapper.public_id)
159
144
  wrapper
@@ -28,12 +28,14 @@ require 'contrast/agent/protect/rule/sqli/default_sql_scanner'
28
28
  require 'contrast/agent/protect/rule/sqli/mysql_sql_scanner'
29
29
  require 'contrast/agent/protect/rule/sqli/postgres_sql_scanner'
30
30
  require 'contrast/agent/protect/rule/sqli/sqlite_sql_scanner'
31
+ require 'contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions'
31
32
 
32
33
  # The classes required for Path Traversal
33
34
  require 'contrast/agent/protect/rule/path_traversal'
34
35
 
35
- # The classes required for Command Injection
36
+ # The classes required for Command Injection and sub-rules
36
37
  require 'contrast/agent/protect/rule/cmd_injection'
38
+ require 'contrast/agent/protect/rule/cmdi/cmdi_backdoors'
37
39
 
38
40
  # The classes required for XXE
39
41
  require 'contrast/agent/protect/rule/xxe'
@@ -57,6 +57,14 @@ module Contrast
57
57
  def tags= tags
58
58
  @_tags = tags if tags.is_a?(String)
59
59
  end
60
+
61
+ def details
62
+ @_details ||= {}
63
+ end
64
+
65
+ def details= protect_details
66
+ @_details = protect_details if protect_details.is_a?(Contrast::Agent::Reporting::Details::ProtectRuleDetails)
67
+ end
60
68
  end
61
69
  end
62
70
  end
@@ -4,48 +4,82 @@
4
4
  require 'contrast/utils/object_share'
5
5
  require 'contrast/utils/timer'
6
6
  require 'contrast/agent/reporting/attack_result/user_input'
7
+ require 'contrast/agent/reporting/input_analysis/input_type'
8
+ require 'contrast/agent/reporting/details/protect_rule_details'
9
+ require 'contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack'
7
10
 
8
11
  module Contrast
9
12
  module Agent
10
13
  module Reporting
11
14
  # This class will hold the new RaspRuleSample.
12
- # protect rules.
13
- class RaspRuleSample # rubocop:disable Lint/EmptyClass
14
- # def timestamp
15
- # @_timestamp ||= 0
16
- # end
15
+ # It is mainly used to build samples for each
16
+ # protect rule, and translate data from SP IA.
17
+ # It is not a reporting event.
18
+ class RaspRuleSample
19
+ # Any rules specific details
17
20
  #
18
- # def timestamp= timestamp_ms
19
- # @_timestamp = timestamp_ms
20
- # end
21
- #
22
- # def user_input
23
- # @_user_input ||= Contrast::Agent::Reporting::UserInput.new
24
- # end
25
- #
26
- # def user_input= input
27
- # @_user_input = input if input.is_a?(Contrast::Agent::Reporting::UserInput)
28
- # end
29
- #
30
- # def build context, ia_result
31
- # sample = self
32
- # sample.timestamp = context&.timer&.start_ms
33
- # sample.user_input = build_user_input_from_ia(ia_result)
34
- # sample.user_input.document_type = if context&.request
35
- # Contrast::Utils::StringUtils.force_utf8(context.request.document_type)
36
- # end
37
- # sample
38
- # end
39
- #
40
- # def build_user_input_from_ia ia_result
41
- # user_input = Contrast::Agent::Reporting::UserInput.new
42
- # user_input.input_type = ia_result.input_type
43
- # user_input.matcher_ids = ia_result.ids
44
- # user_input.path = ia_result.path
45
- # user_input.key = ia_result.key if ia_result.key
46
- # user_input.value = ia_result.value if ia_result.value
47
- # user_input
48
- # end
21
+ # @return [Contrast::Agent::Reporting::Details::ProtectRuleDetails, nil]
22
+ attr_accessor :details
23
+
24
+ class << self
25
+ # @param context [Contrast::Agent::RequestContext]
26
+ # @param ia_result [Contrast::Agent::Reporting::Settings::InputAnalysisResult] the analysis of the input that
27
+ # was determined to be an attack
28
+ # @return [Contrast::Agent::Reporting::RaspRuleSample]
29
+ def build context, ia_result
30
+ sample = new
31
+ sample.time_stamp = context&.timer&.start_ms
32
+ sample.user_input = build_user_input_from_ia(ia_result)
33
+ sample.user_input.document_type = if context&.request
34
+ Contrast::Utils::StringUtils.force_utf8(context.request.document_type)
35
+ end
36
+ sample
37
+ end
38
+
39
+ # @param ia_result [Contrast::Agent::Reporting::Settings::InputAnalysisResult] the analysis of the input that
40
+ # was determined to be an attack
41
+ def build_user_input_from_ia ia_result
42
+ user_input = Contrast::Agent::Reporting::UserInput.new
43
+ return user_input unless ia_result
44
+
45
+ user_input.input_type = ia_result.input_type
46
+ user_input.matcher_ids = ia_result.ids
47
+ user_input.path = ia_result.path
48
+ user_input.key = ia_result.key if ia_result.key
49
+ user_input.value = ia_result.value if ia_result.value
50
+ user_input
51
+ end
52
+ end
53
+
54
+ def time_stamp
55
+ @_time_stamp ||= Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms || 0
56
+ end
57
+
58
+ def time_stamp= timestamp_ms
59
+ @_time_stamp = timestamp_ms
60
+ end
61
+
62
+ def user_input
63
+ @_user_input ||= Contrast::Agent::Reporting::UserInput.new
64
+ end
65
+
66
+ def user_input= input
67
+ @_user_input = input if input.is_a?(Contrast::Agent::Reporting::UserInput)
68
+ end
69
+
70
+ # @return [Array<Contrast::Agent::Reporting::ApplicationDefendAttackSampleStack>,Array]
71
+ def stack
72
+ @_stack ||= []
73
+ end
74
+
75
+ def to_controlled_hash
76
+ {
77
+ timeStamp: Time.at(time_stamp).iso8601,
78
+ userInput: user_input.to_controlled_hash,
79
+ details: details&.to_controlled_hash,
80
+ stack: stack.map(&:to_controlled_hash)
81
+ }
82
+ end
49
83
  end
50
84
  end
51
85
  end
@@ -9,18 +9,18 @@ module Contrast
9
9
  # This module will hold the response types used to generate
10
10
  # attack result.
11
11
  module ResponseType
12
- BLOCKED = :BLOCKED.cs__freeze
13
- MONITORED = :MONITORED.cs__freeze
14
- PROBED = :PROBED.cs__freeze
15
- BLOCK_AT_PERIMETER = :BLOCK_AT_PERIMETER.cs__freeze
16
- SUSPICIOUS = :SUSPICIOUS.cs__freeze
17
- AGGREGATED = :AGGREGATED.cs__freeze
18
- EXPLOITED = :EXPLOITED.cs__freeze
19
- NO_ACTION = :NO_ACTION.cs__freeze
12
+ BLOCKED = :BLOCKED.cs__freeze
13
+ MONITORED = :MONITORED.cs__freeze
14
+ PROBED = :PROBED.cs__freeze
15
+ BLOCKED_AT_PERIMETER = :BLOCKED_AT_PERIMETER.cs__freeze
16
+ SUSPICIOUS = :SUSPICIOUS.cs__freeze
17
+ AGGREGATED = :AGGREGATED.cs__freeze
18
+ EXPLOITED = :EXPLOITED.cs__freeze
19
+ NO_ACTION = :NO_ACTION.cs__freeze
20
20
 
21
21
  class << self
22
22
  def to_a
23
- [NO_ACTION, BLOCKED, MONITORED, PROBED, BLOCK_AT_PERIMETER, EXPLOITED, SUSPICIOUS, AGGREGATED]
23
+ [NO_ACTION, BLOCKED, MONITORED, PROBED, BLOCKED_AT_PERIMETER, EXPLOITED, SUSPICIOUS, AGGREGATED]
24
24
  end
25
25
  end
26
26
  end
@@ -81,6 +81,17 @@ module Contrast
81
81
  def matcher_ids= ids
82
82
  @_matcher_ids = ids if ids.is_a?(Array) && ids.any?(String)
83
83
  end
84
+
85
+ def to_controlled_hash
86
+ {
87
+ path: path,
88
+ key: key,
89
+ value: value,
90
+ inputType: input_type.to_s,
91
+ documentType: document_type.to_s,
92
+ matcherIds: matcher_ids&.map(&:to_s)
93
+ }
94
+ end
84
95
  end
85
96
  end
86
97
  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: true
3
+
4
+ require 'contrast/agent/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # Bot blocker IA result details info.
11
+ class BotBlockerDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_accessor :bot
14
+ # User agent header value
15
+ #
16
+ # @return [String]
17
+ attr_accessor :user_agent
18
+
19
+ def to_controlled_hash
20
+ {
21
+ bot: bot,
22
+ userAgent: user_agent
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # CMDI IA result details info.
11
+ class CmdInjectionDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_accessor :cmd
14
+ # @return [Integer]
15
+ attr_accessor :start_idx
16
+ # @return [Integer]
17
+ attr_accessor :end_idx
18
+
19
+ def to_controlled_hash
20
+ {
21
+ command: cmd,
22
+ startIndex: start_idx,
23
+ endIndex: end_idx
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
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/reporting/details/bot_blocker_details'
5
+ require 'contrast/agent/reporting/details/cmd_injection_details'
6
+ require 'contrast/agent/reporting/details/http_method_tempering_details'
7
+ require 'contrast/agent/reporting/details/no_sqli_details'
8
+ require 'contrast/agent/reporting/details/path_traversal_details'
9
+ require 'contrast/agent/reporting/details/protect_rule_details'
10
+ require 'contrast/agent/reporting/details/sqli_details'
11
+ require 'contrast/agent/reporting/details/untrusted_deserialization_details'
12
+ require 'contrast/agent/reporting/details/xss_match'
13
+ require 'contrast/agent/reporting/details/xss_details'
14
+ require 'contrast/agent/reporting/details/xxe_details'
15
+ require 'contrast/agent/reporting/details/xxe_match'
16
+ require 'contrast/agent/reporting/details/xxe_wrapper'
17
+ require 'contrast/agent/reporting/details/virtual_patch_details'
18
+ require 'contrast/agent/reporting/details/ip_denylist_details'
@@ -0,0 +1,27 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # HttpMethodTemperingDetails IA result details info.
11
+ class HttpMethodTemperingDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_accessor :method
14
+ # @return [Integer]
15
+ attr_accessor :response_code
16
+
17
+ def to_controlled_hash
18
+ {
19
+ method: method, # rubocop:disable Security/Object/Method
20
+ responseCode: response_code
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # Bot blocker IA result details info.
11
+ class IpDenylistDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_reader :ip
14
+ # @return [String]
15
+ attr_reader :uuid
16
+
17
+ # @param ip [String] the IP address that was blocked
18
+ # @param uuid [String] the UUID to identify the block rule in TeamServer
19
+ def initialize ip, uuid
20
+ @ip = ip
21
+ @uuid = uuid
22
+ super()
23
+ end
24
+
25
+ def to_controlled_hash
26
+ {
27
+ ip: ip,
28
+ uuid: uuid
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,36 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # NoSqliDetails IA result details info.
11
+ class NoSqliDetails < ProtectRuleDetails
12
+ # @return [Integer]
13
+ attr_accessor :start_idx
14
+ # @return [Integer]
15
+ attr_accessor :end_idx
16
+ # @return [Integer]
17
+ attr_accessor :boundary_overrun_idx
18
+ # @return [Integer]
19
+ attr_accessor :input_boundary_idx
20
+ # @return [String]
21
+ attr_accessor :query
22
+
23
+ def to_controlled_hash
24
+ {
25
+ start: start_idx,
26
+ end: end_idx,
27
+ boundaryOverrunIndex: boundary_overrun_idx,
28
+ inputBoundaryIndex: input_boundary_idx,
29
+ query: query
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # PathTraversalDetails IA result details info.
11
+ class PathTraversalDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_accessor :path
14
+
15
+ def to_controlled_hash
16
+ {
17
+ path: path
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
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/reporting/details/protect_rule_details'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ module Details
10
+ # PathTraversalDetails IA result details info.
11
+ class PathTraversalSemanticAnalysisDetails < ProtectRuleDetails
12
+ # @return [String]
13
+ attr_accessor :path
14
+ # @return [Array<Symbol>]
15
+ attr_accessor :findings
16
+
17
+ def initialize
18
+ @findings = []
19
+ super
20
+ end
21
+
22
+ def to_controlled_hash
23
+ {
24
+ path: path,
25
+ findings: findings&.map(&:to_s)
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end