contrast-agent 6.0.0 → 6.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -1
  3. data/Rakefile +1 -1
  4. data/ext/build_funchook.rb +3 -3
  5. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +5 -1
  6. data/ext/cs__assess_regexp/cs__assess_regexp.c +15 -2
  7. data/ext/cs__assess_regexp/cs__assess_regexp.h +2 -0
  8. data/ext/cs__assess_string/cs__assess_string.c +8 -0
  9. data/ext/cs__assess_test/cs__assess_test.h +9 -0
  10. data/ext/cs__assess_test/cs__assess_tests.c +22 -0
  11. data/ext/cs__assess_test/extconf.rb +5 -0
  12. data/ext/cs__common/cs__common.c +101 -0
  13. data/ext/cs__common/cs__common.h +29 -5
  14. data/ext/cs__contrast_patch/cs__contrast_patch.c +1 -1
  15. data/ext/cs__tests/cs__tests.c +12 -0
  16. data/ext/cs__tests/cs__tests.h +3 -0
  17. data/ext/cs__tests/extconf.rb +5 -0
  18. data/ext/extconf_common.rb +1 -1
  19. data/lib/contrast/agent/assess/contrast_object.rb +16 -16
  20. data/lib/contrast/agent/assess/events/source_event.rb +17 -19
  21. data/lib/contrast/agent/assess/finalizers/hash.rb +2 -2
  22. data/lib/contrast/agent/assess/policy/policy.rb +9 -10
  23. data/lib/contrast/agent/assess/policy/policy_node.rb +9 -10
  24. data/lib/contrast/agent/assess/policy/policy_scanner.rb +2 -16
  25. data/lib/contrast/agent/assess/policy/propagation_method.rb +3 -3
  26. data/lib/contrast/agent/assess/policy/propagation_node.rb +2 -3
  27. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  28. data/lib/contrast/agent/assess/policy/propagator/buffer.rb +2 -1
  29. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
  30. data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
  31. data/lib/contrast/agent/assess/policy/propagator/split.rb +17 -21
  32. data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
  33. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  34. data/lib/contrast/agent/assess/policy/trigger_method.rb +10 -18
  35. data/lib/contrast/agent/assess/policy/trigger_node.rb +16 -16
  36. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  37. data/lib/contrast/agent/assess/property/evented.rb +2 -2
  38. data/lib/contrast/agent/assess/property/tagged.rb +2 -2
  39. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +6 -8
  40. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +6 -7
  41. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +12 -7
  42. data/lib/contrast/agent/assess/rule/response/base_rule.rb +13 -6
  43. data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +66 -43
  44. data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +4 -4
  45. data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +6 -6
  46. data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +4 -4
  47. data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +4 -4
  48. data/lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb +4 -4
  49. data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +3 -4
  50. data/lib/contrast/agent/assess/tag.rb +13 -14
  51. data/lib/contrast/agent/at_exit_hook.rb +12 -1
  52. data/lib/contrast/agent/inventory/database_config.rb +22 -7
  53. data/lib/contrast/agent/middleware.rb +9 -6
  54. data/lib/contrast/agent/patching/policy/after_load_patch.rb +3 -5
  55. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +2 -2
  56. data/lib/contrast/agent/patching/policy/method_policy_extend.rb +4 -4
  57. data/lib/contrast/agent/patching/policy/patch.rb +20 -19
  58. data/lib/contrast/agent/patching/policy/patch_status.rb +10 -3
  59. data/lib/contrast/agent/patching/policy/patcher.rb +1 -1
  60. data/lib/contrast/agent/patching/policy/policy.rb +13 -15
  61. data/lib/contrast/agent/patching/policy/policy_node.rb +19 -21
  62. data/lib/contrast/agent/patching/policy/trigger_node.rb +1 -1
  63. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +126 -122
  64. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -2
  65. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +1 -1
  66. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
  67. data/lib/contrast/agent/protect/policy/rule_applicator.rb +4 -4
  68. data/lib/contrast/agent/protect/rule/base.rb +30 -18
  69. data/lib/contrast/agent/protect/rule/base_service.rb +31 -14
  70. data/lib/contrast/agent/protect/rule/cmd_injection.rb +16 -9
  71. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +3 -3
  72. data/lib/contrast/agent/protect/rule/default_scanner.rb +2 -1
  73. data/lib/contrast/agent/protect/rule/deserialization.rb +18 -7
  74. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +74 -74
  75. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +71 -53
  76. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +3 -3
  77. data/lib/contrast/agent/protect/rule/no_sqli.rb +15 -16
  78. data/lib/contrast/agent/protect/rule/path_traversal.rb +13 -3
  79. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -2
  80. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +1 -1
  81. data/lib/contrast/agent/protect/rule/sqli.rb +16 -23
  82. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +61 -61
  83. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +29 -29
  84. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +32 -32
  85. data/lib/contrast/agent/protect/rule/xss.rb +17 -0
  86. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +14 -13
  87. data/lib/contrast/agent/protect/rule/xxe.rb +25 -3
  88. data/lib/contrast/agent/reaction_processor.rb +1 -1
  89. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +36 -36
  90. data/lib/contrast/agent/reporting/masker/masker.rb +18 -21
  91. data/lib/contrast/agent/reporting/masker/masker_utils.rb +10 -6
  92. data/lib/contrast/agent/reporting/reporter.rb +11 -16
  93. data/lib/contrast/agent/reporting/reporter_heartbeat.rb +49 -0
  94. data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +6 -2
  95. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +51 -0
  96. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +96 -0
  97. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +70 -0
  98. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +182 -0
  99. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +56 -0
  100. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +22 -0
  101. data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +70 -0
  102. data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +6 -2
  103. data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +60 -0
  104. data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +27 -0
  105. data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +15 -11
  106. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +7 -12
  107. data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +1 -1
  108. data/lib/contrast/agent/reporting/reporting_events/finding.rb +9 -3
  109. data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +2 -4
  110. data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +3 -3
  111. data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +6 -2
  112. data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +7 -3
  113. data/lib/contrast/agent/reporting/reporting_events/poll.rb +6 -2
  114. data/lib/contrast/agent/reporting/reporting_events/preflight.rb +10 -8
  115. data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +6 -10
  116. data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +12 -20
  117. data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +27 -0
  118. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +17 -27
  119. data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +38 -0
  120. data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +8 -0
  121. data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
  122. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -2
  123. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +15 -10
  124. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +54 -67
  125. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +17 -7
  126. data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +9 -6
  127. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +17 -17
  128. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +47 -32
  129. data/lib/contrast/agent/reporting/settings/application_settings.rb +1 -1
  130. data/lib/contrast/agent/reporting/settings/assess.rb +5 -5
  131. data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +3 -3
  132. data/lib/contrast/agent/reporting/settings/exclusions.rb +3 -3
  133. data/lib/contrast/agent/reporting/settings/protect.rb +21 -6
  134. data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +6 -6
  135. data/lib/contrast/agent/reporting/settings/reaction.rb +3 -3
  136. data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +2 -2
  137. data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +2 -2
  138. data/lib/contrast/agent/reporting/settings/server_features.rb +2 -2
  139. data/lib/contrast/agent/request.rb +5 -5
  140. data/lib/contrast/agent/request_context.rb +23 -19
  141. data/lib/contrast/agent/request_context_extend.rb +11 -24
  142. data/lib/contrast/agent/request_handler.rb +4 -4
  143. data/lib/contrast/agent/response.rb +2 -0
  144. data/lib/contrast/agent/rule_set.rb +2 -2
  145. data/lib/contrast/agent/scope.rb +1 -1
  146. data/lib/contrast/agent/service_heartbeat.rb +6 -48
  147. data/lib/contrast/agent/static_analysis.rb +1 -1
  148. data/lib/contrast/agent/telemetry/base.rb +155 -0
  149. data/lib/contrast/agent/telemetry/events/event.rb +35 -0
  150. data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +119 -0
  151. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +44 -36
  152. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +29 -21
  153. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +91 -73
  154. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +62 -44
  155. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +50 -33
  156. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +20 -0
  157. data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions_report.rb +30 -0
  158. data/lib/contrast/agent/telemetry/events/metric_event.rb +28 -0
  159. data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +123 -0
  160. data/lib/contrast/agent/thread_watcher.rb +52 -68
  161. data/lib/contrast/agent/version.rb +1 -1
  162. data/lib/contrast/agent/worker_thread.rb +8 -0
  163. data/lib/contrast/agent.rb +1 -3
  164. data/lib/contrast/api/communication/messaging_queue.rb +29 -12
  165. data/lib/contrast/api/communication/response_processor.rb +7 -10
  166. data/lib/contrast/api/communication/service_lifecycle.rb +1 -1
  167. data/lib/contrast/api/communication/socket.rb +1 -1
  168. data/lib/contrast/api/communication/socket_client.rb +1 -1
  169. data/lib/contrast/api/communication/speedracer.rb +3 -3
  170. data/lib/contrast/api/decorators/activity.rb +33 -0
  171. data/lib/contrast/api/decorators/agent_startup.rb +10 -9
  172. data/lib/contrast/api/decorators/application_settings.rb +1 -1
  173. data/lib/contrast/api/decorators/application_startup.rb +4 -4
  174. data/lib/contrast/api/decorators/http_request.rb +1 -1
  175. data/lib/contrast/api/decorators/response_type.rb +4 -17
  176. data/lib/contrast/components/agent.rb +1 -1
  177. data/lib/contrast/components/base.rb +1 -1
  178. data/lib/contrast/components/config.rb +19 -28
  179. data/lib/contrast/components/contrast_service.rb +13 -1
  180. data/lib/contrast/components/sampling.rb +1 -1
  181. data/lib/contrast/components/settings.rb +58 -24
  182. data/lib/contrast/config/agent_configuration.rb +21 -11
  183. data/lib/contrast/config/api_configuration.rb +12 -8
  184. data/lib/contrast/config/api_proxy_configuration.rb +7 -3
  185. data/lib/contrast/config/application_configuration.rb +15 -11
  186. data/lib/contrast/config/assess_configuration.rb +13 -9
  187. data/lib/contrast/config/assess_rules_configuration.rb +6 -2
  188. data/lib/contrast/config/base_configuration.rb +3 -35
  189. data/lib/contrast/config/certification_configuration.rb +9 -5
  190. data/lib/contrast/config/exception_configuration.rb +10 -7
  191. data/lib/contrast/config/heap_dump_configuration.rb +13 -9
  192. data/lib/contrast/config/inventory_configuration.rb +9 -6
  193. data/lib/contrast/config/logger_configuration.rb +9 -6
  194. data/lib/contrast/config/protect_configuration.rb +9 -6
  195. data/lib/contrast/config/protect_rule_configuration.rb +12 -8
  196. data/lib/contrast/config/protect_rules_configuration.rb +19 -18
  197. data/lib/contrast/config/request_audit_configuration.rb +10 -7
  198. data/lib/contrast/config/root_configuration.rb +29 -12
  199. data/lib/contrast/config/ruby_configuration.rb +14 -11
  200. data/lib/contrast/config/sampling_configuration.rb +11 -8
  201. data/lib/contrast/config/server_configuration.rb +13 -9
  202. data/lib/contrast/config/service_configuration.rb +14 -11
  203. data/lib/contrast/configuration.rb +23 -14
  204. data/lib/contrast/extension/assess/array.rb +1 -1
  205. data/lib/contrast/extension/assess/erb.rb +1 -1
  206. data/lib/contrast/extension/assess/marshal.rb +1 -1
  207. data/lib/contrast/extension/assess/string.rb +1 -1
  208. data/lib/contrast/extension/extension.rb +2 -2
  209. data/lib/contrast/framework/base_support.rb +8 -8
  210. data/lib/contrast/framework/grape/support.rb +3 -3
  211. data/lib/contrast/framework/manager.rb +5 -5
  212. data/lib/contrast/framework/manager_extend.rb +1 -1
  213. data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
  214. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +14 -3
  215. data/lib/contrast/framework/rails/patch/assess_configuration.rb +3 -3
  216. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
  217. data/lib/contrast/framework/rails/patch/support.rb +14 -46
  218. data/lib/contrast/framework/rails/support.rb +2 -2
  219. data/lib/contrast/framework/sinatra/support.rb +1 -1
  220. data/lib/contrast/logger/aliased_logging.rb +94 -0
  221. data/lib/contrast/logger/application.rb +0 -4
  222. data/lib/contrast/logger/cef_log.rb +14 -14
  223. data/lib/contrast/logger/format.rb +1 -1
  224. data/lib/contrast/logger/log.rb +8 -8
  225. data/lib/contrast/tasks/config.rb +30 -21
  226. data/lib/contrast/tasks/service.rb +2 -2
  227. data/lib/contrast/utils/assess/tracking_util.rb +4 -4
  228. data/lib/contrast/utils/class_util.rb +6 -10
  229. data/lib/contrast/utils/findings.rb +3 -3
  230. data/lib/contrast/utils/hash_digest.rb +6 -7
  231. data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
  232. data/lib/contrast/utils/invalid_configuration_util.rb +2 -2
  233. data/lib/contrast/utils/log_utils.rb +6 -4
  234. data/lib/contrast/utils/lru_cache.rb +1 -1
  235. data/lib/contrast/utils/metrics_hash.rb +1 -1
  236. data/lib/contrast/utils/middleware_utils.rb +6 -6
  237. data/lib/contrast/utils/net_http_base.rb +4 -4
  238. data/lib/contrast/utils/object_share.rb +1 -1
  239. data/lib/contrast/utils/os.rb +1 -1
  240. data/lib/contrast/utils/patching/policy/patch_utils.rb +2 -2
  241. data/lib/contrast/utils/request_utils.rb +2 -2
  242. data/lib/contrast/utils/sha256_builder.rb +4 -4
  243. data/lib/contrast/utils/stack_trace_utils.rb +31 -13
  244. data/lib/contrast/utils/telemetry.rb +22 -7
  245. data/lib/contrast/utils/telemetry_client.rb +27 -15
  246. data/lib/contrast/utils/telemetry_hash.rb +41 -0
  247. data/lib/contrast/utils/telemetry_identifier.rb +18 -3
  248. data/lib/contrast/utils/timer.rb +1 -1
  249. data/lib/contrast.rb +9 -0
  250. data/resources/assess/policy.json +1 -1
  251. data/ruby-agent.gemspec +1 -1
  252. data/service_executables/VERSION +1 -1
  253. data/service_executables/linux/contrast-service +0 -0
  254. data/service_executables/mac/contrast-service +0 -0
  255. metadata +41 -16
  256. data/lib/contrast/agent/telemetry/events/metric_telemetry_event.rb +0 -26
  257. data/lib/contrast/agent/telemetry/events/startup_metrics_telemetry_event.rb +0 -121
  258. data/lib/contrast/agent/telemetry/events/telemetry_event.rb +0 -33
  259. data/lib/contrast/agent/telemetry/telemetry.rb +0 -150
  260. data/lib/contrast/utils/exclude_key.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47aa135a205e4a74d64b778ae543f892213ca70e47be654032147a8bfe16dc82
