contrast-agent 6.11.0 → 6.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (471) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -1
  3. data/Gemfile +1 -1
  4. data/Rakefile +1 -1
  5. data/ext/build_funchook.rb +1 -1
  6. data/ext/cs__assess_array/cs__assess_array.c +24 -18
  7. data/ext/cs__assess_array/extconf.rb +1 -1
  8. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +1 -1
  9. data/ext/cs__assess_basic_object/extconf.rb +1 -1
  10. data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
  11. data/ext/cs__assess_fiber_track/extconf.rb +1 -1
  12. data/ext/cs__assess_hash/cs__assess_hash.c +1 -1
  13. data/ext/cs__assess_hash/extconf.rb +1 -1
  14. data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -1
  15. data/ext/cs__assess_kernel/extconf.rb +1 -1
  16. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +7 -5
  17. data/ext/cs__assess_marshal_module/extconf.rb +1 -1
  18. data/ext/cs__assess_module/cs__assess_module.c +1 -1
  19. data/ext/cs__assess_module/extconf.rb +1 -1
  20. data/ext/cs__assess_regexp/cs__assess_regexp.c +1 -1
  21. data/ext/cs__assess_regexp/extconf.rb +1 -1
  22. data/ext/cs__assess_string/cs__assess_string.c +1 -1
  23. data/ext/cs__assess_string/extconf.rb +1 -1
  24. data/ext/cs__assess_string_interpolation/cs__assess_string_interpolation.c +1 -1
  25. data/ext/cs__assess_string_interpolation/extconf.rb +1 -1
  26. data/ext/cs__assess_test/extconf.rb +1 -1
  27. data/ext/cs__assess_yield_track/cs__assess_yield_track.c +1 -1
  28. data/ext/cs__assess_yield_track/extconf.rb +1 -1
  29. data/ext/cs__common/cs__common.c +1 -1
  30. data/ext/cs__common/extconf.rb +1 -1
  31. data/ext/cs__contrast_patch/cs__contrast_patch.c +12 -10
  32. data/ext/cs__contrast_patch/extconf.rb +1 -1
  33. data/ext/cs__os_information/cs__os_information.c +1 -1
  34. data/ext/cs__os_information/extconf.rb +1 -1
  35. data/ext/cs__scope/cs__scope.c +390 -207
  36. data/ext/cs__scope/cs__scope.h +3 -1
  37. data/ext/cs__scope/extconf.rb +1 -1
  38. data/ext/cs__tests/cs__tests.c +1 -1
  39. data/ext/cs__tests/extconf.rb +1 -1
  40. data/ext/extconf_common.rb +1 -1
  41. data/lib/contrast/agent/assess/contrast_object.rb +1 -1
  42. data/lib/contrast/agent/assess/events/event_data.rb +1 -1
  43. data/lib/contrast/agent/assess/finalizers/freeze.rb +1 -1
  44. data/lib/contrast/agent/assess/finalizers/hash.rb +1 -1
  45. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +1 -1
  46. data/lib/contrast/agent/assess/policy/patcher.rb +1 -1
  47. data/lib/contrast/agent/assess/policy/policy.rb +1 -1
  48. data/lib/contrast/agent/assess/policy/policy_node.rb +1 -1
  49. data/lib/contrast/agent/assess/policy/policy_node_utils.rb +1 -1
  50. data/lib/contrast/agent/assess/policy/policy_scanner.rb +1 -1
  51. data/lib/contrast/agent/assess/policy/preshift.rb +1 -1
  52. data/lib/contrast/agent/assess/policy/propagation_method.rb +1 -1
  53. data/lib/contrast/agent/assess/policy/propagation_node.rb +1 -1
  54. data/lib/contrast/agent/assess/policy/propagator/append.rb +1 -1
  55. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  56. data/lib/contrast/agent/assess/policy/propagator/buffer.rb +1 -1
  57. data/lib/contrast/agent/assess/policy/propagator/center.rb +1 -1
  58. data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
  59. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
  60. data/lib/contrast/agent/assess/policy/propagator/insert.rb +1 -1
  61. data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
  62. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +1 -1
  63. data/lib/contrast/agent/assess/policy/propagator/next.rb +1 -1
  64. data/lib/contrast/agent/assess/policy/propagator/prepend.rb +1 -1
  65. data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +1 -1
  66. data/lib/contrast/agent/assess/policy/propagator/remove.rb +1 -1
  67. data/lib/contrast/agent/assess/policy/propagator/replace.rb +1 -1
  68. data/lib/contrast/agent/assess/policy/propagator/reverse.rb +1 -1
  69. data/lib/contrast/agent/assess/policy/propagator/select.rb +1 -1
  70. data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
  71. data/lib/contrast/agent/assess/policy/propagator/split.rb +1 -1
  72. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +1 -1
  73. data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +1 -1
  74. data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
  75. data/lib/contrast/agent/assess/policy/propagator.rb +1 -1
  76. data/lib/contrast/agent/assess/policy/source_method.rb +1 -3
  77. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  78. data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +1 -1
  79. data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
  80. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +2 -1
  81. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
  82. data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
  83. data/lib/contrast/agent/assess/policy/trigger_node.rb +1 -1
  84. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +39 -1
  85. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
  86. data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +1 -1
  87. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
  88. data/lib/contrast/agent/assess/properties.rb +1 -1
  89. data/lib/contrast/agent/assess/property/evented.rb +1 -1
  90. data/lib/contrast/agent/assess/property/tagged.rb +1 -1
  91. data/lib/contrast/agent/assess/property/updated.rb +1 -1
  92. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +1 -1
  93. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -1
  94. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +1 -1
  95. data/lib/contrast/agent/assess/rule/provider.rb +1 -1
  96. data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
  97. data/lib/contrast/agent/assess/rule/response/base_rule.rb +1 -1
  98. data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -1
  99. data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +1 -1
  100. data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +1 -1
  101. data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
  102. data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +1 -1
  103. data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +1 -1
  104. data/lib/contrast/agent/assess/rule/response/header_rule.rb +1 -1
  105. data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +1 -1
  106. data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
  107. data/lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb +1 -1
  108. data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +1 -1
  109. data/lib/contrast/agent/assess/tag.rb +1 -1
  110. data/lib/contrast/agent/assess/tracker.rb +1 -1
  111. data/lib/contrast/agent/assess.rb +1 -1
  112. data/lib/contrast/agent/at_exit_hook.rb +1 -1
  113. data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
  114. data/lib/contrast/agent/deadzone/policy/policy.rb +1 -1
  115. data/lib/contrast/agent/disable_reaction.rb +1 -1
  116. data/lib/contrast/agent/excluder.rb +125 -43
  117. data/lib/contrast/agent/exclusion_matcher.rb +11 -55
  118. data/lib/contrast/agent/inventory/database_config.rb +1 -1
  119. data/lib/contrast/agent/inventory/dependencies.rb +1 -1
  120. data/lib/contrast/agent/inventory/dependency_analysis.rb +1 -1
  121. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +1 -1
  122. data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
  123. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  124. data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
  125. data/lib/contrast/agent/inventory.rb +1 -1
  126. data/lib/contrast/agent/middleware.rb +21 -8
  127. data/lib/contrast/agent/module_data.rb +1 -1
  128. data/lib/contrast/agent/patching/policy/after_load_patch.rb +1 -1
  129. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +1 -1
  130. data/lib/contrast/agent/patching/policy/method_policy.rb +1 -1
  131. data/lib/contrast/agent/patching/policy/method_policy_extend.rb +1 -1
  132. data/lib/contrast/agent/patching/policy/module_policy.rb +1 -1
  133. data/lib/contrast/agent/patching/policy/patch.rb +1 -1
  134. data/lib/contrast/agent/patching/policy/patch_status.rb +1 -1
  135. data/lib/contrast/agent/patching/policy/patcher.rb +1 -1
  136. data/lib/contrast/agent/patching/policy/policy.rb +1 -1
  137. data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
  138. data/lib/contrast/agent/patching/policy/trigger_node.rb +1 -1
  139. data/lib/contrast/agent/protect/exploitable_collection.rb +1 -1
  140. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +4 -2
  141. data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +12 -11
  142. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +1 -1
  143. data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +1 -1
  144. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
  145. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +1 -1
  146. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -1
  147. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
  148. data/lib/contrast/agent/protect/policy/policy.rb +1 -1
  149. data/lib/contrast/agent/protect/policy/rule_applicator.rb +6 -1
  150. data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
  151. data/lib/contrast/agent/protect/rule/base.rb +9 -19
  152. data/lib/contrast/agent/protect/rule/base_service.rb +33 -10
  153. data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +1 -1
  154. data/lib/contrast/agent/protect/rule/bot_blocker.rb +1 -1
  155. data/lib/contrast/agent/protect/rule/cmd_injection.rb +1 -1
  156. data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -50
  157. data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +11 -18
  158. data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +10 -11
  159. data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +10 -11
  160. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +1 -1
  161. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  162. data/lib/contrast/agent/protect/rule/deserialization.rb +2 -3
  163. data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -1
  164. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +1 -1
  165. data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -13
  166. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +1 -1
  167. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +34 -9
  168. data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -47
  169. data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +1 -1
  170. data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +1 -1
  171. data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +1 -1
  172. data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +2 -2
  173. data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +1 -1
  174. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +1 -1
  175. data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +5 -5
  176. data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
  177. data/lib/contrast/agent/protect/rule/sqli.rb +1 -13
  178. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +1 -1
  179. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -2
  180. data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +1 -1
  181. data/lib/contrast/agent/protect/rule/xss.rb +1 -1
  182. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +1 -1
  183. data/lib/contrast/agent/protect/rule/xxe.rb +2 -3
  184. data/lib/contrast/agent/protect/rule.rb +1 -1
  185. data/lib/contrast/agent/reporting/attack_result/attack_result.rb +1 -1
  186. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +1 -1
  187. data/lib/contrast/agent/reporting/attack_result/response_type.rb +1 -1
  188. data/lib/contrast/agent/reporting/attack_result/user_input.rb +1 -1
  189. data/lib/contrast/{api/communication → agent/reporting}/connection_status.rb +3 -17
  190. data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +1 -1
  191. data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +1 -1
  192. data/lib/contrast/agent/reporting/details/details.rb +1 -1
  193. data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +1 -1
  194. data/lib/contrast/agent/reporting/details/no_sqli_details.rb +1 -1
  195. data/lib/contrast/agent/reporting/details/path_traversal_details.rb +1 -1
  196. data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +1 -1
  197. data/lib/contrast/agent/reporting/details/protect_rule_details.rb +1 -1
  198. data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +1 -1
  199. data/lib/contrast/agent/reporting/details/sqli_details.rb +1 -1
  200. data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +1 -1
  201. data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +1 -1
  202. data/lib/contrast/agent/reporting/details/xss_details.rb +1 -1
  203. data/lib/contrast/agent/reporting/details/xss_match.rb +1 -1
  204. data/lib/contrast/agent/reporting/details/xxe_details.rb +1 -1
  205. data/lib/contrast/agent/reporting/details/xxe_match.rb +1 -1
  206. data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +1 -1
  207. data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +1 -1
  208. data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +1 -1
  209. data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -1
  210. data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +1 -1
  211. data/lib/contrast/agent/reporting/input_analysis/input_type.rb +1 -1
  212. data/lib/contrast/agent/reporting/input_analysis/score_level.rb +1 -1
  213. data/lib/contrast/agent/reporting/masker/masker.rb +1 -1
  214. data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -1
  215. data/lib/contrast/agent/reporting/report.rb +1 -1
  216. data/lib/contrast/agent/reporting/reporter.rb +10 -9
  217. data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
  218. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +5 -4
  219. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -9
  220. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +5 -6
  221. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -1
  222. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +4 -3
  223. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +1 -1
  224. data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +19 -12
  225. data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +2 -2
  226. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +2 -2
  227. data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +1 -1
  228. data/lib/contrast/agent/reporting/reporting_events/application_settings.rb +2 -2
  229. data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +2 -2
  230. data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +1 -1
  231. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +2 -3
  232. data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +4 -10
  233. data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +3 -11
  234. data/lib/contrast/agent/reporting/reporting_events/finding.rb +2 -11
  235. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +5 -12
  236. data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +4 -12
  237. data/lib/contrast/agent/reporting/reporting_events/finding_event_parent_object.rb +9 -13
  238. data/lib/contrast/agent/reporting/reporting_events/finding_event_property.rb +9 -13
  239. data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +5 -12
  240. data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -21
  241. data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +9 -12
  242. data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +10 -14
  243. data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range_tags.rb +1 -1
  244. data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +4 -12
  245. data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +14 -14
  246. data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +14 -14
  247. data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +3 -11
  248. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +2 -11
  249. data/lib/contrast/agent/reporting/reporting_events/poll.rb +2 -2
  250. data/lib/contrast/agent/reporting/reporting_events/preflight.rb +13 -2
  251. data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +5 -13
  252. data/lib/contrast/agent/reporting/reporting_events/reportable_hash.rb +47 -0
  253. data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +4 -35
  254. data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +1 -3
  255. data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +9 -13
  256. data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +9 -13
  257. data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +1 -1
  258. data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +2 -2
  259. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +5 -2
  260. data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +5 -2
  261. data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +1 -1
  262. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +6 -3
  263. data/lib/contrast/agent/reporting/reporting_utilities/ng_response_extractor.rb +4 -4
  264. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +6 -19
  265. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +20 -3
  266. data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
  267. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
  268. data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +2 -22
  269. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +1 -1
  270. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +1 -1
  271. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +22 -5
  272. data/lib/contrast/agent/reporting/reporting_workers/application_server_worker.rb +1 -1
  273. data/lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb +1 -1
  274. data/lib/contrast/agent/reporting/reporting_workers/reporting_workers.rb +1 -1
  275. data/lib/contrast/agent/reporting/reporting_workers/server_settings_worker.rb +1 -1
  276. data/lib/contrast/agent/reporting/settings/application_settings.rb +1 -1
  277. data/lib/contrast/agent/reporting/settings/assess.rb +1 -1
  278. data/lib/contrast/agent/reporting/settings/assess_rule.rb +1 -1
  279. data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +1 -1
  280. data/lib/contrast/agent/reporting/settings/bot_blocker.rb +1 -1
  281. data/lib/contrast/agent/reporting/settings/exclusion_base.rb +90 -12
  282. data/lib/contrast/agent/reporting/settings/exclusions.rb +11 -31
  283. data/lib/contrast/agent/reporting/settings/helpers.rb +41 -5
  284. data/lib/contrast/agent/reporting/settings/input_exclusion.rb +54 -10
  285. data/lib/contrast/agent/reporting/settings/ip_filter.rb +1 -1
  286. data/lib/contrast/agent/reporting/settings/keyword.rb +1 -1
  287. data/lib/contrast/agent/reporting/settings/log_enhancer.rb +1 -1
  288. data/lib/contrast/agent/reporting/settings/protect.rb +1 -1
  289. data/lib/contrast/agent/reporting/settings/protect_rule.rb +1 -1
  290. data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
  291. data/lib/contrast/agent/reporting/settings/reaction.rb +1 -1
  292. data/lib/contrast/agent/reporting/settings/rule_definition.rb +1 -1
  293. data/lib/contrast/agent/reporting/settings/sampling.rb +1 -1
  294. data/lib/contrast/agent/reporting/settings/sanitizer.rb +1 -1
  295. data/lib/contrast/agent/reporting/settings/security_logger.rb +1 -1
  296. data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +1 -1
  297. data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +1 -1
  298. data/lib/contrast/agent/reporting/settings/server_features.rb +1 -1
  299. data/lib/contrast/agent/reporting/settings/syslog.rb +1 -1
  300. data/lib/contrast/agent/reporting/settings/url_exclusion.rb +2 -26
  301. data/lib/contrast/agent/reporting/settings/validator.rb +1 -1
  302. data/lib/contrast/agent/reporting/settings/virtual_patch.rb +1 -1
  303. data/lib/contrast/agent/reporting/settings/virtual_patch_condition.rb +1 -1
  304. data/lib/contrast/agent/request.rb +1 -1
  305. data/lib/contrast/agent/request_context.rb +1 -1
  306. data/lib/contrast/agent/request_context_extend.rb +1 -1
  307. data/lib/contrast/agent/request_handler.rb +1 -1
  308. data/lib/contrast/agent/response.rb +1 -1
  309. data/lib/contrast/agent/rule_set.rb +1 -1
  310. data/lib/contrast/agent/scope.rb +9 -1
  311. data/lib/contrast/agent/static_analysis.rb +1 -1
  312. data/lib/contrast/agent/telemetry/base.rb +21 -12
  313. data/lib/contrast/agent/telemetry/client.rb +109 -0
  314. data/lib/contrast/agent/telemetry/{events/event.rb → event.rb} +1 -1
  315. data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_base.rb → exception/base.rb} +2 -2
  316. data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_event.rb → exception/event.rb} +10 -10
  317. data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message.rb → exception/message.rb} +9 -9
  318. data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message_exception.rb → exception/message_exception.rb} +9 -9
  319. data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_stack_frame.rb → exception/stack_frame.rb} +4 -4
  320. data/lib/contrast/agent/telemetry/exception.rb +19 -0
  321. data/lib/contrast/agent/telemetry/hash.rb +71 -0
  322. data/lib/contrast/{utils/telemetry_identifier.rb → agent/telemetry/identifier.rb} +5 -5
  323. data/lib/contrast/agent/telemetry/{events/metric_event.rb → metric_event.rb} +2 -2
  324. data/lib/contrast/agent/telemetry/{events/startup_metrics_event.rb → startup_metrics_event.rb} +2 -2
  325. data/lib/contrast/{utils → agent}/telemetry.rb +3 -3
  326. data/lib/contrast/agent/thread.rb +1 -1
  327. data/lib/contrast/agent/thread_watcher.rb +28 -31
  328. data/lib/contrast/agent/tracepoint_hook.rb +1 -1
  329. data/lib/contrast/agent/version.rb +2 -2
  330. data/lib/contrast/agent/worker_thread.rb +1 -1
  331. data/lib/contrast/agent.rb +6 -2
  332. data/lib/contrast/agent_lib/api/command_injection.rb +1 -1
  333. data/lib/contrast/agent_lib/api/init.rb +1 -1
  334. data/lib/contrast/agent_lib/api/input_tracing.rb +1 -1
  335. data/lib/contrast/agent_lib/api/panic.rb +1 -1
  336. data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +1 -1
  337. data/lib/contrast/agent_lib/interface.rb +1 -1
  338. data/lib/contrast/agent_lib/interface_base.rb +2 -2
  339. data/lib/contrast/agent_lib/return_types/eval_result.rb +1 -1
  340. data/lib/contrast/agent_lib/test.rb +1 -1
  341. data/lib/contrast/components/agent.rb +1 -1
  342. data/lib/contrast/components/api.rb +1 -1
  343. data/lib/contrast/components/app_context.rb +1 -1
  344. data/lib/contrast/components/app_context_extend.rb +1 -1
  345. data/lib/contrast/components/assess.rb +1 -1
  346. data/lib/contrast/components/assess_rules.rb +1 -1
  347. data/lib/contrast/components/base.rb +1 -1
  348. data/lib/contrast/components/config/sources.rb +1 -1
  349. data/lib/contrast/components/config.rb +1 -1
  350. data/lib/contrast/components/heap_dump.rb +1 -1
  351. data/lib/contrast/components/inventory.rb +1 -1
  352. data/lib/contrast/components/logger.rb +1 -1
  353. data/lib/contrast/components/polling.rb +4 -4
  354. data/lib/contrast/components/protect.rb +1 -1
  355. data/lib/contrast/components/ruby_component.rb +45 -6
  356. data/lib/contrast/components/sampling.rb +6 -6
  357. data/lib/contrast/components/scope.rb +9 -1
  358. data/lib/contrast/components/security_logger.rb +1 -1
  359. data/lib/contrast/components/settings.rb +13 -12
  360. data/lib/contrast/config/api_proxy_configuration.rb +1 -1
  361. data/lib/contrast/config/base_configuration.rb +1 -1
  362. data/lib/contrast/config/certification_configuration.rb +1 -1
  363. data/lib/contrast/config/config.rb +14 -12
  364. data/lib/contrast/config/diagnostics.rb +12 -3
  365. data/lib/contrast/config/diagnostics_tools.rb +2 -1
  366. data/lib/contrast/config/effective_config.rb +81 -15
  367. data/lib/contrast/config/effective_config_value.rb +4 -4
  368. data/lib/contrast/config/env_variables.rb +1 -1
  369. data/lib/contrast/config/exception_configuration.rb +1 -1
  370. data/lib/contrast/config/protect_rule_configuration.rb +1 -1
  371. data/lib/contrast/config/protect_rules_configuration.rb +1 -1
  372. data/lib/contrast/config/request_audit_configuration.rb +1 -1
  373. data/lib/contrast/config/server_configuration.rb +2 -2
  374. data/lib/contrast/config.rb +1 -1
  375. data/lib/contrast/configuration.rb +1 -1
  376. data/lib/contrast/extension/assess/array.rb +1 -1
  377. data/lib/contrast/extension/assess/erb.rb +1 -1
  378. data/lib/contrast/extension/assess/eval_trigger.rb +1 -1
  379. data/lib/contrast/extension/assess/exec_trigger.rb +1 -1
  380. data/lib/contrast/extension/assess/fiber.rb +1 -1
  381. data/lib/contrast/extension/assess/hash.rb +1 -1
  382. data/lib/contrast/extension/assess/kernel.rb +1 -1
  383. data/lib/contrast/extension/assess/marshal.rb +1 -1
  384. data/lib/contrast/extension/assess/regexp.rb +1 -1
  385. data/lib/contrast/extension/assess/string.rb +1 -1
  386. data/lib/contrast/extension/assess.rb +1 -1
  387. data/lib/contrast/extension/delegator.rb +1 -1
  388. data/lib/contrast/extension/extension.rb +1 -1
  389. data/lib/contrast/extension/inventory.rb +1 -1
  390. data/lib/contrast/extension/module.rb +1 -1
  391. data/lib/contrast/extension/object.rb +1 -1
  392. data/lib/contrast/extension/protect/psych.rb +1 -1
  393. data/lib/contrast/extension/protect.rb +1 -1
  394. data/lib/contrast/extension/thread.rb +1 -1
  395. data/lib/contrast/framework/base_support.rb +1 -1
  396. data/lib/contrast/framework/grape/support.rb +1 -1
  397. data/lib/contrast/framework/manager.rb +1 -1
  398. data/lib/contrast/framework/manager_extend.rb +1 -1
  399. data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
  400. data/lib/contrast/framework/rack/patch/support.rb +1 -1
  401. data/lib/contrast/framework/rack/support.rb +1 -1
  402. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -1
  403. data/lib/contrast/framework/rails/patch/assess_configuration.rb +1 -1
  404. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
  405. data/lib/contrast/framework/rails/patch/support.rb +1 -1
  406. data/lib/contrast/framework/rails/railtie.rb +1 -1
  407. data/lib/contrast/framework/rails/support.rb +1 -1
  408. data/lib/contrast/framework/sinatra/patch/encrypted_session_cookie.rb +39 -0
  409. data/lib/contrast/framework/sinatra/support.rb +14 -1
  410. data/lib/contrast/funchook/funchook.rb +1 -1
  411. data/lib/contrast/logger/aliased_logging.rb +12 -14
  412. data/lib/contrast/logger/application.rb +1 -1
  413. data/lib/contrast/logger/cef_log.rb +1 -1
  414. data/lib/contrast/logger/format.rb +1 -1
  415. data/lib/contrast/logger/log.rb +1 -1
  416. data/lib/contrast/logger/request.rb +1 -1
  417. data/lib/contrast/logger/time.rb +1 -1
  418. data/lib/contrast/security_exception.rb +1 -1
  419. data/lib/contrast/tasks/config.rb +1 -1
  420. data/lib/contrast/utils/assess/event_limit_utils.rb +1 -1
  421. data/lib/contrast/utils/assess/object_store.rb +1 -1
  422. data/lib/contrast/utils/assess/propagation_method_utils.rb +1 -1
  423. data/lib/contrast/utils/assess/property/tagged_utils.rb +1 -1
  424. data/lib/contrast/utils/assess/sampling_util.rb +1 -1
  425. data/lib/contrast/utils/assess/source_method_utils.rb +1 -1
  426. data/lib/contrast/utils/assess/split_utils.rb +1 -1
  427. data/lib/contrast/utils/assess/tracking_util.rb +1 -1
  428. data/lib/contrast/utils/assess/trigger_method_utils.rb +1 -1
  429. data/lib/contrast/utils/class_util.rb +1 -1
  430. data/lib/contrast/utils/duck_utils.rb +1 -1
  431. data/lib/contrast/utils/env_configuration_item.rb +1 -1
  432. data/lib/contrast/utils/findings.rb +1 -1
  433. data/lib/contrast/utils/hash_digest.rb +1 -1
  434. data/lib/contrast/utils/hash_digest_extend.rb +1 -1
  435. data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
  436. data/lib/contrast/utils/heap_dump_util.rb +1 -1
  437. data/lib/contrast/utils/input_classification_base.rb +2 -5
  438. data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
  439. data/lib/contrast/utils/io_util.rb +1 -1
  440. data/lib/contrast/utils/job_servers_running.rb +1 -1
  441. data/lib/contrast/utils/log_utils.rb +2 -2
  442. data/lib/contrast/utils/lru_cache.rb +1 -1
  443. data/lib/contrast/utils/metrics_hash.rb +1 -1
  444. data/lib/contrast/utils/middleware_utils.rb +4 -4
  445. data/lib/contrast/utils/net_http_base.rb +3 -3
  446. data/lib/contrast/utils/object_share.rb +2 -1
  447. data/lib/contrast/utils/os.rb +1 -1
  448. data/lib/contrast/utils/patching/policy/patch_utils.rb +1 -1
  449. data/lib/contrast/utils/patching/policy/patcher_utils.rb +1 -1
  450. data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +12 -4
  451. data/lib/contrast/utils/request_utils.rb +1 -1
  452. data/lib/contrast/utils/resource_loader.rb +1 -1
  453. data/lib/contrast/utils/response_utils.rb +1 -1
  454. data/lib/contrast/utils/routes_sent.rb +1 -2
  455. data/lib/contrast/utils/sha256_builder.rb +1 -1
  456. data/lib/contrast/utils/silence_maker.rb +16 -0
  457. data/lib/contrast/utils/stack_trace_utils.rb +1 -1
  458. data/lib/contrast/utils/string_utils.rb +1 -1
  459. data/lib/contrast/utils/tag_util.rb +1 -1
  460. data/lib/contrast/utils/thread_tracker.rb +1 -1
  461. data/lib/contrast/utils/timer.rb +1 -1
  462. data/lib/contrast-agent.rb +1 -1
  463. data/lib/contrast.rb +7 -6
  464. data/resources/assess/policy.json +26 -0
  465. data/ruby-agent.gemspec +2 -2
  466. metadata +31 -30
  467. data/lib/contrast/agent/reporting/settings/code_exclusion.rb +0 -32
  468. data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +0 -124
  469. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +0 -19
  470. data/lib/contrast/utils/telemetry_client.rb +0 -107
  471. data/lib/contrast/utils/telemetry_hash.rb +0 -65
