contrast-agent 3.13.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/exe/contrast_service +1 -7
  3. data/ext/cs__assess_active_record_named/cs__active_record_named.c +8 -7
  4. data/ext/cs__assess_array/cs__assess_array.c +6 -5
  5. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +5 -5
  6. data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +2 -1
  7. data/ext/cs__assess_hash/cs__assess_hash.c +18 -17
  8. data/ext/cs__assess_hash/cs__assess_hash.h +2 -1
  9. data/ext/cs__assess_kernel/cs__assess_kernel.c +7 -8
  10. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +18 -16
  11. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.h +1 -0
  12. data/ext/cs__assess_module/cs__assess_module.c +6 -6
  13. data/ext/cs__assess_regexp/cs__assess_regexp.c +4 -4
  14. data/ext/cs__assess_string/cs__assess_string.c +31 -16
  15. data/ext/cs__assess_string/cs__assess_string.h +6 -1
  16. data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c +4 -2
  17. data/ext/cs__assess_yield_track/cs__assess_yield_track.c +2 -2
  18. data/ext/cs__common/cs__common.c +48 -39
  19. data/ext/cs__common/cs__common.h +16 -21
  20. data/ext/cs__contrast_patch/cs__contrast_patch.c +27 -25
  21. data/ext/cs__contrast_patch/cs__contrast_patch.h +5 -7
  22. data/ext/cs__protect_kernel/cs__protect_kernel.c +11 -12
  23. data/ext/cs__protect_kernel/cs__protect_kernel.h +2 -2
  24. data/lib/contrast-agent.rb +1 -1
  25. data/lib/contrast.rb +13 -23
  26. data/lib/contrast/agent.rb +39 -47
  27. data/lib/contrast/agent/assess.rb +12 -12
  28. data/lib/contrast/agent/assess/contrast_event.rb +151 -85
  29. data/lib/contrast/agent/assess/events/event_factory.rb +2 -2
  30. data/lib/contrast/agent/assess/events/source_event.rb +3 -3
  31. data/lib/contrast/agent/assess/finalizers/freeze.rb +15 -0
  32. data/lib/contrast/agent/assess/finalizers/hash.rb +97 -0
  33. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +11 -4
  34. data/lib/contrast/agent/assess/policy/patcher.rb +6 -6
  35. data/lib/contrast/agent/assess/policy/policy.rb +9 -11
  36. data/lib/contrast/agent/assess/policy/policy_node.rb +17 -12
  37. data/lib/contrast/agent/assess/policy/policy_scanner.rb +21 -5
  38. data/lib/contrast/agent/assess/policy/preshift.rb +13 -7
  39. data/lib/contrast/agent/assess/policy/propagation_method.rb +64 -44
  40. data/lib/contrast/agent/assess/policy/propagation_node.rb +2 -2
  41. data/lib/contrast/agent/assess/policy/propagator.rb +18 -18
  42. data/lib/contrast/agent/assess/policy/propagator/append.rb +8 -5
  43. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  44. data/lib/contrast/agent/assess/policy/propagator/center.rb +9 -5
  45. data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
  46. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +6 -4
  47. data/lib/contrast/agent/assess/policy/propagator/insert.rb +7 -4
  48. data/lib/contrast/agent/assess/policy/propagator/keep.rb +4 -1
  49. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +7 -9
  50. data/lib/contrast/agent/assess/policy/propagator/next.rb +7 -5
  51. data/lib/contrast/agent/assess/policy/propagator/prepend.rb +13 -5
  52. data/lib/contrast/agent/assess/policy/propagator/remove.rb +8 -4
  53. data/lib/contrast/agent/assess/policy/propagator/replace.rb +5 -2
  54. data/lib/contrast/agent/assess/policy/propagator/reverse.rb +7 -5
  55. data/lib/contrast/agent/assess/policy/propagator/select.rb +13 -7
  56. data/lib/contrast/agent/assess/policy/propagator/splat.rb +10 -9
  57. data/lib/contrast/agent/assess/policy/propagator/split.rb +27 -22
  58. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +52 -35
  59. data/lib/contrast/agent/assess/policy/propagator/trim.rb +11 -5
  60. data/lib/contrast/agent/assess/policy/rewriter_patch.rb +5 -5
  61. data/lib/contrast/agent/assess/policy/source_method.rb +90 -72
  62. data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +1 -1
  63. data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
  64. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +16 -12
  65. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +2 -2
  66. data/lib/contrast/agent/assess/policy/trigger_method.rb +81 -33
  67. data/lib/contrast/agent/assess/policy/trigger_node.rb +41 -46
  68. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +2 -1
  69. data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +2 -2
  70. data/lib/contrast/agent/assess/properties.rb +15 -5
  71. data/lib/contrast/agent/assess/property/evented.rb +7 -20
  72. data/lib/contrast/agent/assess/property/tagged.rb +13 -7
  73. data/lib/contrast/agent/assess/property/updated.rb +131 -0
  74. data/lib/contrast/agent/assess/rule.rb +2 -2
  75. data/lib/contrast/agent/assess/rule/base.rb +3 -4
  76. data/lib/contrast/agent/assess/rule/provider.rb +3 -3
  77. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +58 -5
  78. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +24 -9
  79. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +85 -16
  80. data/lib/contrast/agent/assess/tag.rb +1 -1
  81. data/lib/contrast/agent/assess/tracker.rb +66 -0
  82. data/lib/contrast/agent/at_exit_hook.rb +6 -6
  83. data/lib/contrast/agent/class_reopener.rb +14 -11
  84. data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
  85. data/lib/contrast/agent/deadzone/policy/policy.rb +2 -2
  86. data/lib/contrast/agent/disable_reaction.rb +1 -1
  87. data/lib/contrast/agent/exclusion_matcher.rb +1 -1
  88. data/lib/contrast/agent/inventory.rb +15 -0
  89. data/lib/contrast/agent/inventory/dependencies.rb +50 -0
  90. data/lib/contrast/agent/inventory/dependency_analysis.rb +37 -0
  91. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +104 -0
  92. data/lib/contrast/agent/inventory/gemfile_digest_cache.rb +38 -0
  93. data/lib/contrast/agent/inventory/policy/datastores.rb +2 -2
  94. data/lib/contrast/agent/inventory/policy/policy.rb +3 -3
  95. data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
  96. data/lib/contrast/agent/middleware.rb +33 -34
  97. data/lib/contrast/agent/patching/policy/after_load_patch.rb +9 -9
  98. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +23 -22
  99. data/lib/contrast/agent/patching/policy/module_policy.rb +11 -11
  100. data/lib/contrast/agent/patching/policy/patch.rb +15 -15
  101. data/lib/contrast/agent/patching/policy/patcher.rb +43 -44
  102. data/lib/contrast/agent/patching/policy/policy.rb +23 -12
  103. data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
  104. data/lib/contrast/agent/patching/policy/trigger_node.rb +2 -2
  105. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +6 -8
  106. data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +2 -2
  107. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -2
  108. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +7 -6
  109. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +2 -2
  110. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +4 -4
  111. data/lib/contrast/agent/protect/policy/policy.rb +8 -8
  112. data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
  113. data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
  114. data/lib/contrast/agent/protect/rule.rb +18 -18
  115. data/lib/contrast/agent/protect/rule/base.rb +4 -3
  116. data/lib/contrast/agent/protect/rule/base_service.rb +1 -1
  117. data/lib/contrast/agent/protect/rule/cmd_injection.rb +5 -5
  118. data/lib/contrast/agent/protect/rule/deserialization.rb +1 -1
  119. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +1 -1
  120. data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -1
  121. data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -0
  122. data/lib/contrast/agent/protect/rule/path_traversal.rb +4 -5
  123. data/lib/contrast/agent/protect/rule/sqli.rb +2 -2
  124. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -1
  125. data/lib/contrast/agent/protect/rule/xss.rb +1 -1
  126. data/lib/contrast/agent/protect/rule/xxe.rb +3 -5
  127. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +2 -2
  128. data/lib/contrast/agent/railtie.rb +1 -1
  129. data/lib/contrast/agent/reaction_processor.rb +2 -2
  130. data/lib/contrast/agent/request.rb +45 -43
  131. data/lib/contrast/agent/request_context.rb +10 -6
  132. data/lib/contrast/agent/request_handler.rb +1 -1
  133. data/lib/contrast/agent/response.rb +23 -12
  134. data/lib/contrast/agent/rewriter.rb +6 -9
  135. data/lib/contrast/agent/service_heartbeat.rb +2 -2
  136. data/lib/contrast/agent/static_analysis.rb +9 -9
  137. data/lib/contrast/agent/thread.rb +1 -1
  138. data/lib/contrast/agent/thread_watcher.rb +2 -2
  139. data/lib/contrast/agent/tracepoint_hook.rb +2 -2
  140. data/lib/contrast/agent/version.rb +1 -1
  141. data/lib/contrast/api.rb +4 -4
  142. data/lib/contrast/api/communication.rb +9 -9
  143. data/lib/contrast/api/communication/messaging_queue.rb +3 -6
  144. data/lib/contrast/api/communication/response_processor.rb +1 -1
  145. data/lib/contrast/api/communication/socket_client.rb +41 -6
  146. data/lib/contrast/api/communication/speedracer.rb +1 -1
  147. data/lib/contrast/api/communication/tcp_socket.rb +1 -1
  148. data/lib/contrast/api/communication/unix_socket.rb +1 -1
  149. data/lib/contrast/api/decorators.rb +17 -14
  150. data/lib/contrast/api/decorators/address.rb +20 -20
  151. data/lib/contrast/api/decorators/application_settings.rb +3 -2
  152. data/lib/contrast/api/decorators/application_update.rb +7 -8
  153. data/lib/contrast/api/decorators/http_request.rb +13 -12
  154. data/lib/contrast/api/decorators/input_analysis.rb +3 -2
  155. data/lib/contrast/api/decorators/library.rb +53 -0
  156. data/lib/contrast/api/decorators/library_usage_update.rb +30 -0
  157. data/lib/contrast/api/decorators/message.rb +4 -2
  158. data/lib/contrast/api/decorators/rasp_rule_sample.rb +2 -1
  159. data/lib/contrast/api/decorators/route_coverage.rb +3 -2
  160. data/lib/contrast/api/decorators/server_features.rb +3 -2
  161. data/lib/contrast/api/decorators/trace_event.rb +28 -25
  162. data/lib/contrast/api/decorators/trace_event_object.rb +6 -5
  163. data/lib/contrast/api/decorators/trace_event_signature.rb +5 -4
  164. data/lib/contrast/api/decorators/trace_taint_range.rb +4 -3
  165. data/lib/contrast/api/decorators/user_input.rb +4 -4
  166. data/lib/contrast/common_agent_configuration.rb +2 -2
  167. data/lib/contrast/components/agent.rb +8 -7
  168. data/lib/contrast/components/app_context.rb +50 -39
  169. data/lib/contrast/components/config.rb +32 -50
  170. data/lib/contrast/components/contrast_service.rb +10 -10
  171. data/lib/contrast/components/interface.rb +39 -17
  172. data/lib/contrast/components/inventory.rb +6 -1
  173. data/lib/contrast/components/logger.rb +1 -1
  174. data/lib/contrast/components/scope.rb +3 -3
  175. data/lib/contrast/components/settings.rb +20 -23
  176. data/lib/contrast/config.rb +18 -18
  177. data/lib/contrast/config/application_configuration.rb +5 -2
  178. data/lib/contrast/config/base_configuration.rb +2 -2
  179. data/lib/contrast/config/inventory_configuration.rb +2 -2
  180. data/lib/contrast/config/protect_rule_configuration.rb +1 -1
  181. data/lib/contrast/config/service_configuration.rb +8 -0
  182. data/lib/contrast/configuration.rb +93 -52
  183. data/lib/contrast/extension/assess.rb +21 -22
  184. data/lib/contrast/extension/assess/array.rb +18 -11
  185. data/lib/contrast/extension/assess/erb.rb +11 -3
  186. data/lib/contrast/extension/assess/eval_trigger.rb +7 -7
  187. data/lib/contrast/extension/assess/exec_trigger.rb +2 -2
  188. data/lib/contrast/extension/assess/fiber.rb +14 -14
  189. data/lib/contrast/extension/assess/hash.rb +7 -6
  190. data/lib/contrast/extension/assess/kernel.rb +34 -28
  191. data/lib/contrast/extension/assess/marshal.rb +67 -0
  192. data/lib/contrast/extension/assess/regexp.rb +10 -9
  193. data/lib/contrast/extension/assess/string.rb +23 -23
  194. data/lib/contrast/extension/inventory.rb +4 -4
  195. data/lib/contrast/extension/kernel.rb +1 -1
  196. data/lib/contrast/extension/module.rb +1 -1
  197. data/lib/contrast/extension/protect.rb +3 -3
  198. data/lib/contrast/extension/protect/kernel.rb +4 -4
  199. data/lib/contrast/extension/protect/psych.rb +2 -2
  200. data/lib/contrast/framework/base_support.rb +1 -1
  201. data/lib/contrast/framework/manager.rb +10 -11
  202. data/lib/contrast/framework/rack/patch/session_cookie.rb +23 -29
  203. data/lib/contrast/framework/rack/patch/support.rb +1 -1
  204. data/lib/contrast/framework/rack/support.rb +2 -2
  205. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +13 -13
  206. data/lib/contrast/framework/rails/patch/assess_configuration.rb +7 -13
  207. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +11 -11
  208. data/lib/contrast/framework/rails/patch/support.rb +4 -4
  209. data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +11 -11
  210. data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +12 -12
  211. data/lib/contrast/framework/rails/rewrite/active_record_named.rb +4 -4
  212. data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +12 -12
  213. data/lib/contrast/framework/rails/support.rb +67 -14
  214. data/lib/contrast/framework/sinatra/patch/base.rb +12 -12
  215. data/lib/contrast/framework/sinatra/patch/support.rb +1 -1
  216. data/lib/contrast/framework/sinatra/support.rb +6 -6
  217. data/lib/contrast/funchook/funchook.rb +1 -1
  218. data/lib/contrast/logger/application.rb +13 -5
  219. data/lib/contrast/logger/format.rb +22 -9
  220. data/lib/contrast/logger/log.rb +17 -10
  221. data/lib/contrast/logger/request.rb +30 -0
  222. data/lib/contrast/tasks/config.rb +1 -1
  223. data/lib/contrast/tasks/service.rb +2 -2
  224. data/lib/contrast/utils/assess/sampling_util.rb +2 -2
  225. data/lib/contrast/utils/assess/tracking_util.rb +49 -4
  226. data/lib/contrast/utils/class_util.rb +2 -2
  227. data/lib/contrast/utils/duck_utils.rb +0 -10
  228. data/lib/contrast/utils/env_configuration_item.rb +2 -1
  229. data/lib/contrast/utils/hash_digest.rb +2 -1
  230. data/lib/contrast/utils/heap_dump_util.rb +2 -2
  231. data/lib/contrast/utils/invalid_configuration_util.rb +21 -22
  232. data/lib/contrast/utils/inventory_util.rb +3 -10
  233. data/lib/contrast/utils/io_util.rb +1 -1
  234. data/lib/contrast/utils/os.rb +1 -1
  235. data/lib/contrast/utils/ruby_ast_rewriter.rb +1 -1
  236. data/lib/contrast/utils/sha256_builder.rb +2 -14
  237. data/lib/contrast/utils/stack_trace_utils.rb +2 -2
  238. data/lib/contrast/utils/string_utils.rb +11 -6
  239. data/resources/assess/policy.json +31 -22
  240. data/ruby-agent.gemspec +21 -19
  241. data/service_executables/VERSION +1 -1
  242. data/service_executables/linux/contrast-service +0 -0
  243. data/service_executables/mac/contrast-service +0 -0
  244. metadata +73 -30
  245. data/lib/contrast/agent/assess/insulator.rb +0 -49
  246. data/lib/contrast/agent/require_state.rb +0 -61
  247. data/lib/contrast/extension/assess/assess_extension.rb +0 -147
  248. data/lib/contrast/utils/boolean_util.rb +0 -30
  249. data/lib/contrast/utils/freeze_util.rb +0 -32
  250. data/lib/contrast/utils/gemfile_reader.rb +0 -193
