contrast-agent 4.6.0 → 4.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -1
  3. data/.gitmodules +1 -1
  4. data/.simplecov +1 -0
  5. data/Rakefile +1 -2
  6. data/ext/build_funchook.rb +3 -3
  7. data/ext/extconf_common.rb +1 -5
  8. data/lib/contrast.rb +24 -14
  9. data/lib/contrast/agent/assess.rb +1 -1
  10. data/lib/contrast/agent/assess/contrast_event.rb +1 -4
  11. data/lib/contrast/agent/assess/contrast_object.rb +2 -2
  12. data/lib/contrast/agent/assess/events/event_factory.rb +2 -1
  13. data/lib/contrast/agent/assess/finalizers/hash.rb +2 -4
  14. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +6 -3
  15. data/lib/contrast/agent/assess/policy/patcher.rb +16 -21
  16. data/lib/contrast/agent/assess/policy/policy.rb +1 -1
  17. data/lib/contrast/agent/assess/policy/policy_node.rb +25 -33
  18. data/lib/contrast/agent/assess/policy/policy_scanner.rb +3 -5
  19. data/lib/contrast/agent/assess/policy/preshift.rb +7 -5
  20. data/lib/contrast/agent/assess/policy/propagation_method.rb +10 -19
  21. data/lib/contrast/agent/assess/policy/propagation_node.rb +19 -8
  22. data/lib/contrast/agent/assess/policy/propagator.rb +1 -0
  23. data/lib/contrast/agent/assess/policy/propagator/center.rb +2 -1
  24. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +3 -6
  25. data/lib/contrast/agent/assess/policy/propagator/insert.rb +3 -1
  26. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +2 -1
  27. data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +73 -0
  28. data/lib/contrast/agent/assess/policy/propagator/select.rb +2 -12
  29. data/lib/contrast/agent/assess/policy/propagator/split.rb +12 -13
  30. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +3 -10
  31. data/lib/contrast/agent/assess/policy/propagator/trim.rb +3 -15
  32. data/lib/contrast/agent/assess/policy/rewriter_patch.rb +13 -10
  33. data/lib/contrast/agent/assess/policy/source_method.rb +12 -12
  34. data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -3
  35. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +5 -1
  36. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +0 -3
  37. data/lib/contrast/agent/assess/policy/trigger_method.rb +8 -18
  38. data/lib/contrast/agent/assess/policy/trigger_node.rb +3 -2
  39. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +4 -3
  40. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -2
  41. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -8
  42. data/lib/contrast/agent/assess/property/evented.rb +8 -5
  43. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +11 -5
  44. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +4 -1
  45. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +7 -9
  46. data/lib/contrast/agent/at_exit_hook.rb +3 -3
  47. data/lib/contrast/agent/class_reopener.rb +9 -6
  48. data/lib/contrast/agent/disable_reaction.rb +4 -7
  49. data/lib/contrast/agent/exclusion_matcher.rb +7 -14
  50. data/lib/contrast/agent/inventory/dependencies.rb +2 -0
  51. data/lib/contrast/agent/inventory/dependency_analysis.rb +2 -6
  52. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +3 -5
  53. data/lib/contrast/agent/inventory/policy/datastores.rb +3 -4
  54. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  55. data/lib/contrast/agent/middleware.rb +17 -18
  56. data/lib/contrast/agent/module_data.rb +3 -3
  57. data/lib/contrast/agent/patching/policy/after_load_patch.rb +3 -3
  58. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +9 -9
  59. data/lib/contrast/agent/patching/policy/method_policy.rb +6 -2
  60. data/lib/contrast/agent/patching/policy/module_policy.rb +14 -7
  61. data/lib/contrast/agent/patching/policy/patch.rb +20 -25
  62. data/lib/contrast/agent/patching/policy/patch_status.rb +6 -7
  63. data/lib/contrast/agent/patching/policy/patcher.rb +21 -18
  64. data/lib/contrast/agent/patching/policy/policy.rb +2 -4
  65. data/lib/contrast/agent/patching/policy/policy_node.rb +16 -7
  66. data/lib/contrast/agent/patching/policy/trigger_node.rb +21 -8
  67. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +1 -1
  68. data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +1 -1
  69. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
  70. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +2 -3
  71. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -1
  72. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +5 -9
  73. data/lib/contrast/agent/protect/policy/policy.rb +1 -1
  74. data/lib/contrast/agent/protect/policy/rule_applicator.rb +7 -9
  75. data/lib/contrast/agent/protect/rule/base.rb +20 -23
  76. data/lib/contrast/agent/protect/rule/base_service.rb +9 -5
  77. data/lib/contrast/agent/protect/rule/cmd_injection.rb +18 -23
  78. data/lib/contrast/agent/protect/rule/deserialization.rb +6 -13
  79. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +3 -14
  80. data/lib/contrast/agent/protect/rule/no_sqli.rb +6 -2
  81. data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -3
  82. data/lib/contrast/agent/protect/rule/path_traversal.rb +6 -10
  83. data/lib/contrast/agent/protect/rule/sqli.rb +1 -1
  84. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -1
  85. data/lib/contrast/agent/protect/rule/xss.rb +1 -1
  86. data/lib/contrast/agent/protect/rule/xxe.rb +5 -12
  87. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +1 -2
  88. data/lib/contrast/agent/reaction_processor.rb +13 -13
  89. data/lib/contrast/agent/request.rb +27 -26
  90. data/lib/contrast/agent/request_context.rb +17 -22
  91. data/lib/contrast/agent/request_handler.rb +5 -3
  92. data/lib/contrast/agent/response.rb +2 -3
  93. data/lib/contrast/agent/rewriter.rb +9 -6
  94. data/lib/contrast/agent/rule_set.rb +5 -4
  95. data/lib/contrast/agent/service_heartbeat.rb +4 -6
  96. data/lib/contrast/agent/static_analysis.rb +6 -5
  97. data/lib/contrast/agent/thread.rb +2 -4
  98. data/lib/contrast/agent/thread_watcher.rb +3 -4
  99. data/lib/contrast/agent/tracepoint_hook.rb +5 -5
  100. data/lib/contrast/agent/version.rb +1 -1
  101. data/lib/contrast/api/communication/messaging_queue.rb +4 -5
  102. data/lib/contrast/api/communication/response_processor.rb +11 -13
  103. data/lib/contrast/api/communication/service_lifecycle.rb +9 -6
  104. data/lib/contrast/api/communication/socket_client.rb +22 -31
  105. data/lib/contrast/api/communication/speedracer.rb +8 -13
  106. data/lib/contrast/api/decorators/address.rb +2 -3
  107. data/lib/contrast/api/decorators/agent_startup.rb +7 -9
  108. data/lib/contrast/api/decorators/application_startup.rb +12 -10
  109. data/lib/contrast/api/decorators/application_update.rb +0 -4
  110. data/lib/contrast/api/decorators/http_request.rb +3 -7
  111. data/lib/contrast/api/decorators/instrumentation_mode.rb +3 -5
  112. data/lib/contrast/api/decorators/library.rb +8 -6
  113. data/lib/contrast/api/decorators/message.rb +9 -9
  114. data/lib/contrast/api/decorators/trace_event.rb +3 -1
  115. data/lib/contrast/api/decorators/trace_event_object.rb +3 -6
  116. data/lib/contrast/api/decorators/trace_taint_range_tags.rb +1 -6
  117. data/lib/contrast/components/agent.rb +17 -17
  118. data/lib/contrast/components/app_context.rb +11 -15
  119. data/lib/contrast/components/assess.rb +16 -16
  120. data/lib/contrast/components/base.rb +40 -0
  121. data/lib/contrast/components/config.rb +2 -3
  122. data/lib/contrast/components/contrast_service.rb +12 -18
  123. data/lib/contrast/components/heap_dump.rb +5 -4
  124. data/lib/contrast/components/inventory.rb +2 -7
  125. data/lib/contrast/components/logger.rb +1 -2
  126. data/lib/contrast/components/protect.rb +10 -13
  127. data/lib/contrast/components/sampling.rb +13 -7
  128. data/lib/contrast/components/scope.rb +0 -4
  129. data/lib/contrast/components/settings.rb +5 -7
  130. data/lib/contrast/config/assess_rules_configuration.rb +1 -3
  131. data/lib/contrast/config/base_configuration.rb +4 -5
  132. data/lib/contrast/config/exception_configuration.rb +1 -5
  133. data/lib/contrast/config/heap_dump_configuration.rb +12 -6
  134. data/lib/contrast/config/logger_configuration.rb +1 -5
  135. data/lib/contrast/configuration.rb +6 -18
  136. data/lib/contrast/extension/assess/array.rb +3 -10
  137. data/lib/contrast/extension/assess/erb.rb +1 -7
  138. data/lib/contrast/extension/assess/eval_trigger.rb +4 -9
  139. data/lib/contrast/extension/assess/exec_trigger.rb +3 -9
  140. data/lib/contrast/extension/assess/fiber.rb +8 -17
  141. data/lib/contrast/extension/assess/hash.rb +3 -3
  142. data/lib/contrast/extension/assess/kernel.rb +4 -13
  143. data/lib/contrast/extension/assess/marshal.rb +6 -10
  144. data/lib/contrast/extension/assess/regexp.rb +6 -10
  145. data/lib/contrast/extension/assess/string.rb +8 -6
  146. data/lib/contrast/extension/kernel.rb +2 -2
  147. data/lib/contrast/extension/protect/kernel.rb +0 -5
  148. data/lib/contrast/framework/manager.rb +3 -5
  149. data/lib/contrast/framework/rack/patch/session_cookie.rb +11 -24
  150. data/lib/contrast/framework/rack/patch/support.rb +6 -4
  151. data/lib/contrast/framework/rails/patch/assess_configuration.rb +12 -9
  152. data/lib/contrast/framework/rails/patch/support.rb +41 -35
  153. data/lib/contrast/framework/rails/railtie.rb +34 -0
  154. data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +4 -1
  155. data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +2 -0
  156. data/lib/contrast/framework/rails/rewrite/active_record_named.rb +5 -4
  157. data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +2 -0
  158. data/lib/contrast/framework/rails/support.rb +2 -2
  159. data/lib/contrast/framework/sinatra/support.rb +3 -1
  160. data/lib/contrast/funchook/funchook.rb +5 -8
  161. data/lib/contrast/logger/application.rb +13 -15
  162. data/lib/contrast/logger/format.rb +2 -5
  163. data/lib/contrast/logger/log.rb +26 -9
  164. data/lib/contrast/logger/request.rb +1 -6
  165. data/lib/contrast/security_exception.rb +1 -1
  166. data/lib/contrast/tasks/config.rb +0 -1
  167. data/lib/contrast/tasks/service.rb +6 -7
  168. data/lib/contrast/utils/assess/sampling_util.rb +2 -3
  169. data/lib/contrast/utils/assess/tracking_util.rb +3 -6
  170. data/lib/contrast/utils/class_util.rb +0 -8
  171. data/lib/contrast/utils/hash_digest.rb +2 -5
  172. data/lib/contrast/utils/heap_dump_util.rb +5 -3
  173. data/lib/contrast/utils/invalid_configuration_util.rb +4 -3
  174. data/lib/contrast/utils/inventory_util.rb +2 -3
  175. data/lib/contrast/utils/io_util.rb +3 -5
  176. data/lib/contrast/utils/job_servers_running.rb +13 -7
  177. data/lib/contrast/utils/os.rb +4 -4
  178. data/lib/contrast/utils/ruby_ast_rewriter.rb +2 -1
  179. data/lib/contrast/utils/string_utils.rb +2 -3
  180. data/lib/contrast/utils/tag_util.rb +25 -19
  181. data/resources/assess/policy.json +55 -0
  182. data/ruby-agent.gemspec +17 -16
  183. data/service_executables/VERSION +1 -1
  184. data/service_executables/linux/contrast-service +0 -0
  185. data/service_executables/mac/contrast-service +0 -0
  186. data/sonar-project.properties +9 -0
  187. metadata +61 -46
  188. data/lib/contrast/agent/railtie.rb +0 -31
  189. data/lib/contrast/components/interface.rb +0 -195
  190. data/lib/contrast/delegators/input_analysis.rb +0 -12