@@ -1,10 +1,9 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 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/agent/reporting/reporting_events/reporting_event'
5
4
  require 'contrast/components/assess'
6
- require 'contrast/components/logger'
7
5
  require 'contrast/utils/string_utils'
6
+ require 'contrast/agent/reporting/reporting_events/reportable_hash'
8
7
 
9
8
  module Contrast
10
9
  module Agent
@@ -13,9 +12,7 @@ module Contrast
13
12
  # system to report a single message, part of the main Preflight, to TeamServer. This message represents the
14
13
  # identifying information of a Finding/Trace, which TeamServer will use to determine if it requires the full
15
14
  # information of the Finding/Trace to be reported.
16
- class PreflightMessage
17
- include Contrast::Components::Logger::InstanceMethods
18
-
15
+ class PreflightMessage < Contrast::Agent::Reporting::ReportableHash
19
16
  # @return [String] the message identifier; rule_id,hash
20
17
  attr_accessor :data
21
18
  # @return [String] CRC checksum of the finding to which this message pertains
@@ -30,6 +27,7 @@ module Contrast
30
27
 
31
28
  def initialize
32
29
  @routes = []
30
+ super()
33
31
  end
34
32
 
35
33
  # Convert the instance variables on the class, and other information, into the identifiers required for
@@ -38,13 +36,7 @@ module Contrast
38
36
  # @return [Hash]