4
- data.tar.gz: 60f0de0e2675578bfb735c4f90303748bdc5e2053f2722dac4907bf84364d2f9
3
+ metadata.gz: c901ed882ebff8176fe2f3794907e29b03cc2903b61260f138d93b2ef02a465c
4
+ data.tar.gz: 72e4f01ccf5a57bbd5afa0cac58c51cddbe26183691d9495f563dfd9fb37e7e1
5
5
  SHA512:
6
- metadata.gz: fdd2d1209de7366f810cb1d7355700a54cd7d7749d94736213cf96c47b8e5cedad449ec0dc2ab09753c0ecc3d064498d18d1d001edc5d998c6c615c4cd05b571
7
- data.tar.gz: 888016b33c67e7f2f77f320affcd1e945a7cc6e1c01c87d559d231cbed3309bbd4fff74833a5296f21680492955977d042594a39d807d4cb91eecd6adc4b4636
6
+ metadata.gz: 1d60653e61e95443c45bb43caac325b3c72449ddea435096e2d8e49c0a0851ff9ae6486fc16a17f65f663c2f069c58f6157f4f7ef8745d0b082d4fe7c5c0b8b6
7
+ data.tar.gz: e1e5dd1a542009d153fa6e77f86d889d8bb852d85d66c84400a583b63536be06a70423c4f05e547280f06368851a43720ac941efedf3aeb17a314ff3c9f61a14
data/.simplecov CHANGED
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
- SimpleCov.minimum_coverage line: 95
4
+ SimpleCov.minimum_coverage(line: 94)
5
5
  SimpleCov.start do