@@ -1 +1 @@
1
- 2.19.0
1
+ 2.21.2
@@ -0,0 +1,9 @@
1
+ sonar.projectKey=Contrast-Security-Inc_ruby-agent
2
+ sonar.organization=contrast-security-inc
3
+
4
+ # Ignore C/CPP/ObjC files
5
+ sonar.c.file.suffixes=-
6
+ sonar.cpp.file.suffixes=-
7
+ sonar.objc.file.suffixes=-
8
+
9
+ sonar.ruby.coverage.reportPaths=coverage/coverage-formatted.json
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: 4.6.0
4
+ version: 4.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - galen.palmer@contrastsecurity.com
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2021-04-22 00:00:00.000000000 Z
16
+ date: 2021-07-15 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -89,72 +89,72 @@ dependencies:
89
89
  name: debride
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ">="
92
+ - - '='
93
93
  - !ruby/object:Gem::Version
94
- version: '0'
94
+ version: 1.8.2
95
95
  type: :development
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ">="
99
+ - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
101
+ version: 1.8.2
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: fasterer
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: '0'
108
+ version: 0.9.0
109
109
  type: :development
110
110
  prerelease: false
111
111
  version_requirements: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: 0.9.0
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: flay
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: 2.12.1
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - '='
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: 2.12.1
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: rubocop
132
132
  requirement: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - '='