@@ -1 +1 @@
1
- 2.9.5
1
+ 2.15.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrast-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - galen.palmer@contrastsecurity.com
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2020-07-29 00:00:00.000000000 Z
15
+ date: 2020-11-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amazing_print
@@ -56,6 +56,20 @@ dependencies:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
+ - !ruby/object:Gem::Dependency
60
+ name: debase
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
59
73
  - !ruby/object:Gem::Dependency
60
74
  name: debride
61
75
  requirement: !ruby/object:Gem::Requirement
@@ -126,6 +140,20 @@ dependencies:
126
140
  - - ">="
127
141
  - !ruby/object:Gem::Version
128
142
  version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: flay
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
129
157
  - !ruby/object:Gem::Dependency
130
158
  name: openssl
131
159
  requirement: !ruby/object:Gem::Requirement
@@ -258,42 +286,56 @@ dependencies:
258
286
  requirements:
259
287
  - - '='
260
288
  - !ruby/object:Gem::Version
261
- version: 0.83.0
289
+ version: 0.93.1
262
290
  type: :development
263
291
  prerelease: false
264
292
  version_requirements: !ruby/object:Gem::Requirement
265
293
  requirements:
266
294
  - - '='
267
295
  - !ruby/object:Gem::Version
268
- version: 0.83.0
296
+ version: 0.93.1
269
297
  - !ruby/object:Gem::Dependency