6
6
  add_filter '/spec/'
7
7
  enable_coverage :branch
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ CLOBBER << 'shared_libraries/*'
13
13
 
14
14
  Dir['ext/cs__*'].each do |extension|
15
15
  name = extension.split('/')[1]
16
- Rake::ExtensionTask.new name do |ext|
16
+ Rake::ExtensionTask.new(name) do |ext|
17
17
  ext.lib_dir = "lib/#{ name }"
18
18
  end
19
19
  end
@@ -52,13 +52,13 @@ unless find_header('funchook.h', ext_path)
52
52
 
53
53
  TARGET_PATHS.each do |target_path|
54
54
  unless File.writable?(target_path)
55
- puts "Unable to copy into #{ target_path } - directory not writable"
55
+ puts("Unable to copy into #{ target_path } - directory not writable")
56
56
  next
57
57
  end
58
- puts "Copying #{ source_file_path } into #{ target_path }"
58
+ puts("Copying #{ source_file_path } into #{ target_path }")
59
59
  FileUtils.cp(source_file_path, target_path)
60
60
  rescue StandardError
61
- puts "Error while copying #{ source_file } to #{ target_path }"
61
+ puts("Error while copying #{ source_file } to #{ target_path }")
62
62
  end
63
63
  end
64
64
  end