135
135
  - !ruby/object:Gem::Version
136
- version: 1.6.1
136
+ version: 1.13.0
137
137
  type: :development
138
138
  prerelease: false
139
139
  version_requirements: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - '='
142
142
  - !ruby/object:Gem::Version
143
- version: 1.6.1
143
+ version: 1.13.0
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: rubocop-performance
146
146
  requirement: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - '='
149
149
  - !ruby/object:Gem::Version
150
- version: 1.9.1
150
+ version: 1.11.0
151
151
  type: :development
152
152
  prerelease: false
153
153
  version_requirements: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - '='
156
156
  - !ruby/object:Gem::Version
157
- version: 1.9.1
157
+ version: 1.11.0
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: rubocop-rails
160
160
  requirement: !ruby/object:Gem::Requirement
@@ -189,42 +189,42 @@ dependencies:
189
189
  requirements:
190
190
  - - '='
191
191
  - !ruby/object:Gem::Version
192
- version: 2.1.0
192
+ version: 2.2.0
193
193
  type: :development
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
196
196
  requirements:
197
197
  - - '='
198
198
  - !ruby/object:Gem::Version
199
- version: 2.1.0
199
+ version: 2.2.0
200
200
  - !ruby/object:Gem::Dependency
201
- name: codecov
201
+ name: simplecov
202
202
  requirement: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - ">="