270
298
  name: rubocop-performance
271
299
  requirement: !ruby/object:Gem::Requirement
272
300
  requirements:
273
301
  - - '='
274
302
  - !ruby/object:Gem::Version
275
- version: 1.5.2
303
+ version: 1.8.1
276
304
  type: :development
277
305
  prerelease: false
278
306
  version_requirements: !ruby/object:Gem::Requirement
279
307
  requirements:
280
308
  - - '='
281
309
  - !ruby/object:Gem::Version
282
- version: 1.5.2
310
+ version: 1.8.1
283
311
  - !ruby/object:Gem::Dependency
284
312
  name: rubocop-rspec
285
313
  requirement: !ruby/object:Gem::Requirement
286
314
  requirements:
287
315
  - - '='
288
316
  - !ruby/object:Gem::Version
289
- version: 1.39.0
317
+ version: 1.43.2
290
318
  type: :development
291
319
  prerelease: false
292
320
  version_requirements: !ruby/object:Gem::Requirement
293
321
  requirements:
294
322
  - - '='
295
323
  - !ruby/object:Gem::Version
296
- version: 1.39.0
324
+ version: 1.43.2
325
+ - !ruby/object:Gem::Dependency
326
+ name: ruby-debug-ide
327
+ requirement: !ruby/object:Gem::Requirement
328
+ requirements:
329
+ - - ">="
330
+ - !ruby/object:Gem::Version
331
+ version: '0'
332
+ type: :development
333
+ prerelease: false
334
+ version_requirements: !ruby/object:Gem::Requirement
335
+ requirements:
336
+ - - ">="
337
+ - !ruby/object:Gem::Version
338
+ version: '0'
297
339
  - !ruby/object:Gem::Dependency