39
37
  # @raise [ArgumentError]
40
38
  def to_controlled_hash
41
- begin
42
- validate
43
- rescue ArgumentError => e
44
- logger.error('PreflightMessage validation failed with: ', e)
45
- return
46
- end
47
-
39
+ validate
48
40
  {
49
41
  code: CODE,
50
42
  app_language: Contrast::Utils::ObjectShare::RUBY,
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ require 'contrast/components/logger'
5
+
6
+ module Contrast
7
+ module Agent
8
+ module Reporting
9
+ # A class supporting all to_controlled_hash reporting methods. All errors raised during
10
+ # validation will be handled here.
11
+ class ReportableHash
12
+ include Contrast::Components::Logger::InstanceMethods
13
+
14
+ # Convert the instance variables on the class, and other information, into the identifiers required for
15
+ # TeamServer to process the JSON form of this message.
16
+ #
17
+ # @return [Hash, nil]
18
+ # @raise [ArgumentError]
19
+ def to_controlled_hash
20
+ validate
21
+ {}
22
+ end
23
+
24
+ # @raise [ArgumentError]
25
+ def validate; end
26
+
27
+ # Helper method to get json representation of event objects and handle errors.
28
+ #
29
+ # @return [String, nil] - JSON
30
+ def event_json
31
+ hsh = to_controlled_hash
32
+ hsh.to_json
33
+ rescue ArgumentError => e
34
+ # Log the error and raise it for the client to handle:
35
+ logger.error(validation_error_message, e)
36
+ raise(e)
37
+ end
38
+
39
+ private
40
+
41
+ def validation_error_message
42
+ "#{ cs__class } failed validation with: "
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,7 +1,7 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 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/components/logger'
4
+ require 'contrast/agent/reporting/reporting_events/reportable_hash'
5
5
  require 'contrast/utils/assess/trigger_method_utils'
6
6
  require 'contrast/agent/reporting/reporting_utilities/endpoints'
7
7
  require 'contrast/components/assess'
@@ -13,9 +13,7 @@ module Contrast
13
13
  # reporting system.
14
14
  #
15
15
  # @abstract
16
- class ReportingEvent
17
- include Contrast::Components::Logger::InstanceMethods
18
-
16
+ class ReportingEvent < Contrast::Agent::Reporting::ReportableHash
19
17
  # @return [String] the endpoint, with host, to which this event should be sent
20
18
  attr_reader :event_endpoint
21
19
  # @return event_method [Symbol] the HTTP method to use to send this event
@@ -23,6 +21,7 @@ module Contrast
23
21
 
24
22
  def initialize
25
23
  @event_method ||= :POST # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
24
+ super()
26
25
  end
27
26
 
28
27
  # Some reports require specific additional headers to be used. To that end, we'll attach them here, letting
@@ -30,36 +29,6 @@ module Contrast
30
29
  #
31
30
  # @param _request [Net::HTTPRequest]
32
31
  def attach_headers _request; end
33
-
34
- # Convert the instance variables on the class, and other information, into the identifiers required for
35
- # TeamServer to process the JSON form of this message.
36
- #
37
- # @return [Hash]
38
- # @raise [ArgumentError]
39
- def to_controlled_hash
40
- begin
41
- validate
42
- rescue ArgumentError => e
43
- logger.error('ReportingEvent validation failed with: ', e)
44
- return
45
- end
46
-
47
- {}
48
- end
49
-
50
- # @raise [ArgumentError]
51
- def validate; end
52
-
53
- # Helper method to get json representation of event and handle errors
54
- #
55
- # @return [String] - JSON
56
- def event_json
57
- hsh = to_controlled_hash
58
- hsh.to_json
59
- rescue Exception => e # rubocop:disable Lint/RescueException
60
- logger.error('Unable to convert JSON string', e, hsh)
61
- raise(e)
62
- end
63
32
  end
64
33
  end
65
34
  end
@@ -1,9 +1,7 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'json'
5
- require 'contrast/components/logger'
6
- require 'contrast/agent/reporting/reporting_events/reporting_event'
7
5
  require 'contrast/utils/object_share'
8
6
 
9
7
  module Contrast
@@ -1,8 +1,9 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/reporting_events/route_discovery_observation'
5
- require 'contrast/components/logger'
5
+ require 'contrast/agent/reporting/reporting_events/reportable_hash'
6
+ require 'contrast/utils/duck_utils'
6
7
 
7
8
  module Contrast
8
9
  module Agent
@@ -13,9 +14,7 @@ module Contrast
13
14
  # externally accessible endpoints within the application, as registered to the application framework. They may or
14
15
  # may not have been invoked at the time of reporting.
15
16
  #
16
- class RouteDiscovery
17
- include Contrast::Components::Logger::InstanceMethods
18
-
17
+ class RouteDiscovery < Contrast::Agent::Reporting::ReportableHash
19
18
  # @return [Array<Contrast::Agent::Reporting::RouteDiscoveryObservation>] the routes and verbs seen that match
20
19
  # to this Route.
21
20
  attr_reader :observations
@@ -29,6 +28,7 @@ module Contrast
29
28
  @signature = signature
30
29
  @observations = []
31
30
  observations << observation
31
+ super()
32
32
  end
33
33
 
34
34
  # Convert the instance variables on the class, and other information, into the identifiers required for
@@ -37,13 +37,7 @@ module Contrast
37
37
  # @return [Hash]
38
38
  # @raise [ArgumentError]
39
39
  def to_controlled_hash
40
- begin
41
- validate
42
- rescue ArgumentError => e
43
- logger.error('RouteDiscovery validation failed with: ', e)
44
- return
45
- end
46
-
40
+ validate
47
41
  {
48
42
  count: 0, # we have this to make TS happy
49
43
  observations: @observations.map(&:to_controlled_hash),
@@ -55,7 +49,9 @@ module Contrast
55
49
  #
56
50
  # @raise [ArgumentError]
57
51
  def validate
58
- raise(ArgumentError, "#{ self } did not have a proper signature. Unable to continue.") unless signature
52
+ return unless Contrast::Utils::DuckUtils.empty_duck?(signature)
53
+
54
+ raise(ArgumentError, "#{ self } did not have a proper signature. Unable to continue.")
59
55
  end
60
56
  end
61
57
  end
@@ -1,8 +1,9 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/string_utils'
5
- require 'contrast/components/logger'
5
+ require 'contrast/agent/reporting/reporting_events/reportable_hash'
6
+ require 'contrast/utils/duck_utils'
6
7
 
7
8
  module Contrast
8
9
  module Agent
@@ -11,9 +12,7 @@ module Contrast
11
12
  # reporting system to relay this information in the Application Update messages. These route observations are
12
13
  # used by TeamServer to construct the route coverage information for the assess feature. They represent the
13
14
  # literal URL and HTTP verb used to invoke a method in the application, as routed by the application framework.
14
- class RouteDiscoveryObservation
15
- include Contrast::Components::Logger::InstanceMethods
16
-
15
+ class RouteDiscoveryObservation < Contrast::Agent::Reporting::ReportableHash
17
16
  # @return [String] the URL requested to hit this endpoint. Required for reporting; required attributes
18
17
  attr_accessor :url
19
18
  # @return [String] the HTTP Method requested to his this endpoint. Empty means all, so is allowed for
@@ -23,6 +22,7 @@ module Contrast
23
22
  def initialize url, verb
24
23
  @url = url
25
24
  @verb = verb if Contrast::Utils::StringUtils.present?(verb)
25
+ super()
26
26
  end
27
27
 
28
28
  # Convert the instance variables on the class, and other information, into the identifiers required for
@@ -31,13 +31,7 @@ module Contrast
31
31
  # @return [Hash]
32
32
  # @raise [ArgumentError]
33
33
  def to_controlled_hash
34
- begin
35
- validate
36
- rescue ArgumentError => e
37
- logger.error('RouteDiscoveryObservation validation failed with: ', e)
38
- return
39
- end
40
-
34
+ validate
41
35
  { url: url, verb: verb }.compact
42
36
  end
43
37
 
@@ -45,7 +39,9 @@ module Contrast
45
39
  #
46
40
  # @raise [ArgumentError]
47
41
  def validate
48
- raise(ArgumentError, "#{ self } did not have a proper url. Unable to continue.") unless url
42
+ return unless Contrast::Utils::DuckUtils.empty_duck?(url)
43
+
44
+ raise(ArgumentError, "#{ self } did not have a proper url. Unable to continue.")
49
45
  end
50
46
  end
51
47
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/reporting_events/reporting_event'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/reporting_events/server_reporting_event'
@@ -14,7 +14,7 @@ module Contrast
14
14
  def initialize
15
15
  @event_method = :GET
16
16
  @event_endpoint = Contrast::Agent::Reporting::Endpoints.server_settings
17
- super
17
+ super()
18
18
  end
19
19
 
20
20
  def file_name
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/components/logger'
@@ -33,8 +33,11 @@ module Contrast
33
33
  log_data(:request, file_name, data) if data
34
34
  return unless ::Contrast::API.request_audit_responses
35
35
 
36
- data = response_data&.body || 'There is no available response'
36
+ data = response_data&.body ||
37
+ { response_code: response_data.code, response_body: 'There is no available response body' }.to_json
37
38
  log_data(:response, file_name, data)
39
+ rescue StandardError => e
40
+ logger.error('Audit failed with error: ', event: event, error: e)
38
41
  end
39
42
 
40
43
  private
@@ -1,10 +1,11 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/reporting_events/preflight_message'
5
5
  require 'contrast/agent/reporting/reporting_events/preflight'
6
6
  require 'contrast/agent/reporting/reporting_events/route_discovery'
7
7
  require 'contrast/agent/reporting/reporting_utilities/reporting_storage'
8
+ require 'contrast/utils/duck_utils'
8
9
 
9
10
  module Contrast
10
11
  module Agent
@@ -26,7 +27,9 @@ module Contrast
26
27
  new_preflight_message.hash_code = finding.hash_code
27
28
  new_preflight_message.data = "#{ finding.rule_id },#{ finding.hash_code }"
28
29
  new_preflight.messages << new_preflight_message
29
- new_preflight
30
+ return new_preflight unless Contrast::Utils::DuckUtils.empty_duck?(new_preflight.messages)
31
+
32
+ nil
30
33
  end
31
34
  end
32
35
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/components/logger'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/utils/object_share'
@@ -11,11 +11,12 @@ module Contrast
11
11
  # This class will build the required headers for agent reporting to TS
12
12
  class Headers
13
13
  attr_reader :app_name, :api_key, :agent_version, :app_language, :app_path, :app_version, :authorization,
14
- :server_name, :server_path, :server_type, :content_type, :encoding
14
+ :server_name, :server_path, :server_type, :content_type, :encoding, :compression
15
15
 
16
16
  include Contrast::Utils::ObjectShare
17
17
  ENCODING = 'base64'
18
18
  CONTENT_TYPE = 'application/json'
19
+ COMPRESSION = 'gzip'
19
20
 
20
21
  def initialize
21
22
  @app_name = Base64.strict_encode64(Contrast::APP_CONTEXT.name) # rubocop:disable Security/Module/Name
@@ -30,6 +31,7 @@ module Contrast
30
31
  @server_type = Base64.strict_encode64(Contrast::APP_CONTEXT.server_type)
31
32
  @content_type = CONTENT_TYPE
32
33
  @encoding = ENCODING
34
+ @compression = COMPRESSION
33
35
  end
34
36
 
35
37
  def to_contrast_hash
@@ -45,7 +47,8 @@ module Contrast
45
47
  server_path: @server_path,
46
48
  server_type: @server_type,
47
49
  content_type: @content_type,
48
- encoding: @encoding
50
+ encoding: @encoding,
51
+ compression: @compression
49
52
  }.cs__freeze
50
53
  end
51
54
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast
@@ -44,9 +44,9 @@ module Contrast
44
44
  exclusions = response_data[:settings][:exceptions]
45
45
  return unless exclusions
46
46
 
47
- res.application_settings.exclusions.code_exclusions = exclusions[:codeExceptions]
48
- res.application_settings.exclusions.input_exclusions = exclusions[:inputExceptions]
49
- res.application_settings.exclusions.url_exclusions = exclusions[:urlExceptions]
47
+ # Pass true if the endpoint is ng.
48
+ res.application_settings.exclusions.input_exclusions = [exclusions[:inputExceptions], true]
49
+ res.application_settings.exclusions.url_exclusions = [exclusions[:urlExceptions], true]
50
50
  end
51
51
 
52
52
  # The responses we receive for feature and settings from TS have different
@@ -1,11 +1,11 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'json'
5
5
  require 'net/http'
6
6
  require 'contrast/components/logger'
7
7
  require 'contrast/utils/net_http_base'
8
- require 'contrast/api/communication/connection_status'
8
+ require 'contrast/agent/reporting/connection_status'
9
9
  require 'contrast/agent/reporting/reporting_utilities/response_handler'
10
10
  require 'contrast/agent/reporting/reporting_utilities/reporter_client_utils'
11
11
  require 'contrast/agent/reporting/reporting_utilities/endpoints'
@@ -76,7 +76,6 @@ module Contrast
76
76
  response = connection.request(request)
77
77
  audit&.audit_event(event, response) if ::Contrast::API.request_audit_enable
78
78
  process_settings_response(response, event)
79
- record_status(response, event)
80
79
  record_configuration(response, event)
81
80
  process_preflight_response(event, response, connection)
82
81
  response
@@ -84,19 +83,6 @@ module Contrast
84
83
  handle_error(event, e)
85
84
  end
86
85
 
87
- # This is going to populate the config status value in the diagnostics json
88
- #
89
- # @param response [Contrast::Agent::Reporting::Response, nil]
90
- # @param event [Contrast::Agent::Reporting::ReportingEvent]
91
- def record_status response, event
92
- return unless response
93
- return unless event&.cs__class == Contrast::Agent::Reporting::AgentStartup ||
94
- event&.cs__class == Contrast::Agent::Reporting::ApplicationStartup
95
-
96
- diagnostics.config.determine_config_status(response)
97
- nil
98
- end
99
-
100
86
  # Write effective config to file:
101
87
  # If we are here the create and server messages are sent and the code received is
102
88
  # 200 or 304. In case of 304 there will be no new settings and we can write current ones.
@@ -106,16 +92,17 @@ module Contrast
106
92
  # @param event [Contrast::Agent::Reporting::ReportingEvent]
107
93
  def record_configuration response, event
108
94
  return unless response
109
- return unless REPORT_CONFIG_WHEN.include?(response_handler.last_response_code)
95
+
96
+ diagnostics.config.determine_config_status(response_handler.last_response_code || response.code)
97
+ return unless REPORT_CONFIG_WHEN.include?(response_handler.last_response_code || response.code)
110
98
  return unless RECORDABLE_EVENTS.include?(event&.cs__class)
111
99
 
112
100
  logger.info('[Reporter Diagnostics] last response code:', response_code: response_handler.last_response_code)
113
101
  diagnostics.write_to_file
114
- status.server_response_success!
115
102
  end
116
103
 
117
104
  def status
118
- @_status ||= Contrast::Api::Communication::ConnectionStatus.new
105
+ @_status ||= Contrast::Agent::Reporting::ConnectionStatus.new
119
106
  end
120
107
 
121
108
  def response_handler
@@ -1,6 +1,8 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'zlib'
5
+ require 'stringio'
4
6
  require 'contrast/components/logger'
5
7
  require 'contrast/components/scope'
6
8
  require 'contrast/agent/reporting/reporting_events/application_startup'
@@ -49,6 +51,7 @@ module Contrast
49
51
  # This method will build headers of the request required for TS communication
50
52
  #
51
53
  # @param request [Net::HTTPRequest]
54
+ # @return [Net::HTTPRequest]
52
55
  def build_headers request
53
56
  app_version = @headers.app_version
54
57
  request['API-Key'] = @headers.api_key
@@ -57,12 +60,12 @@ module Contrast
57
60
  request['Application-Path'] = @headers.app_path
58
61
  request['Application-Version'] = app_version if app_version
59
62
  request['Authorization'] = @headers.authorization
60
- request['Content-Type'] = @headers.content_type
61
63
  request['Server-Name'] = @headers.server_name
62
64
  request['Server-Path'] = @headers.server_path
63
65
  request['Server-Type'] = @headers.server_type
64
66
  request['X-Contrast-Agent'] = @headers.agent_version
65
67
  request['X-Contrast-Header-Encoding'] = @headers.encoding
68
+ build_encode_and_compress_headers(request)
66
69
  request
67
70
  end
68
71
 
@@ -134,10 +137,24 @@ module Contrast
134
137
  end
135
138
  build_headers(request)
136
139
  event.attach_headers(request)
137
- request.body = event.event_json
140
+ # compress:
141
+ gzip = Zlib::GzipWriter.new(StringIO.new)
142
+ gzip << event.event_json
143
+ request.body = gzip.close.string
138
144
  request
139
145
  end
140
146
  end
147
+
148
+ # Adds the compression and encoding Headers required for sending
149
+ # compress and encoded body payload.
150
+ #
151
+ # @param request [Net::HTTPRequest]
152
+ def build_encode_and_compress_headers request
153
+ request['Content-Type'] = @headers.content_type
154
+ request['X-Contrast-Header-Encoding'] = @headers.encoding
155
+ request['X-Contrast-Encoding'] = @headers.compression
156
+ request['Content-Encoding'] = @headers.compression
157
+ end
141
158
  end
142
159
  end
143
160
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/components/logger'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/settings/application_settings'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/settings/assess_rule'
@@ -124,28 +124,8 @@ module Contrast
124
124
  exclusions = response_data[:exclusions]
125
125
  return unless exclusions
126
126
 
127
- res.application_settings.exclusions.code_exclusions = exclusions[:code]
128
127
  res.application_settings.exclusions.url_exclusions = exclusions[:url]
129
- extract_input_exclusions(response_data[:exclusions], res)
130
- end
131
-
132
- # Input exclusions between NG and non-NG are different, so need to be cast separately.
133
- #
134
- # @param exclusions [Hash]
135
- # @param res [Contrast::Agent::Reporting::Response]
136
- def extract_input_exclusions exclusions, res
137
- res.application_settings.exclusions.input_exclusions = []
138
- exclusions[:input].each do |exclusion_details|
139
- input_exclusion = Contrast::Agent::Reporting::Settings::InputExclusion.new
140
- input_exclusion.name = exclusion_details[:name]
141
- input_exclusion.modes = exclusion_details[:modes]
142
- input_exclusion.assess_rules = exclusion_details[:assess_rules]
143
- input_exclusion.protect_rules = exclusion_details[:protect_rules]
144
- input_exclusion.input_name = exclusion_details[:name]
145
- input_exclusion.input_type = exclusion_details[:type]
146
- input_exclusion.urls = exclusion_details[:urls]
147
- res.application_settings.exclusions.input_exclusions << exclusion
148
- end
128
+ res.application_settings.exclusions.input_exclusions = exclusions[:input]
149
129
  end
150
130
 
151
131
  # @param response_data [Hash]
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/reporting/reporting_utilities/response'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
1
+ # Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Contrast