204
+ - - '='
205
205
  - !ruby/object:Gem::Version
206
- version: '0'
206
+ version: 0.21.2
207
207
  type: :development
208
208
  prerelease: false
209
209
  version_requirements: !ruby/object:Gem::Requirement
210
210
  requirements:
211
- - - ">="
211
+ - - '='
212
212
  - !ruby/object:Gem::Version
213
- version: '0'
213
+ version: 0.21.2
214
214
  - !ruby/object:Gem::Dependency
215
- name: simplecov
215
+ name: rack-protection
216
216
  requirement: !ruby/object:Gem::Requirement
217
217
  requirements:
218
- - - '='
218
+ - - ">="
219
219
  - !ruby/object:Gem::Version
220
- version: 0.20.0
220
+ version: '2'
221
221
  type: :development
222
222
  prerelease: false
223
223
  version_requirements: !ruby/object:Gem::Requirement
224
224
  requirements:
225
- - - '='
225
+ - - ">="
226
226
  - !ruby/object:Gem::Version
227
- version: 0.20.0
227
+ version: '2'
228
228
  - !ruby/object:Gem::Dependency
229
229
  name: rails
230
230
  requirement: !ruby/object:Gem::Requirement
@@ -282,7 +282,7 @@ dependencies:
282
282
  - !ruby/object:Gem::Version