298
340
  name: simplecov
299
341
  requirement: !ruby/object:Gem::Requirement
@@ -438,22 +480,16 @@ dependencies:
438
480
  name: rack
439
481
  requirement: !ruby/object:Gem::Requirement
440
482
  requirements:
441
- - - ">="
483
+ - - "~>"
442
484
  - !ruby/object:Gem::Version
443
485
  version: '2.0'
444
- - - "<"
445
- - !ruby/object:Gem::Version
446
- version: '3.0'
447
486
  type: :runtime
448
487
  prerelease: false
449
488
  version_requirements: !ruby/object:Gem::Requirement
450
489
  requirements:
451
- - - ">="
490
+ - - "~>"
452
491
  - !ruby/object:Gem::Version
453
492
  version: '2.0'
454
- - - "<"
455
- - !ruby/object:Gem::Version
456
- version: '3.0'
457
493
  description: This gem instantiates a Rack middleware for rack-based web applications
458
494
  in order to provide Interactive Application Security Testing and Protection.
459
495
  email:
@@ -462,20 +498,20 @@ executables:
462
498
  - contrast_service
463
499
  extensions:
464
500
  - ext/cs__common/extconf.rb
465
- - ext/cs__assess_marshal_module/extconf.rb
501
+ - ext/cs__contrast_patch/extconf.rb
466
502
  - ext/cs__assess_active_record_named/extconf.rb