@@ -17,6 +17,10 @@
17
17
  * }
18
18
  */
19
19
 
20
+ VALUE contrast_check_and_register_instance_patch(
21
+ const char *module_name, const char *method_name,
22
+ VALUE(c_fn)(const int, VALUE *, const VALUE));
23
+
20
24
  void contrast_assess_instance_eval_trigger_check(VALUE self, VALUE source,
21
25
  VALUE ret) {
22
26
  rb_funcall(basic_eval_trigger, instance_trigger_check_method, 3, self,
@@ -61,6 +65,6 @@ void Init_cs__assess_basic_object(void) {
61
65
  * but if someone else patched BasicObject#instance_eval,
62
66
  * IDK if this is intentional... noting it. -ajm
63
67
  */
64
- contrast_register_patch("BasicObject", "instance_eval",
68
+ contrast_check_and_register_instance_patch("BasicObject", "instance_eval",
65
69
  contrast_assess_basic_object_instance_eval);
66
70
  }
@@ -3,8 +3,20 @@
3
3
 
4
4
  #include "cs__assess_regexp.h"
5
5
  #include "../cs__common/cs__common.h"
6
+ #include "../cs__contrast_patch/cs__contrast_patch.h"
6
7
  #include <ruby.h>
7
8
 
9
+ extern VALUE contrast_force_patch(const int argc, VALUE *argv) {
10
+ return contrast_check_and_register_instance_patch(
11
+ "Regexp", "=~", contrast_assess_regexp_equal_squiggle);
12
+ }
13
+
14
+ /* check if method is prepended and register instance alias or prepend patch */
15
+ VALUE contrast_check_and_register_instance_patch(const char *module_name,
16
+ const char *method_name,
17
+ VALUE(c_fn)(const int, VALUE *,
18
+ const VALUE));
19
+
8
20
  void contrast_alias_method(const VALUE target, const char *to,
9
21
  const char *from);
10
22
 
@@ -46,7 +58,8 @@ void Init_cs__assess_regexp(void) {
46
58
  rb_global_variable(&rb_sym_string);
47
59
  rb_sym_back_ref = ID2SYM(rb_intern("back_ref"));
48
60
  rb_global_variable(&rb_sym_back_ref);
61
+ rb_define_singleton_method(assess, "contrast_force_repatch_regexp", contrast_force_patch, 0);
49
62
 
50
- rb_sym_assess_regexp_equal_squiggle = contrast_register_patch(
51
- "Regexp", "=~", contrast_assess_regexp_equal_squiggle);
63
+ rb_sym_assess_regexp_equal_squiggle = contrast_check_and_register_instance_patch(
64
+ "Regexp", "=~", contrast_assess_regexp_equal_squiggle);
52
65
  }
@@ -20,4 +20,6 @@ static VALUE contrast_assess_regexp_equal_squiggle(const int argc,
20
20
  const VALUE *argv,
21
21
  const VALUE regexp);
22
22
 
23
+ extern VALUE contrast_force_patch(const int argc, VALUE *argv);
24
+
23
25
  void Init_cs__assess_regexp(void);
@@ -17,6 +17,13 @@
17
17
  * return rb_fstring(str);
18
18
  * }
19
19
  */
20
+
21
+ /*
22
+ * This patch won't do the Prepend. We would call to the String instance'
23
+ * uminus directly and skip other propagation from prepended modules.
24
+ * We could come back to this one and rethink it's prepend patching.
25
+ */
26
+
20
27
  static VALUE contrast_assess_string_freeze(const int argc, VALUE *argv,
21
28
  const VALUE obj) {
22
29
  if (!OBJ_FROZEN(obj)) {
@@ -55,6 +62,7 @@ void Init_cs__assess_string(void) {
55
62
  VALUE tracker = rb_define_class_under(assess, "Tracker", rb_cObject);
56
63
  properties_hash = rb_const_get(tracker, rb_intern("PROPERTIES_HASH"));
57
64
 
65
+ /* We only do alias for this one */
58
66
  rb_sym_assess_string_uminus =
59
67
  contrast_register_patch("String", "-@", &contrast_assess_string_uminus);
60
68
  rb_sym_assess_string_freeze = contrast_register_patch(
@@ -0,0 +1,9 @@
1
+ #include <ruby.h>
2
+
3
+ static VALUE dummy_regexp;
4
+ static VALUE test_regexp;
5
+
6
+ VALUE rb_equal_squiggle(const int argc, const VALUE *argv)
7
+ void rb_force_prepend(void);
8
+
9
+ void Init_cs__assess_test(void)
@@ -0,0 +1,22 @@
1
+ #include "../cs__common/cs__common.h";
2
+ #include "ruby.h"
3
+ #include <ruby/re.h>
4
+
5
+ static VALUE dummy_regexp;
6
+ static VALUE test_regexp;
7
+
8
+ VALUE rb_equal_squiggle(const int argc, const VALUE *argv) {
9
+ return rb_call_super(argc, argv);
10
+ }
11
+
12
+ void rb_force_prepend(void) {
13
+ rb_prepend_module(rb_cRegexp, dummy_regexp);
14
+ }
15
+
16
+ void Init_cs__assess_test(void) {
17
+ test_regexp = rb_define_module("ForcePrepend");
18
+ rb_define_singleton_method(test_regexp, "cs__force_prepend",
19
+ rb_force_prepend, 0);
20
+ dummy_regexp = rb_define_module("DummyMod");
21
+ rb_define_method(dummy_regexp, "=~", rb_equal_squiggle, -1);
22
+ }
@@ -0,0 +1,5 @@
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
+ $TO_MAKE = File.basename(__dir__)
5
+ require_relative '../extconf_common'
@@ -59,12 +59,14 @@ VALUE contrast_patcher() {
59
59
  return patcher;
60
60
  }
61
61
 
62
+ /* register instance alias patch */
62
63
  VALUE contrast_register_patch(const char *module_name, const char *method_name,
63
64
  VALUE(c_fn)(const int, VALUE *, const VALUE)) {
64
65
  return _contrast_register_patch(module_name, method_name, c_fn,
65
66
  IMPL_ALIAS_INSTANCE);
66
67
  }
67
68
 
69
+ /* register singleton alias patch */
68
70
  VALUE contrast_register_singleton_patch(const char *module_name,
69
71
  const char *method_name,
70
72
  VALUE(c_fn)(const int, VALUE *,
@@ -73,6 +75,7 @@ VALUE contrast_register_singleton_patch(const char *module_name,
73
75
  IMPL_ALIAS_SINGLETON);
74
76
  }
75
77
 
78
+ /* register instance prepend patch */
76
79
  VALUE contrast_register_prepend_patch(const char *module_name,
77
80
  const char *method_name,
78
81
  VALUE(c_fn)(const int, VALUE *,
@@ -81,6 +84,7 @@ VALUE contrast_register_prepend_patch(const char *module_name,
81
84
  IMPL_PREPEND_INSTANCE);
82
85
  }
83
86
 
87
+ /* register singleton prepend patch */
84
88
  VALUE contrast_register_singleton_prepend_patch(const char *module_name,
85
89
  const char *method_name,
86
90
  VALUE(c_fn)(const int, VALUE *,
@@ -89,6 +93,31 @@ VALUE contrast_register_singleton_prepend_patch(const char *module_name,
89
93
  IMPL_PREPEND_SINGLETON);
90
94
  }
91
95
 
96
+ /* check if method is prepended and register instance alias or prepend patch */
97
+ /* module name c_char "Module"; */
98
+ /* method name c_char "method"; */
99
+ /* c_func => pointer */
100
+ VALUE contrast_check_and_register_instance_patch(
101
+ const char *module_name, const char *method_name,
102
+ VALUE(c_fn)(const int, VALUE *, const VALUE)) {
103
+
104
+ VALUE object, method, is_prepended, patch_type;
105
+ /* check if method is prepended */
106
+ object = rb_const_get(rb_cObject, rb_intern(module_name));
107
+ method = ID2SYM(rb_intern(method_name));
108
+ is_prepended = contrast_check_prepended(object, method, Qtrue);
109
+
110
+ if (is_prepended == Qtrue) {
111
+ /* prepend patch */
112
+ return _contrast_register_patch(module_name, method_name, c_fn,
113
+ IMPL_PREPEND_INSTANCE);
114
+ } else {
115
+ /* alias patch */
116
+ return _contrast_register_patch(module_name, method_name, c_fn,
117
+ IMPL_ALIAS_INSTANCE);
118
+ }
119
+ }
120
+
92
121
  static VALUE
93
122
  _contrast_register_patch(const char *module_name, const char *method_name,
94
123
  VALUE(c_fn)(const int, VALUE *, const VALUE),
@@ -133,6 +162,7 @@ _contrast_register_patch(const char *module_name, const char *method_name,
133
162
  break;
134
163
  case IMPL_PREPEND_INSTANCE:
135
164
  impl = ID2SYM(rb_sym_prepend_instance);
165
+ break;
136
166
  case IMPL_PREPEND_SINGLETON:
137
167
  impl = ID2SYM(rb_sym_prepend_singleton);
138
168
  break;
@@ -151,6 +181,71 @@ int rb_ver_below_three() {
151
181
  return ruby_version < 3;
152
182
  }
153
183
 
184
+ /* used for direct check on object: String.cs__prepended? *args */
185
+ extern VALUE contrast_check_prepended(VALUE self, VALUE method_name,
186
+ VALUE is_instance) {
187
+ return _contrast_check_prepended(self, method_name, is_instance);
188
+ }
189
+
190
+ /* used for passing object to look if not called on itself.
191
+ Contrast::Agent::Assess.cs__object_method_prepended? object, :method_name,
192
+ true/false */
193
+ extern VALUE contrast_lookout_prepended(VALUE self, VALUE object_name,
194
+ VALUE method_name, VALUE is_instance) {
195
+ /* object_name must be the object, the self value is needed to prevent
196
+ lookout for self, since is always passed first we skip it */
197
+ VALUE result =
198
+ _contrast_check_prepended(object_name, method_name, is_instance);
199
+ return result;
200
+ }
201
+
202
+ static VALUE _contrast_check_prepended(VALUE object, VALUE method_name,
203
+ VALUE is_instance) {
204
+ VALUE entry, ancestors, object_idx, entry_methods;
205
+ VALUE result = Qfalse;
206
+ int i;
207
+ int y;
208
+
209
+ /* get self ancestors */
210
+ ancestors = rb_mod_ancestors(object);
211
+ /* get the size of the array */
212
+ int length = RARRAY_LEN(ancestors);
213
+ /* Locate self in ancestors: */
214
+ for (i = 0; i < length; ++i) {
215
+ entry = rb_ary_entry(ancestors, i);
216
+ if (entry == object) {
217
+ object_idx = i;
218
+ break;
219
+ }
220
+ }
221
+
222
+ /* find all the prepended modules */
223
+ /* we have the object place in ancestors: */
224
+ /* [suspect, suspect, object, ...] */
225
+ for (i = 0; i < object_idx; ++i) {
226
+ entry = rb_ary_entry(ancestors, i);
227
+ if (is_instance == Qtrue) {
228
+ entry_methods = rb_class_instance_methods(1, entry, entry);
229
+ } else {
230
+ entry_methods = rb_obj_singleton_methods(1, entry, entry);
231
+ }
232
+
233
+ /* Loop through the instance/singleton methods of the prepended modules
234
+ */
235
+ int entry_methods_length = RARRAY_LEN(entry_methods);
236
+ for (y = 0; y <= entry_methods_length; ++y) {
237
+ if (rb_ary_entry(entry_methods, y) == method_name) {
238
+ result = Qtrue;
239
+ break;
240
+ }
241
+ }
242
+ if (result == Qtrue) {
243
+ break;
244
+ }
245
+ }
246
+ return result;
247
+ }
248
+
154
249
  void Init_cs__common(void) {
155
250
  cs__send_method = rb_intern("send");
156
251
  cs__alias_method_sym = ID2SYM(rb_intern("alias_method"));
@@ -191,4 +286,10 @@ void Init_cs__common(void) {
191
286
 
192
287
  core_extensions = rb_define_module_under(contrast, "Extension");
193
288
  core_assess = rb_define_module_under(core_extensions, "Assess");
289
+ /* defined for direct object check */
290
+ rb_define_singleton_method(rb_cObject, "cs__prepended?",
291
+ contrast_check_prepended, 2);
292
+ /* defined for object lookout */
293
+ rb_define_singleton_method(assess, "cs__object_method_prepended?",
294
+ contrast_lookout_prepended, 4);
194
295
  }
@@ -57,15 +57,39 @@ VALUE contrast_register_singleton_patch(const char *module_name,
57
57
  VALUE(c_fn)(const int, VALUE *,
58
58
  const VALUE));
59
59
 
60
- VALUE contrast_register_singleton_prepend_patch(
61
- const char *module_name, const char *method_name,
62
- VALUE(c_fn)(const int, VALUE *, const VALUE));
60
+ VALUE contrast_register_prepend_patch(const char *module_name,
61
+ const char *method_name,
62
+ VALUE(c_fn)(const int, VALUE *,
63
+ const VALUE));
63
64
 
64
- static VALUE
65
- _contrast_register_patch(const char *module_name, const char *method_name,
65
+
66
+ VALUE contrast_register_singleton_prepend_patch(const char *module_name,
67
+ const char *method_name,
68
+ VALUE(c_fn)(const int, VALUE *,
69
+ const VALUE));
70
+
71
+ VALUE contrast_register_prepend_patch(const char *module_name,
72
+ const char *method_name,
73
+ VALUE(c_fn)(const int, VALUE *,
74
+ const VALUE));
75
+
76
+ static VALUE _contrast_register_patch(const char *module_name, const char *method_name,
66
77
  VALUE(c_fn)(const int, VALUE *, const VALUE),
67
78
  patch_impl patch_impl);
68
79
 
80
+ static VALUE _contrast_check_prepended(VALUE self, VALUE method_name, VALUE is_instance);
81
+
82
+ extern VALUE contrast_check_prepended(VALUE self, VALUE method_name, VALUE is_instance);
83
+
84
+ extern VALUE contrast_lookout_prepended(VALUE self, VALUE object_name, VALUE method_name,
85
+ VALUE is_instance);
86
+
87
+ /* check if method is prepended and register instance alias or prepend patch */
88
+ VALUE contrast_check_and_register_instance_patch(const char *module_name,
89
+ const char *method_name,
90
+ VALUE(c_fn)(const int, VALUE *,
91
+ const VALUE));
92
+
69
93
  VALUE contrast_patcher();
70
94
 
71
95
  void Init_cs__common(void);
@@ -488,7 +488,7 @@ VALUE contrast_patch_prepend(const VALUE self, const VALUE originalModule,
488
488
  rb_funcall(originalModule, rb_intern("included_in"), 0);
489
489
  if (RB_TYPE_P(rb_incl_in_mod_ary, T_ARRAY)) {
490
490
  int i = 0;
491
- int size = rb_funcall(rb_incl_in_mod_ary, rb_intern("length"), 0);
491
+ int size = RARRAY_LEN(rb_incl_in_mod_ary);
492
492
  for (i = 0; i < size; ++i) {
493
493
  module_at = rb_ary_entry(rb_incl_in_mod_ary, i);
494
494
  if (RB_TYPE_P(module_at, T_MODULE)) {
@@ -0,0 +1,12 @@
1
+ /* Copyright (c) 2022 Contrast Security, Inc. See
2
+ * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */
3
+
4
+ #include "cs__tests.h"
5
+ #include "../cs__common/cs__common.h"
6
+ #include <ruby.h>
7
+
8
+ /* Define any tests functions here, you could call a patch function and define
9
+ * it in Ruby */
10
+
11
+ void Init_cs__tests(void) {
12
+ }
@@ -0,0 +1,3 @@
1
+ #include <ruby.h>
2
+
3
+ void Init_cs__tests(void);
@@ -0,0 +1,5 @@
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
+ $TO_MAKE = File.basename(__dir__)
5
+ require_relative '../extconf_common'
@@ -5,7 +5,7 @@ require 'mkmf'
5
5
  require_relative '../lib/contrast/agent/version'
6
6
 
7
7
  def make!
8
- create_makefile "#{ $TO_MAKE }/#{ $TO_MAKE }"
8
+ create_makefile("#{ $TO_MAKE }/#{ $TO_MAKE }")
9
9
  end
10
10
 
11
11
  def ext_path
@@ -8,24 +8,22 @@ require 'contrast/agent/assess/tracker'
8
8
  module Contrast
9
9
  module Agent
10
10
  module Assess
11
- # This class is a convenient holder of our version of an Object. It
12
- # creates a String version of the Object from the original provided
13
- # and keeps reference to the original's Tags, letting us determine if it
14
- # was tracked when we try to report to TeamServer.
11
+ # This class is a convenient holder of our version of an Object. It creates a String version of the Object from
12
+ # the original provided and keeps reference to the original's Tags, letting us determine if it was tracked when
13
+ # we try to report to TeamServer.
15
14
  #
16
- # @attr_reader object [String, nil] the Contrast string representing the
17
- # object.
18
- # @attr_reader object_type [String] the name of the object's module.
19
- # @attr_reader tags [Hash{String => Contrast::Agent::Assess::Tag}, nil]
20
- # the tags on the object before it was captured.
21
- #
22
- # TODO: RUBY-1083 determine if this is expensive and/or worth not storing
23
- # these values directly on ContrastEvent and passing them around. Args
24
- # probably make the argument for wrapping them b/c otherwise we'll have
25
- # to keep two arrays in synch or make an array of arrays, at which
26
- # point, we may as well make this.
15
+ # TODO: RUBY-1083 determine if this is expensive and/or worth not storing these values directly on ContrastEvent
16
+ # and passing them around. Args probably make the argument for wrapping them b/c otherwise we'll have to keep
17
+ # two arrays in synch or make an array of arrays, at which point, we may as well make this.
27
18
  class ContrastObject
28
- attr_reader :object, :object_type, :tags
19
+ # @return [String] the Contrast String representation of the Object.
20
+ attr_reader :object
21
+ # @return [Integer] the __id__ of the original Object.
22
+ attr_reader :tracked_object_id
23
+ # @return [String] the name of the Class/Module of the Object.
24
+ attr_reader :object_type
25
+ # @return [Hash<Contrast::Agent::Assess::Tag>] the tags on the original Object.
26
+ attr_reader :tags
29
27
 
30
28
  # Capture the details about the object which we need to render it in
31
29
  # TeamServer.
@@ -34,10 +32,12 @@ module Contrast
34
32
  def initialize object
35
33
  if object
36
34
  @object = Contrast::Utils::ClassUtil.to_contrast_string(object)
35
+ @tracked_object_id = object.__id__
37
36
  @object_type = object.cs__class.cs__name
38
37
  @tags = Contrast::Agent::Assess::Tracker.properties(object)&.get_tags
39
38
  else
40
39
  @object = Contrast::Utils::ObjectShare::NIL_STRING
40
+ @tracked_object_id = nil.__id__
41
41
  @object_type = nil.cs__class.cs__name
42
42
  end
43
43
  end
@@ -9,22 +9,22 @@ module Contrast
9
9
  module Agent
10
10
  module Assess
11
11
  module Events
12
- # This class holds the data about an event in the application
13
- # We'll use it to build an event that TeamServer can consume if
14
- # the object to which this event belongs ends in a trigger.
15
- #
16
- # @attr_reader request [Contrast::Agent::Request] our wrapper around the Rack::Request at the time this source
17
- # was created
18
- # @attr_reader source_name [String] the name of the source if it comes from a map-like entity
19
- # @attr_reader source_type [String] the TeamServer understood type of source; i.e. parameter
12
+ # This class holds the data about an event in the application. We'll use it to build an event that TeamServer
13
+ # can consume if the object to which this event belongs ends in a trigger.
20
14
  class SourceEvent < Contrast::Agent::Assess::ContrastEvent
21
- attr_reader :request, :source_name, :source_type
15
+ # @return [Contrast::Agent::Request] our wrapper around the Rack::Request at the time this source
16
+ # was created
17
+ attr_reader :request
18
+ # @return [String] the name of the source if it comes from a map-like entity
19
+ attr_reader :source_name
20
+ # @return [String] the TeamServer understood type of source; i.e. parameter
21
+ attr_reader :source_type
22
22
 
23
23
  # @param event_data [Contrast::Agent::Assess::Events::EventData]
24
- # @param source_type [String] the type of this source, from the
25
- # source_node, or a KEY_TYPE if invoked for a map,
26
- # @param source_name [String, nil] the name of this source, i.e.
27
- # the key used to accessed if from a map or nil if a type like,
24
+ # @param source_type [String] the type of this source, from the source_node, or a KEY_TYPE if invoked for a
25
+ # Hash
26
+ # @param source_name [String, nil] the name of this source, i.e. the key used to accessed if from a Hash or
27
+ # nil if a type like
28
28
  def initialize event_data, source_type = nil, source_name = nil
29
29
  super(event_data)
30
30
  @source_type = source_type
@@ -54,8 +54,7 @@ module Contrast
54
54
  @_forced_source_name ||= Contrast::Utils::StringUtils.force_utf8(source_name)
55
55
  end
56
56
 
57
- # Probably only for source events, but we'll go
58
- # with source_type instead. java & .net support source_type
57
+ # Probably only for source events, but we'll go with source_type instead. java & .net support source_type
59
58
  # in propagation events, so we'll future proof this
60
59
  def build_event_source_dtm
61
60
  # You can have a source w/o a name, but not w/o a type
@@ -67,8 +66,7 @@ module Contrast
67
66
  dtm
68
67
  end
69
68
 
70
- # Probably only for source events, but we'll go
71
- # with source_type instead. java & .net support source_type
69
+ # Probably only for source events, but we'll go with source_type instead. java & .net support source_type
72
70
  # in propagation events, so we'll future proof this
73
71
  def build_event_source
74
72
  # You can have a source w/o a name, but not w/o a type
@@ -80,8 +78,8 @@ module Contrast
80
78
  trace_event_source
81
79
  end
82
80
 
83
- # We have to do a little work to figure out what our TS appropriate
84
- # target is. To break this down, the logic is as follows:
81
+ # We have to do a little work to figure out what our TS appropriate target is. To break this down, the logic
82
+ # is as follows:
85
83
  # 1) I'll set the event's source and target to TS values.
86
84
  # 2) Return the first source/target as the taint target.
87
85
  def determine_taint_target event_dtm
@@ -22,11 +22,11 @@ module Contrast
22
22
  else
23
23
  ObjectSpace.define_finalizer(key, finalizing_proc)
24
24
  end
25
- super key.__id__, obj
25
+ super(key.__id__, obj)
26
26
  end
27
27
 
28
28
  def [] key
29
- super key.__id__
29
+ super(key.__id__)
30
30
  end
31
31
 
32
32
  # Something is trackable if it is not a collection and either not frozen or it was frozen after we put a
@@ -18,11 +18,20 @@ module Contrast
18
18
  # This is just a holder for our policy. Takes the policy JSON and
19
19
  # converts it into hashes that we can access nicely
20
20
  class Policy < Contrast::Agent::Patching::Policy::Policy
21
+ PROVIDER_CLASSES = [
22
+ Contrast::Agent::Assess::Rule::Provider::HardcodedKey,
23
+ Contrast::Agent::Assess::Rule::Provider::HardcodedPassword
24
+ ].cs__freeze
21
25
  # Indicates the folder in `resources` where this policy lives.
22
26
  def self.policy_folder
23
27
  'assess'
24
28
  end
25
29
 
30
+ def initialize
31
+ super
32
+ load_providers
33
+ end
34
+
26
35
  # Indicates is this feature has been disabled by the configuration,
27
36
  # read at startup, and therefore can never be enabled.
28
37
  def disabled_globally?
@@ -33,11 +42,6 @@ module Contrast
33
42
  Contrast::Agent::Assess::Policy::TriggerNode
34
43
  end
35
44
 
36
- def initialize
37
- super
38
- load_providers
39
- end
40
-
41
45
  # Our policy for dataflow rules is a 'dope ass' JSON file. Rather than
42
46
  # hard code in a bunch of things to monkey patch, we let the JSON file
43
47
  # define the conditions in which sources, propagators, and triggers are
@@ -88,11 +92,6 @@ module Contrast
88
92
  providers[instance.rule_id] = instance
89
93
  end
90
94
  end
91
-
92
- PROVIDER_CLASSES = [
93
- Contrast::Agent::Assess::Rule::Provider::HardcodedKey,
94
- Contrast::Agent::Assess::Rule::Provider::HardcodedPassword
95
- ].cs__freeze
96
95
  end
97
96
  end
98
97
  end
@@ -14,6 +14,14 @@ module Contrast
14
14
  # Ruby object, allowing for dynamic patching over hardcoded patching.
15
15
  class PolicyNode < Contrast::Agent::Patching::Policy::PolicyNode
16
16
  include PolicyNodeUtils
17
+ JSON_TAGS = 'tags'
18
+ JSON_DATAFLOW = 'dataflow'
19
+ # The keys used to read from policy.json to create the individual
20
+ # policy nodes. These are common across node types
21
+ JSON_SOURCE = 'source'
22
+ ALL_TYPE = 'A'
23
+ JSON_TARGET = 'target'
24
+ TO_MARKER = '2'
17
25
 
18
26
  attr_accessor :tags, :type
19
27
  attr_reader :sources, :targets, :source_string, :target_string
@@ -45,7 +53,7 @@ module Contrast
45
53
  @sources = convert_policy_markers(source_string)
46
54
  @targets = convert_policy_markers(target_string)
47
55
  @_use_original_object = ORIGINAL_OBJECT_METHODS.include?(@method_name)
48
- @_use_original_on_bang_method = assign_on_bang_check policy_hash
56
+ @_use_original_on_bang_method = assign_on_bang_check(policy_hash)
49
57
  end
50
58
 
51
59
  def assign_on_bang_check policy_hash
@@ -116,8 +124,6 @@ module Contrast
116
124
  end
117
125
  end
118
126
 
119
- ALL_TYPE = 'A'
120
- TO_MARKER = '2'
121
127
  # Convert our action, built from our source and target, into
122
128
  # the TS appropriate action. That's a single source to single
123
129
  # target marker (A,O,P,R)
@@ -149,13 +155,6 @@ module Contrast
149
155
  @event_action
150
156
  end
151
157
 
152
- # The keys used to read from policy.json to create the individual
153
- # policy nodes. These are common across node types
154
- JSON_SOURCE = 'source'
155
- JSON_TARGET = 'target'
156
- JSON_TAGS = 'tags'
157
- JSON_DATAFLOW = 'dataflow'
158
-
159
158
  # This method will check if a method is fit to use it's original object and
160
159
  # that the method is without bang - it does not change the source, but rather
161
160
  # creates a copy of it.