283
283
  version: '0'
284
284
  - !ruby/object:Gem::Dependency
285
- name: sqlite3
285
+ name: rhino
286
286
  requirement: !ruby/object:Gem::Requirement
287
287
  requirements:
288
288
  - - ">="
@@ -296,7 +296,7 @@ dependencies:
296
296
  - !ruby/object:Gem::Version
297
297
  version: '0'
298
298
  - !ruby/object:Gem::Dependency
299
- name: therubyracer
299
+ name: sqlite3
300
300
  requirement: !ruby/object:Gem::Requirement
301
301
  requirements:
302
302
  - - ">="
@@ -463,6 +463,20 @@ dependencies:
463
463
  - - '='
464
464
  - !ruby/object:Gem::Version
465
465
  version: '5.0'
466
+ - !ruby/object:Gem::Dependency
467
+ name: warning
468
+ requirement: !ruby/object:Gem::Requirement
469
+ requirements:
470
+ - - ">="
471
+ - !ruby/object:Gem::Version
472
+ version: '0'
473
+ type: :development
474
+ prerelease: false
475
+ version_requirements: !ruby/object:Gem::Requirement
476
+ requirements:
477
+ - - ">="
478
+ - !ruby/object:Gem::Version
479
+ version: '0'
466
480
  - !ruby/object:Gem::Dependency
467
481
  name: tzinfo-data
468
482
  requirement: !ruby/object:Gem::Requirement
@@ -495,14 +509,14 @@ dependencies:
495
509
  name: parser
496
510
  requirement: !ruby/object:Gem::Requirement
497
511
  requirements:
498
- - - "~>"
512
+ - - ">="
499
513
  - !ruby/object:Gem::Version
500
514
  version: '2.6'
501
515
  type: :runtime
502
516
  prerelease: false
503
517
  version_requirements: !ruby/object:Gem::Requirement
504
518
  requirements:
505
- - - "~>"
519
+ - - ">="
506
520
  - !ruby/object:Gem::Version
507
521
  version: '2.6'
508
522
  - !ruby/object:Gem::Dependency
@@ -541,19 +555,19 @@ executables:
541
555
  - contrast_service
542
556
  extensions:
543
557
  - ext/cs__common/extconf.rb
544
- - ext/cs__assess_array/extconf.rb
545
- - ext/cs__assess_string_interpolation26/extconf.rb
546
- - ext/cs__assess_marshal_module/extconf.rb
547
- - ext/cs__assess_hash/extconf.rb
548
- - ext/cs__assess_yield_track/extconf.rb
549
558
  - ext/cs__assess_string/extconf.rb
559
+ - ext/cs__assess_fiber_track/extconf.rb
560
+ - ext/cs__assess_marshal_module/extconf.rb
550
561
  - ext/cs__protect_kernel/extconf.rb
562
+ - ext/cs__assess_string_interpolation26/extconf.rb
551
563
  - ext/cs__assess_basic_object/extconf.rb
552
- - ext/cs__contrast_patch/extconf.rb
553
- - ext/cs__assess_regexp/extconf.rb
554
- - ext/cs__assess_fiber_track/extconf.rb
555
- - ext/cs__assess_kernel/extconf.rb
556
564
  - ext/cs__assess_active_record_named/extconf.rb