467
- - ext/cs__assess_string_interpolation26/extconf.rb
468
503
  - ext/cs__assess_module/extconf.rb
469
- - ext/cs__protect_kernel/extconf.rb
504
+ - ext/cs__assess_marshal_module/extconf.rb
470
505
  - ext/cs__assess_hash/extconf.rb
471
- - ext/cs__assess_fiber_track/extconf.rb
472
- - ext/cs__assess_kernel/extconf.rb
506
+ - ext/cs__assess_regexp/extconf.rb
473
507
  - ext/cs__assess_string/extconf.rb
474
- - ext/cs__assess_basic_object/extconf.rb
508
+ - ext/cs__protect_kernel/extconf.rb
509
+ - ext/cs__assess_string_interpolation26/extconf.rb
510
+ - ext/cs__assess_kernel/extconf.rb
511
+ - ext/cs__assess_fiber_track/extconf.rb
475
512
  - ext/cs__assess_array/extconf.rb
476
- - ext/cs__contrast_patch/extconf.rb
477
513
  - ext/cs__assess_yield_track/extconf.rb
478
- - ext/cs__assess_regexp/extconf.rb
514
+ - ext/cs__assess_basic_object/extconf.rb
479
515
  extra_rdoc_files: []
480
516
  files:
481
517
  - ".clang-format"
@@ -674,7 +710,8 @@ files:
674
710
  - lib/contrast/agent/assess/contrast_event.rb
675
711
  - lib/contrast/agent/assess/events/event_factory.rb
676
712
  - lib/contrast/agent/assess/events/source_event.rb
