newrelic_rpm 3.9.1.236 → 3.9.2.239

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data.tar.gz.sig +2 -4
  2. data/CHANGELOG +96 -2
  3. data/lib/new_relic/agent.rb +47 -4
  4. data/lib/new_relic/agent/agent.rb +51 -26
  5. data/lib/new_relic/agent/agent_logger.rb +4 -0
  6. data/lib/new_relic/agent/configuration.rb +2 -32
  7. data/lib/new_relic/agent/configuration/default_source.rb +153 -118
  8. data/lib/new_relic/agent/configuration/dotted_hash.rb +52 -0
  9. data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
  10. data/lib/new_relic/agent/configuration/manager.rb +101 -2
  11. data/lib/new_relic/agent/configuration/manual_source.rb +17 -0
  12. data/lib/new_relic/agent/configuration/server_source.rb +12 -4
  13. data/lib/new_relic/agent/configuration/yaml_source.rb +46 -22
  14. data/lib/new_relic/agent/cross_app_monitor.rb +1 -1
  15. data/lib/new_relic/agent/cross_app_tracing.rb +1 -1
  16. data/lib/new_relic/agent/database/obfuscation_helpers.rb +55 -14
  17. data/lib/new_relic/agent/database/obfuscator.rb +22 -7
  18. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +6 -8
  19. data/lib/new_relic/agent/error_collector.rb +24 -16
  20. data/lib/new_relic/agent/event_loop.rb +189 -0
  21. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +8 -17
  22. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
  24. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -16
  25. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +41 -0
  26. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -11
  27. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
  28. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -8
  29. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -9
  30. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -18
  31. data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
  33. data/lib/new_relic/agent/instrumentation/sinatra.rb +12 -1
  34. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
  35. data/lib/new_relic/agent/method_tracer.rb +33 -39
  36. data/lib/new_relic/agent/new_relic_service.rb +35 -156
  37. data/lib/new_relic/agent/new_relic_service/encoders.rb +34 -0
  38. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +50 -0
  39. data/lib/new_relic/agent/new_relic_service/marshaller.rb +52 -0
  40. data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +52 -0
  41. data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
  42. data/lib/new_relic/agent/traced_method_stack.rb +16 -2
  43. data/lib/new_relic/agent/transaction.rb +0 -4
  44. data/lib/new_relic/collection_helper.rb +2 -2
  45. data/lib/new_relic/control/frameworks/rails.rb +3 -0
  46. data/lib/new_relic/control/instrumentation.rb +6 -2
  47. data/lib/new_relic/json_wrapper.rb +47 -25
  48. data/lib/new_relic/language_support.rb +0 -4
  49. data/lib/new_relic/latest_changes.rb +2 -2
  50. data/lib/new_relic/rack/developer_mode.rb +4 -3
  51. data/lib/new_relic/recipes/capistrano3.rb +2 -2
  52. data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
  53. data/lib/new_relic/timer_lib.rb +1 -1
  54. data/lib/new_relic/version.rb +2 -2
  55. data/lib/tasks/config.html.erb +28 -0
  56. data/lib/tasks/config.rake +134 -0
  57. data/lib/tasks/config.text.erb +7 -0
  58. data/lib/tasks/install.rake +0 -63
  59. data/newrelic.yml +7 -0
  60. data/test/active_record_fixtures.rb +4 -4
  61. data/test/agent_helper.rb +58 -18
  62. data/test/environments/lib/environments/runner.rb +1 -1
  63. data/test/environments/rails21/Gemfile +1 -1
  64. data/test/environments/rails21/config/boot.rb +1 -1
  65. data/test/environments/rails22/Gemfile +1 -1
  66. data/test/environments/rails22/config/boot.rb +1 -1
  67. data/test/environments/rails23/config/boot.rb +2 -2
  68. data/test/environments/rails30/Gemfile +1 -1
  69. data/test/environments/rails31/Gemfile +1 -1
  70. data/test/environments/rails32/Gemfile +1 -1
  71. data/test/environments/rails40/Gemfile +1 -1
  72. data/test/environments/rails41/Gemfile +1 -1
  73. data/test/fixtures/cross_agent_tests/labels.json +104 -0
  74. data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +23 -0
  75. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +1 -0
  76. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +1 -0
  77. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +1 -0
  78. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +1 -0
  79. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +1 -0
  80. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +1 -0
  81. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +2 -0
  82. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +2 -0
  83. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.obfuscated +1 -0
  84. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.sql +2 -0
  85. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +1 -0
  86. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +1 -0
  87. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +2 -0
  88. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +2 -0
  89. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +1 -0
  90. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +1 -0
  91. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +1 -0
  92. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +4 -0
  93. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +1 -0
  94. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +1 -0
  95. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.obfuscated +1 -0
  96. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.sql +2 -0
  97. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.obfuscated +1 -0
  98. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.sql +4 -0
  99. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.obfuscated +1 -0
  100. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.sql +3 -0
  101. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +1 -0
  102. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +1 -0
  103. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +1 -0
  104. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +1 -0
  105. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +1 -0
  106. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +1 -0
  107. data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.obfuscated +1 -0
  108. data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.sql +1 -0
  109. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +1 -0
  110. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +1 -0
  111. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +1 -0
  112. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +1 -0
  113. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +1 -0
  114. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +4 -0
  115. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +1 -0
  116. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +1 -0
  117. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +1 -0
  118. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +2 -0
  119. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +1 -0
  120. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +1 -0
  121. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +1 -0
  122. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +1 -0
  123. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +1 -0
  124. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +4 -0
  125. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +1 -0
  126. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +1 -0
  127. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +1 -0
  128. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +1 -0
  129. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +1 -0
  130. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +1 -0
  131. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +1 -0
  132. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +1 -0
  133. data/test/multiverse/lib/multiverse/output_collector.rb +1 -1
  134. data/test/multiverse/lib/multiverse/runner.rb +1 -1
  135. data/test/multiverse/lib/multiverse/suite.rb +19 -4
  136. data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -38
  137. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +25 -35
  138. data/test/multiverse/suites/agent_only/config/newrelic.yml +2 -0
  139. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -0
  140. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
  141. data/test/multiverse/suites/agent_only/keepalive_test.rb +29 -0
  142. data/test/multiverse/suites/agent_only/labels_test.rb +89 -0
  143. data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -3
  144. data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
  145. data/test/multiverse/suites/agent_only/start_up_test.rb +9 -1
  146. data/test/multiverse/suites/capistrano/config/deploy.rb +6 -2
  147. data/test/multiverse/suites/capistrano/deployment_test.rb +12 -4
  148. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +29 -1
  149. data/test/multiverse/suites/curb/Envfile +6 -2
  150. data/test/multiverse/suites/datamapper/Envfile +0 -4
  151. data/test/multiverse/suites/deferred_instrumentation/Envfile +0 -4
  152. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
  153. data/test/multiverse/suites/excon/Envfile +5 -4
  154. data/test/multiverse/suites/excon/excon_test.rb +1 -1
  155. data/test/multiverse/suites/httpclient/Envfile +0 -4
  156. data/test/multiverse/suites/marshalling/Envfile +12 -0
  157. data/test/multiverse/suites/marshalling/config/newrelic.yml +20 -0
  158. data/test/multiverse/suites/marshalling/marshalling_test.rb +60 -0
  159. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +1 -1
  160. data/test/multiverse/suites/mongo/helpers/mongo_replica_set.rb +1 -1
  161. data/test/multiverse/suites/mongo/helpers/mongo_server.rb +4 -4
  162. data/test/multiverse/suites/padrino/Envfile +0 -5
  163. data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
  164. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +1 -1
  165. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +2 -1
  166. data/test/multiverse/suites/rails/ignore_test.rb +22 -0
  167. data/test/multiverse/suites/rails/rails2_app/config/boot.rb +2 -2
  168. data/test/multiverse/suites/rails/rails2_app/config/routes.rb +1 -0
  169. data/test/multiverse/suites/resque/Envfile +0 -4
  170. data/test/multiverse/suites/sequel/Envfile +0 -5
  171. data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
  172. data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
  173. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +22 -0
  174. data/test/multiverse/suites/typhoeus/Envfile +1 -4
  175. data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -13
  176. data/test/new_relic/agent/agent_logger_test.rb +11 -0
  177. data/test/new_relic/agent/agent_test.rb +43 -20
  178. data/test/new_relic/agent/audit_logger_test.rb +7 -3
  179. data/test/new_relic/agent/commands/thread_profiler_session_test.rb +0 -1
  180. data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
  181. data/test/new_relic/agent/configuration/dotted_hash_test.rb +53 -0
  182. data/test/new_relic/agent/configuration/manager_test.rb +99 -6
  183. data/test/new_relic/agent/configuration/manual_source_test.rb +18 -0
  184. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
  185. data/test/new_relic/agent/configuration/yaml_source_test.rb +8 -4
  186. data/test/new_relic/agent/database/sql_obfuscation_test.rb +76 -0
  187. data/test/new_relic/agent/database_test.rb +2 -38
  188. data/test/new_relic/agent/error_collector/notice_error_test.rb +21 -3
  189. data/test/new_relic/agent/error_collector_test.rb +15 -2
  190. data/test/new_relic/agent/event_loop_test.rb +202 -0
  191. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -0
  192. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +283 -182
  193. data/test/new_relic/agent/method_tracer_test.rb +1 -2
  194. data/test/new_relic/agent/new_relic_service_test.rb +83 -27
  195. data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -6
  196. data/test/new_relic/agent/rpm_agent_test.rb +1 -8
  197. data/test/new_relic/agent/sql_sampler_test.rb +10 -8
  198. data/test/new_relic/agent/threading/backtrace_service_test.rb +1 -1
  199. data/test/new_relic/agent/traced_method_stack_test.rb +45 -13
  200. data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -2
  201. data/test/new_relic/agent/transaction_test.rb +3 -3
  202. data/test/new_relic/agent_test.rb +47 -8
  203. data/test/new_relic/collection_helper_test.rb +5 -5
  204. data/test/new_relic/control/instrumentation_test.rb +56 -0
  205. data/test/new_relic/control_test.rb +4 -3
  206. data/test/new_relic/fake_collector.rb +7 -2
  207. data/test/new_relic/http_client_test_cases.rb +4 -4
  208. data/test/new_relic/latest_changes_test.rb +3 -3
  209. data/test/new_relic/transaction_sample/segment_test.rb +0 -1
  210. data/test/new_relic/transaction_sample_test.rb +19 -2
  211. data/test/performance/lib/performance/runner.rb +4 -4
  212. data/test/performance/suites/marshalling.rb +46 -30
  213. data/test/performance/suites/sql_obfuscation.rb +30 -0
  214. data/test/test_helper.rb +1 -1
  215. data/ui/helpers/developer_mode_helper.rb +2 -2
  216. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +1 -1
  217. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
  218. metadata +84 -3
  219. metadata.gz.sig +0 -0
  220. data/test/environments/rails23/config/environments/development.rb +0 -11