565
+ - ext/cs__assess_yield_track/extconf.rb
566
+ - ext/cs__assess_kernel/extconf.rb
567
+ - ext/cs__assess_array/extconf.rb
568
+ - ext/cs__assess_regexp/extconf.rb
569
+ - ext/cs__assess_hash/extconf.rb
570
+ - ext/cs__contrast_patch/extconf.rb
557
571
  - ext/cs__assess_module/extconf.rb
558
572
  extra_rdoc_files: []
559
573
  files:
@@ -775,6 +789,7 @@ files:
775
789
  - lib/contrast/agent/assess/policy/propagator/match_data.rb
776
790
  - lib/contrast/agent/assess/policy/propagator/next.rb
777
791
  - lib/contrast/agent/assess/policy/propagator/prepend.rb
792
+ - lib/contrast/agent/assess/policy/propagator/rack_protection.rb
778
793
  - lib/contrast/agent/assess/policy/propagator/remove.rb
779
794
  - lib/contrast/agent/assess/policy/propagator/replace.rb
780
795
  - lib/contrast/agent/assess/policy/propagator/reverse.rb
@@ -859,7 +874,6 @@ files:
859
874
  - lib/contrast/agent/protect/rule/xss.rb
860
875
  - lib/contrast/agent/protect/rule/xxe.rb
861
876
  - lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb
862
- - lib/contrast/agent/railtie.rb
863
877
  - lib/contrast/agent/reaction_processor.rb
864
878
  - lib/contrast/agent/request.rb
865
879
  - lib/contrast/agent/request_context.rb
@@ -913,10 +927,10 @@ files:
913
927
  - lib/contrast/components/agent.rb
914
928
  - lib/contrast/components/app_context.rb
915
929
  - lib/contrast/components/assess.rb
930
+ - lib/contrast/components/base.rb
916
931
  - lib/contrast/components/config.rb
917
932
  - lib/contrast/components/contrast_service.rb
918
933
  - lib/contrast/components/heap_dump.rb
919
- - lib/contrast/components/interface.rb
920
934
  - lib/contrast/components/inventory.rb
921
935
  - lib/contrast/components/logger.rb
922
936
  - lib/contrast/components/protect.rb
@@ -943,7 +957,6 @@ files:
943
957
  - lib/contrast/config/server_configuration.rb
944
958
  - lib/contrast/config/service_configuration.rb
945
959
  - lib/contrast/configuration.rb
946
- - lib/contrast/delegators/input_analysis.rb
947
960
  - lib/contrast/extension/assess.rb
948
961
  - lib/contrast/extension/assess/array.rb
949
962
  - lib/contrast/extension/assess/erb.rb
@@ -973,6 +986,7 @@ files:
973
986
  - lib/contrast/framework/rails/patch/assess_configuration.rb
974
987
  - lib/contrast/framework/rails/patch/rails_application_configuration.rb
975
988
  - lib/contrast/framework/rails/patch/support.rb
989
+ - lib/contrast/framework/rails/railtie.rb
976
990
  - lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
977
991
  - lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb
978
992
  - lib/contrast/framework/rails/rewrite/active_record_named.rb
@@ -1021,6 +1035,7 @@ files:
1021
1035
  - service_executables/linux/contrast-service
1022
1036
  - service_executables/mac/contrast-service
1023
1037
  - shared_libraries/.gitkeep
1038
+ - sonar-project.properties
1024
1039
  homepage: https://www.contrastsecurity.com
1025
1040
  licenses:
1026
1041
  - CONTRAST SECURITY (see license file)