677
- - lib/contrast/agent/assess/insulator.rb
713
+ - lib/contrast/agent/assess/finalizers/freeze.rb
714
+ - lib/contrast/agent/assess/finalizers/hash.rb
678
715
  - lib/contrast/agent/assess/policy/dynamic_source_factory.rb
679
716
  - lib/contrast/agent/assess/policy/patcher.rb
680
717
  - lib/contrast/agent/assess/policy/policy.rb
@@ -717,6 +754,7 @@ files:
717
754
  - lib/contrast/agent/assess/properties.rb
718
755
  - lib/contrast/agent/assess/property/evented.rb
719
756
  - lib/contrast/agent/assess/property/tagged.rb
757
+ - lib/contrast/agent/assess/property/updated.rb
720
758
  - lib/contrast/agent/assess/rule.rb
721
759
  - lib/contrast/agent/assess/rule/base.rb
722
760
  - lib/contrast/agent/assess/rule/provider.rb
@@ -725,12 +763,18 @@ files:
725
763
  - lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb
726
764
  - lib/contrast/agent/assess/rule/redos.rb
727
765
  - lib/contrast/agent/assess/tag.rb
766
+ - lib/contrast/agent/assess/tracker.rb
728
767
  - lib/contrast/agent/at_exit_hook.rb
729
768
  - lib/contrast/agent/class_reopener.rb
730
769
  - lib/contrast/agent/deadzone/policy/deadzone_node.rb
731
770
  - lib/contrast/agent/deadzone/policy/policy.rb
732
771
  - lib/contrast/agent/disable_reaction.rb
733
772
  - lib/contrast/agent/exclusion_matcher.rb
773
+ - lib/contrast/agent/inventory.rb
774
+ - lib/contrast/agent/inventory/dependencies.rb
775
+ - lib/contrast/agent/inventory/dependency_analysis.rb
776
+ - lib/contrast/agent/inventory/dependency_usage_analysis.rb
777
+ - lib/contrast/agent/inventory/gemfile_digest_cache.rb
734
778
  - lib/contrast/agent/inventory/policy/datastores.rb
735
779
  - lib/contrast/agent/inventory/policy/policy.rb
736
780
  - lib/contrast/agent/inventory/policy/trigger_node.rb
@@ -779,7 +823,6 @@ files:
779
823
  - lib/contrast/agent/request.rb
780
824
  - lib/contrast/agent/request_context.rb
781
825
  - lib/contrast/agent/request_handler.rb
782
- - lib/contrast/agent/require_state.rb
783
826
  - lib/contrast/agent/response.rb
784
827
  - lib/contrast/agent/rewriter.rb
785
828
  - lib/contrast/agent/rule_set.rb
@@ -809,6 +852,8 @@ files:
809
852
  - lib/contrast/api/decorators/application_update.rb
810
853
  - lib/contrast/api/decorators/http_request.rb
811
854
  - lib/contrast/api/decorators/input_analysis.rb
855
+ - lib/contrast/api/decorators/library.rb
856
+ - lib/contrast/api/decorators/library_usage_update.rb
812
857
  - lib/contrast/api/decorators/message.rb
813
858
  - lib/contrast/api/decorators/rasp_rule_sample.rb
814
859
  - lib/contrast/api/decorators/route_coverage.rb
@@ -857,13 +902,13 @@ files:
857
902
  - lib/contrast/configuration.rb
858
903
  - lib/contrast/extension/assess.rb
859
904
  - lib/contrast/extension/assess/array.rb
860
- - lib/contrast/extension/assess/assess_extension.rb
861
905
  - lib/contrast/extension/assess/erb.rb
862
906
  - lib/contrast/extension/assess/eval_trigger.rb
863
907
  - lib/contrast/extension/assess/exec_trigger.rb
864
908
  - lib/contrast/extension/assess/fiber.rb
865
909
  - lib/contrast/extension/assess/hash.rb
866
910
  - lib/contrast/extension/assess/kernel.rb
911
+ - lib/contrast/extension/assess/marshal.rb
867
912
  - lib/contrast/extension/assess/regexp.rb
868
913
  - lib/contrast/extension/assess/string.rb
869
914
  - lib/contrast/extension/delegator.rb
@@ -896,18 +941,16 @@ files:
896
941
  - lib/contrast/logger/application.rb
897
942
  - lib/contrast/logger/format.rb
898
943
  - lib/contrast/logger/log.rb
944
+ - lib/contrast/logger/request.rb
899
945
  - lib/contrast/logger/time.rb
900
946
  - lib/contrast/security_exception.rb
901
947
  - lib/contrast/tasks/config.rb
902
948
  - lib/contrast/tasks/service.rb