@@ -110,7 +110,7 @@ module Environments
110
110
  return if File.basename(dir) == "norails"
111
111
 
112
112
  puts "Making sure the database is there for '#{File.basename(dir)}'..."
113
- result = `cd #{dir} && RAILS_ENV=test bundle exec rake --trace db:create`
113
+ `cd #{dir} && RAILS_ENV=test bundle exec rake --trace db:create`
114
114
  end
115
115
 
116
116
  def run(dir)
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem "rails", "~>2.1.2"
4
4
 
@@ -64,7 +64,7 @@ module Rails
64
64
  else
65
65
  gem 'rails'
66
66
  end
67
- rescue Gem::LoadError => load_error
67
+ rescue Gem::LoadError
68
68
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
69
  exit 1
70
70
  end
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem "rails", "~>2.2.3"
4
4
 
@@ -64,7 +64,7 @@ module Rails
64
64
  else
65
65
  gem 'rails'
66
66
  end
67
- rescue Gem::LoadError => load_error
67
+ rescue Gem::LoadError
68
68
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
69
  exit 1
70
70
  end
@@ -64,7 +64,7 @@ module Rails
64
64
  else
65
65
  gem 'rails'
66
66
  end
67
- rescue Gem::LoadError => load_error
67
+ rescue Gem::LoadError
68
68
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
69
  exit 1