@@ -1,31 +0,0 @@
1
- # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- require 'contrast/utils/job_servers_running'
5
-
6
- module Contrast
7
- module Agent
8
- # A Railtie to allow for the automatic hooking of the Agent into a Rails
9
- # application.
10
- class Railtie < Rails::Railtie
11
- include Contrast::Components::Interface
12
- access_component :agent, :app_context, :logging
13
-
14
- initializer 'Contrast Ruby Agent Initializer' do |app|
15
- Rails.logger.debug("In railtie ::#{ app.middleware.inspect }") if defined?(Rails) && defined?(Rails.logger)
16
-
17
- if APP_CONTEXT.instrument_middleware_stack?
18
- AGENT.insert_middleware(app)
19
- else
20
- Rails.logger.debug('Detected a running job server, skipping Contrast middleware insertion.')
21
- logger.debug('Disabling Contrast for process', p_id: Process.pid)
22
- end
23
- end
24
-
25
- rake_tasks do
26
- load 'contrast/tasks/service.rb'
27
- load 'contrast/tasks/config.rb'
28
- end
29
- end
30
- end
31
- end
@@ -1,195 +0,0 @@
1
- # Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- require 'delegate'
5
- require 'contrast/extension/module'
6
- require 'contrast/utils/object_share'
7
-
8
- module Contrast
9
- # This is the base module for our components classes. It is intended to
10
- # facilitate the translation of the Common Configuration settings to usable
11
- # Ruby methods. Any class under this namespace should be required here,
12
- # providing a single point of require for this functionality.
13
- module Components
14
- # Include this into your classes and modules,
15
- # and use 'access_component' to define constants that will allow
16
- # interaction with other components.
17
- module Interface
18
- def self.included klass
19
- # Upon inclusion, ComponentInterfaces extends the including with
20
- # these two interfaces.
21
- # Interface provides a class-level method 'access_component'
22
- # that regulates per-class access to agent state.
23
- # (It's a glorified `include MyComponent`).
24
- klass.extend Contrast::Components::ComponentReceiverClassInterface
25
- end
26
- end
27
-
28
- # All component access is gated through delegators.
29
- #
30
- # One delegator is used by the calling class,
31
- # so we can tweak outgoing calls.
32
- #
33
- # The second delegator is used by the receiving component,
34
- # so we can tweak incoming calls.
35
- #
36
- # We use __setobj__ to decide which component implementation to use.
37
- # This is intended to provide flexibility in design and
38
- # simplicity in testing.
39
- class ComponentDelegator < SimpleDelegator
40
- # intentionally left blank
41
- end
42
-
43
- # All components should inherit from this,
44
- # whether Interfaces, InstanceMethods or ClassMethods.
45
- module ComponentBase
46
- def self.included klass
47
- klass.extend Methods
48
- klass.include Methods
49
- end
50
-
51
- module Methods # :nodoc:
52
- # use this to determine if the configuration value is literally boolean
53
- # false or some form of the word `false`, regardless of case. It should
54
- # be used for those values which default to `true` as they should only
55
- # treat a value explicitly set to `false` as such.
56
- #
57
- # @param config_param [Boolean,String] the value to check
58
- # @return [Boolean] should the value be treated as `false`
59
- def false? config_param
60
- return false if config_param == true
61
- return true if config_param == false
62
- return false unless config_param.cs__is_a?(String)
63
-
64
- Contrast::Utils::ObjectShare::FALSE.casecmp?(config_param)
65
- end
66
-
67
- # use this to determine if the configuration value is literally boolean
68
- # true or some form of the word `true`, regardless of case. It should
69
- # be used for those values which default to `false` as they should only
70
- # treat a value explicitly set to `true` as such.
71
- #
72
- # @param config_param [Boolean,String] the value to check
73
- # @return [Boolean] should the value be treated as `true`
74
- def true? config_param
75
- return false if config_param == false
76
- return true if config_param == true
77
- return false unless config_param.cs__is_a?(String)
78
-
79
- Contrast::Utils::ObjectShare::TRUE.casecmp?(config_param)
80
- end
81
- end
82
- end
83
-
84
- def self.component_const_name mod_name
85
- mod_name = mod_name.split('::').last
86
- @cache ||= {}
87
- @cache[mod_name] ||= mod_name. # CamelCaseName
88
- split(/(?=[A-Z])/)&. # ['Camel', 'Case', 'Name']
89
- map(&:upcase)&. # ['CAMEL', 'CASE', 'NAME']
90
- join('_') # 'CAMEL_CASE_NAME'
91
- end
92
-
93
- # Interface to allow for iteration over each of the configuration
94
- # components
95
- module ComponentReceiverClassInterface
96
- # Components are manually required at the end of
97
- # this file, and this constant is then frozen.
98
- # RUBY-535 to handle this better.
99
- COMPONENT_MAP = {} # rubocop:disable Style/MutableConstant
100
-
101
- # TODO: RUBY-535
102
- # This module is used via `extend`, so it can't access
103
- # constants we define here.
104
- def component_map
105
- COMPONENT_MAP
106
- end
107
-
108
- # .access_component
109
- #
110
- # to be used as:
111
- #
112
- # class Abc
113
- # include Contrast::Components::Interface
114
- # access_component :logging, :agent
115
- #
116
- # def function
117
- # if AGENT.disabled?
118
- # 0 / 3
119
- # end
120
- # rescue
121
- # logger.error "this function did error"
122
- # end
123
- # end
124
- #
125
- # `:logger` creates a #logger and .logger method
126
- # `:agent` provides an AGENT constant, analogous to a local singleton.
127
- #
128
- def access_component *component_set_syms
129
- @_access_component ||= {}
130
-
131
- component_set_syms.each do |sym|
132
- next if @_access_component[sym]
133
-
134
- if (mods = component_map[sym]) # rubocop:disable Style/GuardClause
135
- # We may support multiple components via one access request.
136
- mods.each do |m|
137
- name = Contrast::Components.component_const_name(m.name)
138
- cs__const_set(name, m::COMPONENT_INTERFACE) if m.cs__const_defined?(:COMPONENT_INTERFACE)
139
- include m::InstanceMethods if m.cs__const_defined?(:InstanceMethods, false)
140
- extend m::ClassMethods if m.cs__const_defined?(:ClassMethods, false)
141
- end
142
-
143
- @_access_component[sym] = true
144
- else
145
- raise NoMethodError, "#{ self } asked to access undefined component '#{ sym }'."
146
- end
147
- end
148
- end
149
- end
150
- end
151
- end
152
-
153
- # Components can depend on other components, but it should be a
154
- # directed acyclic graph.
155
-
156
- # Scope shouldn't depend on anything.
157
- require 'contrast/components/scope'
158
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:scope] = [Contrast::Components::Scope]
159
-
160
- # Config depends on Scope.
161
- require 'contrast/components/config'
162
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:config] = [Contrast::Components::Config]
163
-
164
- # Settings should not depend on anything but Config.
165
- require 'contrast/components/settings'
166
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:settings] = [Contrast::Components::Settings]
167
-
168
- require 'contrast/components/assess'
169
- require 'contrast/components/protect'
170
- require 'contrast/components/inventory'
171
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:analysis] = [
172
- Contrast::Components::Protect,
173
- Contrast::Components::Assess,
174
- Contrast::Components::Inventory
175
- ]
176
-
177
- require 'contrast/components/logger'
178
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:logging] = [Contrast::Components::Logger]
179
-
180
- require 'contrast/components/agent'
181
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:agent] = [Contrast::Components::Agent]
182
-
183
- require 'contrast/components/contrast_service'
184
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:contrast_service] = [Contrast::Components::ContrastService]
185
-
186
- require 'contrast/components/app_context'
187
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:app_context] = [Contrast::Components::AppContext]
188
-
189
- require 'contrast/components/heap_dump'
190
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:heap_dump] = [Contrast::Components::HeapDump]
191
-
192
- require 'contrast/components/sampling'
193
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:sampling] = [Contrast::Components::Sampling]
194
-
195
- Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP.cs__freeze