903
949
  - lib/contrast/utils/assess/sampling_util.rb
904
950
  - lib/contrast/utils/assess/tracking_util.rb
905
- - lib/contrast/utils/boolean_util.rb
906
951
  - lib/contrast/utils/class_util.rb
907
952
  - lib/contrast/utils/duck_utils.rb
908
953
  - lib/contrast/utils/env_configuration_item.rb
909
- - lib/contrast/utils/freeze_util.rb
910
- - lib/contrast/utils/gemfile_reader.rb
911
954
  - lib/contrast/utils/hash_digest.rb
912
955
  - lib/contrast/utils/heap_dump_util.rb
913
956
  - lib/contrast/utils/invalid_configuration_util.rb
@@ -1,49 +0,0 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- cs__scoped_require 'contrast/utils/prevent_serialization'
5
- cs__scoped_require 'contrast/agent/assess/properties'
6
-
7
- module Contrast
8
- module Agent
9
- module Assess
10
- # This is just a wrapper around Properties so that if they are on a frozen
11
- # object, they are left mutable for us.
12
- class Insulator
13
- # Return a new delegator with a properties method, used to track
14
- # properties in a manner that won't be serialized.
15
- #
16
- # @return [SimpleDelegator<Object>]
17
- def self.generate
18
- delegator = SimpleDelegator.new(nil)
19
- delegator.extend(Contrast::Utils::PreventPsychSerialization)
20
- delegator
21
- end
22
-
23
- # Return the frozen properties delegator, which is a
24
- #
25
- # @return [SimpleDelegator<Object>]
26
- def self.generate_frozen
27
- @_generate_frozen ||= begin
28
- delegator = SimpleDelegator.new(nil)
29
- delegator.extend(Contrast::Utils::PreventPsychSerialization)
30
- delegator
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
-
38
- # Our patch of the SimpleDelegator class, allowing us to leverage its
39
- # marshal_dump and marshal_load methods to hide our properties on an object so
40
- # that they will not be dumped or loaded.
41
- # We do this to prevent polluting data that may run on applications that are no
42
- # longer instrumented with Contrast
43
- class SimpleDelegator
44
- # rubocop:disable Naming/MemoizedInstanceVariableName
45
- def properties
46
- @delegate_properties ||= Contrast::Agent::Assess::Properties.new
47
- end
48
- # rubocop:enable Naming/MemoizedInstanceVariableName
49
- end
@@ -1,61 +0,0 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Agent
6
- # Thread local way to access the current RequireState. Used as a convenient
7
- # wrapper to ensure specific key is used and that we handle the case when
8
- # we try to enter a previously unset require scope.
9
- # (Note that 'require scopes' track nested requires. This is distinct
10
- # from 'contrast scope', which tracks instrumentation.)
11
- module RequireStates
12
- class << self
13
- KEY = :thread_local_contrast_require_scope
14
-
15
- def enter
16
- scope = current_scope
17
- unless current_scope
18
- scope = RequireState.new
19
- Thread.current[KEY] = scope
20
- end
21
- scope.enter
22
- end
23
-
24
- def exit
25
- current_scope.exit
26
- end
27
-
28
- def current_scope
29
- Thread.current[KEY]
30
- end
31
-
32
- def status
33
- current_scope&.scope.to_s
34
- end
35
-
36
- def in_scope?
37
- scope = current_scope
38
- scope && scope.scope > 1
39
- end
40
- end
41
- end
42
-
43
- # Simple counter class for tracking how deep in nested requires / file
44
- # load operations we currently are.
45
- class RequireState
46
- attr_reader :scope
47
-
48
- def initialize
49
- @scope = 0
50
- end
51
-
52
- def enter
53
- @scope += 1
54
- end
55
-
56
- def exit
57
- @scope -= 1
58
- end
59
- end
60
- end
61
- end
@@ -1,147 +0,0 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- cs__scoped_require 'contrast/agent/assess/properties'
5
- cs__scoped_require 'contrast/agent/assess/insulator'
6
-
7
- module Contrast
8
- module Extension
9
- module Assess
10
- # This module is responsible for maintaining the data we need to
11
- # construct a trace event for the object in which it is included. Rather
12
- # than have this code all over the place, any class that wants to use
13
- # dataflow features should be sent
14
- # 'include Contrast::Extension::Assess::AssessExtension'
15
- module AssessExtension
16
- # Lazily build properties object. Only objects that have been tracked
17
- # will have the @_cs__properties, but all will respond to the
18
- # cs__properties method call. You should only call this method if you
19
- # either intend to start tracking an object or you have already checked
20
- # cs__tracked? and it is true.
21
- def cs__properties
22
- # If this object was tracked before being frozen, it'll have
23
- # mutable properties we need inside of the insulator @_cs__properties
24
- if cs__frozen?
25
- if instance_variable_defined?(:@_cs__properties)
26
- @_cs__properties.properties
27
- else
28
- Contrast::Agent::Assess::Insulator.generate_frozen.properties
29
- end
30
- else
31
- @_cs__properties ||= Contrast::Agent::Assess::Insulator.generate
32
- @_cs__properties.properties
33
- end
34
- end
35
-
36
- def cs__properties?
37
- instance_variable_defined?(:@_cs__properties)
38
- end
39
-
40
- # This is a way to check if we are already tracking an object without
41
- # adding tracking to it. If the object already has been tracked we will
42
- # return the tracking state of its properties. If the object hasn't
43
- # already been tracked we will return false without starting to track
44
- # it
45
- def cs__tracked?
46
- cs__properties? && cs__properties.tracked?
47
- end
48
-
49
- def cs__reset_properties
50
- return unless cs__properties?
51
-
52
- @_cs__properties = nil
53
- end
54
-
55
- # copy tags and info from object to self if object support methods
56
- # obj: the object from which to copy tags and events
57
- # shift: how far to shift the tags, negative moves left
58
- # skip_tags: array of tags to skip copying
59
- def cs__copy_from obj, shift = 0, skip_tags = nil
60
- return if obj.equal?(self)
61
- return unless Contrast::Utils::DuckUtils.quacks_to?(obj,
62
- :cs__tracked?)
63
- return unless obj.cs__tracked?
64
- return if cs__properties == Contrast::Agent::Assess::Insulator.generate_frozen.properties
65
-
66
- # This was fun to find...
67
- # the clone and dup methods don't apply to instance variables in the
68
- # cloned/ duped thing, so the arrays in the properties were the same.
69
- # The most infinite of infinite loops ensued.
70
- # DO NOT TAKE THIS OUT!
71
- cs__reset_properties if obj.cs__properties == cs__properties
72
-
73
- obj.cs__properties.events.each do |event|
74
- cs__properties.events << event
75
- end
76
-
77
- obj.cs__properties.tag_keys.each do |key|
78
- next if skip_tags&.include?(key)
79
-
80
- new_tags = []
81
- value = obj.cs__properties.fetch_tag(key)
82
- value.each do |tag|
83
- new_tags << tag.copy_modified(shift)
84
- end
85
- existing = cs__properties.fetch_tag(key)
86
- if existing
87
- existing.concat(new_tags)
88
- Contrast::Utils::TagUtil.size_aware_merge(self, existing)
89
- else
90
- cs__properties.set_tags(key, new_tags)
91
- end
92
- end
93
- end
94
-
95
- # Some propagation occurred, but we're not sure what the
96
- # exact transformation was. To be safe, we just explode
97
- # all the tags from the source to the return.
98
- #
99
- # If the return already had that tag, the existing tag
100
- # range is recycled to save us an object.
101
- def cs__splat_tags ret, source = self
102
- return unless Contrast::Utils::DuckUtils.trackable?(ret)
103
-
104
- length = Contrast::Utils::StringUtils.ret_length(ret)
105
- return if length.zero?
106
-
107
- cs__splat_from_source(ret, length, source)
108
- cs__splat_from_ret(ret, length)
109
- end
110
-
111
- def cs__splat_from_source ret, ret_length, source
112
- splat_source = Contrast::Utils::DuckUtils.trackable?(source)
113
- splat_source &&= source.cs__tracked?
114
- return unless splat_source
115
-
116
- source.cs__properties.tag_keys.each do |key|
117
- existing = ret.cs__properties.fetch_tag(key)
118
- # if the tag already exists, drop all but the first range
119
- # then change that range to cover the entire return
120
- if existing
121
- existing.drop(existing.length - 1)
122
- range = existing[0]
123
- range.repurpose(0, ret_length)
124
- else
125
- ret.cs__properties.add_tag(key, 0...ret_length)
126
- end
127
- end
128
- end
129
-
130
- def cs__splat_from_ret ret, length
131
- return unless ret.cs__tracked?
132
-
133
- ret.cs__properties.tag_keys.each do |key|
134
- next unless key
135
-
136
- existing = ret.cs__properties.fetch_tag(key)
137
- next unless existing
138
-
139
- existing.each do |range|
140
- range.update_end(length) if range.end_idx > length
141
- end
142
- end
143
- end
144
- end
145
- end
146
- end
147
- end