70
70
  end
@@ -121,7 +121,7 @@ class Rails::Boot
121
121
 
122
122
  Rails::Initializer.run(:set_load_path)
123
123
  end
124
- end
124
+ end
125
125
 
126
126
  # All that for this:
127
127
  Rails.boot!
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~>3.0.20'
4
4
 
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~>3.1.12'
4
4
 
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~>3.2.15'
4
4
 
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
@@ -0,0 +1,104 @@
1
+ [
2
+ {
3
+ "name": "empty",
4
+ "labelString": "",
5
+ "warning": false,
6
+ "expected": []
7
+ },
8
+ {
9
+ "name": "multiple_values",
10
+ "labelString": "Data Center: East;Data Center :West; Server : North;Server:South; ",
11
+ "warning": false,
12
+ "expected": [
13
+ { "label_type": "Data Center", "label_value": "East" },
14
+ { "label_type": "Data Center", "label_value": "West" },
15
+ { "label_type": "Server", "label_value": "North" },
16
+ { "label_type": "Server", "label_value": "South" }
17
+ ]
18
+ },
19
+ {
20
+ "name": "single",
21
+ "labelString": "Server:East",
22
+ "warning": false,
23
+ "expected": [ { "label_type": "Server", "label_value": "East" } ]
24
+ },
25
+ {
26
+ "name": "single_trailing_semicolon",
27
+ "labelString": "Server:East;",
28
+ "warning": false,
29
+ "expected": [ { "label_type": "Server", "label_value": "East" } ]
30
+ },
31
+ {
32
+ "name": "pair",
33
+ "labelString": "Data Center:Primary;Server:East",
34
+ "warning": false,
35
+ "expected": [
36
+ { "label_type": "Data Center", "label_value": "Primary" },
37
+ { "label_type": "Server", "label_value": "East" }
38
+ ]
39
+ },
40
+ {
41
+ "name": "truncation",
42
+ "labelString": "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK:VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
43
+ "warning": false,
44
+ "expected": [ {
45
+ "label_type": "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK",
46
+ "label_value": "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
47
+ } ]
48
+ },
49
+ {
50
+ "name": "failed_no_delimiters",
51
+ "labelString": "Server",
52
+ "warning": true,
53
+ "expected": []
54
+ },
55
+ {
56
+ "name": "failed_no_delimiter",
57
+ "labelString": "ServerNorth;",
58
+ "warning": true,
59
+ "expected": []
60
+ },
61
+ {
62
+ "name": "failed_too_many_delimiters",
63
+ "labelString": "Server:North:South;",
64
+ "warning": true,
65
+ "expected": []
66
+ },
67
+ {
68
+ "name": "failed_no_value",
69
+ "labelString": "Server: ",
70
+ "warning": true,
71
+ "expected": []
72
+ },
73
+ {
74
+ "name": "failed_no_key",
75
+ "labelString": ":North",
76
+ "warning": true,
77
+ "expected": []
78
+ },
79
+ {
80
+ "name": "failed_no_delimiter_in_later_pair",
81
+ "labelString": "Server:North;South;",
82
+ "warning": true,
83
+ "expected": []
84
+ },
85
+ {
86
+ "name": "so_many_labels",
87
+ "labelString": "0:0;1:1;2:2;3:3;4:4;5:5;6:6;7:7;8:8;9:9;10:10;11:11;12:12;13:13;14:14;15:15;16:16;17:17;18:18;19:19;20:20;21:21;22:22;23:23;24:24;25:25;26:26;27:27;28:28;29:29;30:30;31:31;32:32;33:33;34:34;35:35;36:36;37:37;38:38;39:39;40:40;41:41;42:42;43:43;44:44;45:45;46:46;47:47;48:48;49:49;50:50;51:51;52:52;53:53;54:54;55:55;56:56;57:57;58:58;59:59;60:60;61:61;62:62;63:63;64:64;65:65;66:66;67:67;68:68;69:69;70:70;71:71;72:72;73:73;74:74;75:75;76:76;77:77;78:78;79:79;80:80;81:81;82:82;83:83;84:84;85:85;86:86;87:87;88:88;89:89;90:90;91:91;92:92;93:93;94:94;95:95;96:96;97:97;98:98;99:99;",
88
+ "warning": true,
89
+ "expected": [
90
+ { "label_type": "0", "label_value": "0" }, { "label_type": "1", "label_value": "1" }, { "label_type": "2", "label_value": "2" }, { "label_type": "3", "label_value": "3" }, { "label_type": "4", "label_value": "4" },
91
+ { "label_type": "5", "label_value": "5" }, { "label_type": "6", "label_value": "6" }, { "label_type": "7", "label_value": "7" }, { "label_type": "8", "label_value": "8" }, { "label_type": "9", "label_value": "9" },
92
+ { "label_type": "10", "label_value": "10" }, { "label_type": "11", "label_value": "11" }, { "label_type": "12", "label_value": "12" }, { "label_type": "13", "label_value": "13" }, { "label_type": "14", "label_value": "14" },
93
+ { "label_type": "15", "label_value": "15" }, { "label_type": "16", "label_value": "16" }, { "label_type": "17", "label_value": "17" }, { "label_type": "18", "label_value": "18" }, { "label_type": "19", "label_value": "19" },
94
+ { "label_type": "20", "label_value": "20" }, { "label_type": "21", "label_value": "21" }, { "label_type": "22", "label_value": "22" }, { "label_type": "23", "label_value": "23" }, { "label_type": "24", "label_value": "24" },
95
+ { "label_type": "25", "label_value": "25" }, { "label_type": "26", "label_value": "26" }, { "label_type": "27", "label_value": "27" }, { "label_type": "28", "label_value": "28" }, { "label_type": "29", "label_value": "29" },
96
+ { "label_type": "30", "label_value": "30" }, { "label_type": "31", "label_value": "31" }, { "label_type": "32", "label_value": "32" }, { "label_type": "33", "label_value": "33" }, { "label_type": "34", "label_value": "34" },
97
+ { "label_type": "35", "label_value": "35" }, { "label_type": "36", "label_value": "36" }, { "label_type": "37", "label_value": "37" }, { "label_type": "38", "label_value": "38" }, { "label_type": "39", "label_value": "39" },
98
+ { "label_type": "40", "label_value": "40" }, { "label_type": "41", "label_value": "41" }, { "label_type": "42", "label_value": "42" }, { "label_type": "43", "label_value": "43" }, { "label_type": "44", "label_value": "44" },
99
+ { "label_type": "45", "label_value": "45" }, { "label_type": "46", "label_value": "46" }, { "label_type": "47", "label_value": "47" }, { "label_type": "48", "label_value": "48" }, { "label_type": "49", "label_value": "49" },
100
+ { "label_type": "50", "label_value": "50" }, { "label_type": "51", "label_value": "51" }, { "label_type": "52", "label_value": "52" }, { "label_type": "53", "label_value": "53" }, { "label_type": "54", "label_value": "54" },
101
+ { "label_type": "55", "label_value": "55" }, { "label_type": "56", "label_value": "56" }, { "label_type": "57", "label_value": "57" }, { "label_type": "58", "label_value": "58" }, { "label_type": "59", "label_value": "59" },
102
+ { "label_type": "60", "label_value": "60" }, { "label_type": "61", "label_value": "61" }, { "label_type": "62", "label_value": "62" }, { "label_type": "63", "label_value": "63" } ]
103
+ }
104
+ ]
@@ -0,0 +1,23 @@
1
+ These test cases cover obfuscation (more properly, masking) of literal values
2
+ from SQL statements captured by agents. SQL statements may be captured and
3
+ attached to transaction trace nodes, or to slow SQL traces.
4
+
5
+ Input queries end with the suffix `.sql`, and the expected obfuscated results
6
+ end with the suffix `.obfuscated`. Input queries may contain comment lines
7
+ explaining notes about the test case. Comment lines will precede the actual
8
+ query, and begin with a `#` symbol.
9
+
10
+ Test cases that have a `.mysql` or `.postgres` tag in the filename preceding the
11
+ `.sql` suffix are specific to either mysql or postgres obfuscation. This is
12
+ relevant because PostgreSQL uses different identifier and string quoting rules
13
+ than MySQL (most notably, double-quoted string literals are not allowed in
14
+ PostgreSQL, where double-quotes are instead used around identifiers).
15
+
16
+ The `malformed` directory contains SQL queries that are not valid SQL in any
17
+ quoting mode. Some agents may choose to attempt to obfuscate these cases, and
18
+ others may instead just replace the query entirely with a placeholder message.
19
+
20
+ The following database documentation may be helpful in understanding these test
21
+ cases:
22
+ * [MySQL String Literals](http://dev.mysql.com/doc/refman/5.5/en/string-literals.html)
23
+ * [PostgreSQL String Constants](http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS)
@@ -0,0 +1 @@
1
+ SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?
@@ -0,0 +1 @@
1
+ SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3="othervalue" LIMIT ?
@@ -0,0 +1 @@
1
+ SELECT * FROM t WHERE foo=? AND baz=?
@@ -0,0 +1 @@
1
+ SELECT * FROM t WHERE foo="bar/*" AND baz="whatever */qux"
@@ -0,0 +1 @@
1
+ SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = ? AND c3=? LIMIT ?
@@ -0,0 +1 @@
1
+ SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = 'value' AND c3=1234 LIMIT 1
@@ -0,0 +1,2 @@
1
+ SELECT * FROM t WHERE foo=? AND
2
+ baz=?
@@ -0,0 +1,2 @@
1
+ SELECT * FROM t WHERE foo="bar--" AND
2
+ baz="qux--"
@@ -0,0 +1,2 @@
1
+ SELECT * FROM t WHERE -- '
2
+ bar='baz' -- '
@@ -0,0 +1 @@
1
+ SELECT * FROM foo WHERE bar='baz' /* Hide Me */
@@ -0,0 +1,2 @@
1
+ SELECT * FROM foobar WHERE password=?
2
+ ?
@@ -0,0 +1,2 @@
1
+ SELECT * FROM foobar WHERE password='hunter2'
2
+ -- No peeking!
@@ -0,0 +1 @@
1
+ SELECT foo, bar FROM baz WHERE password=? ?
@@ -0,0 +1 @@
1
+ SELECT foo, bar FROM baz WHERE password='hunter2' # Secret
@@ -0,0 +1 @@
1
+ SELECT "col1", "col2" from "table" WHERE "col3"=E? AND country=e?
@@ -0,0 +1,4 @@
1
+ # PostgreSQL supports an alternate string quoting mode where backslash escape
2
+ # sequences are interpreted.
3
+ # See: http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
4
+ SELECT "col1", "col2" from "table" WHERE "col3"=E'foo\'bar\\baz' AND country=e'foo\'bar\\baz'
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE foo='bar' AND baz="nothing to see here'
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here
@@ -0,0 +1,2 @@
1
+ SELECT * FROM t WHERE /* ' */
2
+ bar='baz' -- '
@@ -0,0 +1,4 @@
1
+ SELECT * FROM t WHERE -- '
2
+ /* ' */ c2='xxx' /* ' */
3
+ c='x
4
+ xx' -- '
@@ -0,0 +1,3 @@
1
+ SELECT * FROM t WHERE -- '
2
+ c='x
3
+ xx' -- '
@@ -0,0 +1 @@
1
+ INSERT INTO `X` values(?,?, ? , ?, ?)
@@ -0,0 +1 @@
1
+ INSERT INTO `X` values("test",0, 1 , 2, 'test')
@@ -0,0 +1 @@
1
+ SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?
@@ -0,0 +1 @@
1
+ SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'
@@ -0,0 +1 @@
1
+ INSERT INTO X VALUES(?, ?, ?.?, ?+?)
@@ -0,0 +1 @@
1
+ INSERT INTO X VALUES(1, 23456, 123.456, 99+100)
@@ -0,0 +1 @@
1
+ SELECT * FROM foo WHERE col=? AND ?
@@ -0,0 +1 @@
1
+ SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name=? AND value=?
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name="foo" AND value="don't"
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name=? AND value = ?
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name='foo' AND value = 'bar'
@@ -0,0 +1,4 @@
1
+ # If backslashes are being ignored in single-quoted strings
2
+ # (standard_conforming_strings=on in PostgreSQL, or NO_BACKSLASH_ESCAPES is on
3
+ # in MySQL), then this is valid SQL.
4
+ SELECT * FROM table WHERE col='foo\''bar'
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE col1=? AND col2=?
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE col1='foo"bar' AND col2='what"ever'
@@ -0,0 +1 @@
1
+ select * from accounts where accounts.name != ? order by accounts.name
@@ -0,0 +1,2 @@
1
+ select * from accounts where accounts.name != 'dude
2
+ newline' order by accounts.name
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE col1=? AND col2=?
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE col1="don't" AND col2="won't"
@@ -0,0 +1 @@
1
+ INSERT INTO X values(?, ?,?, ? , ?, ?, ?)
@@ -0,0 +1 @@
1
+ INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', """jim''s"" hat", "\"jim''s secret\"")
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name=? AND color=?
@@ -0,0 +1,4 @@
1
+ # If backslashes are being ignored in single-quoted strings
2
+ # (standard_conforming_strings=on in PostgreSQL, or NO_BACKSLASH_ESCAPES is on
3
+ # in MySQL), then this is valid SQL.
4
+ SELECT * FROM table WHERE name='foo\' AND color='blue'
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE foo="this string ends with a backslash\\"
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE foo='this string ends with a backslash\\'
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name=? AND color=?
@@ -0,0 +1 @@
1
+ SELECT * FROM table WHERE name='foo\'' AND color='blue'
@@ -0,0 +1 @@
1
+ INSERT INTO X values(?, ?,?, ? , ?)
@@ -0,0 +1 @@
1
+ INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')