contrast-agent 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.simplecov +1 -0
  4. data/Rakefile +0 -27
  5. data/lib/contrast/agent/assess/policy/propagation_method.rb +0 -2
  6. data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
  7. data/lib/contrast/agent/version.rb +1 -1
  8. data/lib/contrast/api/dtm.pb.rb +1 -1
  9. data/lib/contrast/api/settings.pb.rb +1 -1
  10. data/lib/contrast/utils/patching/policy/patch_utils.rb +5 -22
  11. data/lib/contrast.rb +34 -0
  12. data/lib/protobuf/code_generator.rb +129 -0
  13. data/lib/protobuf/decoder.rb +28 -0
  14. data/lib/protobuf/deprecation.rb +117 -0
  15. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +79 -0
  16. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +360 -0
  17. data/lib/protobuf/descriptors.rb +3 -0
  18. data/lib/protobuf/encoder.rb +11 -0
  19. data/lib/protobuf/enum.rb +365 -0
  20. data/lib/protobuf/exceptions.rb +9 -0
  21. data/lib/protobuf/field/base_field.rb +380 -0
  22. data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
  23. data/lib/protobuf/field/bool_field.rb +64 -0
  24. data/lib/protobuf/field/bytes_field.rb +67 -0
  25. data/lib/protobuf/field/double_field.rb +25 -0
  26. data/lib/protobuf/field/enum_field.rb +56 -0
  27. data/lib/protobuf/field/field_array.rb +102 -0
  28. data/lib/protobuf/field/field_hash.rb +122 -0
  29. data/lib/protobuf/field/fixed32_field.rb +25 -0
  30. data/lib/protobuf/field/fixed64_field.rb +28 -0
  31. data/lib/protobuf/field/float_field.rb +43 -0
  32. data/lib/protobuf/field/int32_field.rb +21 -0
  33. data/lib/protobuf/field/int64_field.rb +34 -0
  34. data/lib/protobuf/field/integer_field.rb +23 -0
  35. data/lib/protobuf/field/message_field.rb +51 -0
  36. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  37. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  38. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  39. data/lib/protobuf/field/sint32_field.rb +21 -0
  40. data/lib/protobuf/field/sint64_field.rb +21 -0
  41. data/lib/protobuf/field/string_field.rb +51 -0
  42. data/lib/protobuf/field/uint32_field.rb +21 -0
  43. data/lib/protobuf/field/uint64_field.rb +21 -0
  44. data/lib/protobuf/field/varint_field.rb +77 -0
  45. data/lib/protobuf/field.rb +74 -0
  46. data/lib/protobuf/generators/base.rb +85 -0
  47. data/lib/protobuf/generators/enum_generator.rb +39 -0
  48. data/lib/protobuf/generators/extension_generator.rb +27 -0
  49. data/lib/protobuf/generators/field_generator.rb +193 -0
  50. data/lib/protobuf/generators/file_generator.rb +262 -0
  51. data/lib/protobuf/generators/group_generator.rb +122 -0
  52. data/lib/protobuf/generators/message_generator.rb +104 -0
  53. data/lib/protobuf/generators/option_generator.rb +17 -0
  54. data/lib/protobuf/generators/printable.rb +160 -0
  55. data/lib/protobuf/generators/service_generator.rb +50 -0
  56. data/lib/protobuf/lifecycle.rb +33 -0
  57. data/lib/protobuf/logging.rb +39 -0
  58. data/lib/protobuf/message/fields.rb +233 -0
  59. data/lib/protobuf/message/serialization.rb +85 -0
  60. data/lib/protobuf/message.rb +241 -0
  61. data/lib/protobuf/optionable.rb +72 -0
  62. data/lib/protobuf/tasks/compile.rake +80 -0
  63. data/lib/protobuf/tasks.rb +1 -0
  64. data/lib/protobuf/varint.rb +20 -0
  65. data/lib/protobuf/varint_pure.rb +31 -0
  66. data/lib/protobuf/version.rb +3 -0
  67. data/lib/protobuf/wire_type.rb +10 -0
  68. data/lib/protobuf.rb +91 -0
  69. data/proto/dynamic_discovery.proto +46 -0
  70. data/proto/google/protobuf/compiler/plugin.proto +183 -0
  71. data/proto/google/protobuf/descriptor.proto +911 -0
  72. data/proto/rpc.proto +71 -0
  73. data/ruby-agent.gemspec +1 -1
  74. metadata +71 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b7fbfe09d8f01268274ec60a3861fc4377278e0e33aafadd29a13aec59348bb
4
- data.tar.gz: caf12a68dca338f4e1ed0e04483857cd7c55140d8698f1aa55b82c6f85d210c6
3
+ metadata.gz: d74206aa94d644cbe7c47523a69efdb9c0f27d59604125287fd98b123f0d20d6
4
+ data.tar.gz: d4c28074b8d3f11e968d9c3875bfd16d3de41bdd63452bec470cea65a6c83089
5
5
  SHA512:
6
- metadata.gz: cd9eb2d8fd9faf79ad16e0d32889806c93178f696ad64aa58cdc046e46c1cb5e0ff463e54cf81e491518fd732a664f5838147f83c791c869d3689695b1255384
7
- data.tar.gz: '097d53ac525825b0b3b305dafe1be2cc178f7198e057f292561e7ffa4801476dcf151d9a51d6277033dbaf149f6ed0d9b52606aebebeffc7636564eea59bbf74'
6
+ metadata.gz: 3dd36988b29722b7961e919d2685a8cafbf001917f54f5e43107cf51fddb7c105cfea368e04f819f01dc388dd75f5bf739f9bb0c58301784c90bf48188c43bd8
7
+ data.tar.gz: 18a2cbb1e4a4e56d64d3a3821c47ec3aca5709f64673ffb0024b26173de7d1ed4aa8213c851c202c1d30c118d73a4f373b14563d3aa3d9f017ea8caa24ead71d
data/.gitignore CHANGED
@@ -56,8 +56,5 @@ contrast-agent-*.gem
56
56
  .ruby-gemset
57
57
  service_executables/*-*
58
58
 
59
- # Generated Protobuf files
60
- /lib/contrast/api/*.pb.rb
61
-
62
59
  # IDE stuff
63
60
  tags
data/.simplecov CHANGED
@@ -4,5 +4,6 @@
4
4
  SimpleCov.minimum_coverage(line: 94)
5
5
  SimpleCov.start do
6
6
  add_filter '/spec/'
7
+ add_filter '/lib/protobuf/'
7
8
  enable_coverage :branch
8
9
  end
data/Rakefile CHANGED
@@ -17,30 +17,3 @@ Dir['ext/cs__*'].each do |extension|
17
17
  ext.lib_dir = "lib/#{ name }"
18
18
  end
19
19
  end
20
-
21
- desc 'compile the protobuf files for the agent, translating them to .rb classes'
22
- task :contrast_pb_compile do
23
- # do some stuff before compile
24
-
25
- # Invoke the protobuf compile task with your sensible defaults
26
- ::Rake::Task['protobuf:compile'].invoke('lib', './agent-service-api/protobuf ./agent-service-api/protobuf/dtm.proto',
27
- 'lib/contrast/api',
28
- nil)
29
-
30
- ::Rake::Task['protobuf:compile'].reenable
31
-
32
- ::Rake::Task['protobuf:compile'].invoke('lib',
33
- './agent-service-api/protobuf ./agent-service-api/protobuf/settings.proto',
34
- 'lib/contrast/api',
35
- nil)
36
-
37
- ['dtm.pb.rb', 'settings.pb.rb'].each do |target_file|
38
- target_path = File.absolute_path(File.join(__dir__, "./lib/contrast/api/#{ target_file }"))
39
- unless File.exist?(target_path)
40
- puts "File not found #{ target_path }"
41
- exit 1
42
- end
43
- end
44
-
45
- puts 'Protobuf copied successfully'
46
- end
@@ -58,8 +58,6 @@ module Contrast
58
58
  # ret [Object] the Return of the invoked method
59
59
  # args [Array<Object>] the Arguments with which the method was invoked
60
60
  # @param block [Block] the Block passed to the original method
61
- # @return [Object, nil] the tracked Return or nil if no changes were made; will replace the return of the
62
- # original function if not nil
63
61
  def apply_propagator propagation_node, preshift, target, propagation_data, block
64
62
  return unless propagation_possible?(propagation_node, target)
65
63
 
@@ -211,7 +211,7 @@ module Contrast
211
211
 
212
212
  build_events(finding, properties.event) if properties.event
213
213
 
214
- # Google::Protobuf::Map doesn't support merge!, so we have to do this long form
214
+ # CSGoogle::Protobuf::Map doesn't support merge!, so we have to do this long form
215
215
  source_props = properties.properties
216
216
  return unless source_props
217
217
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Contrast
5
5
  module Agent
6
- VERSION = '6.3.0'
6
+ VERSION = '6.4.0'
7
7
  end
8
8
  end
@@ -8,7 +8,7 @@ require 'protobuf'
8
8
  module Contrast
9
9
  module Api
10
10
  module Dtm
11
- ::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
11
+ ::Protobuf::Optionable.inject(self) { ::CSGoogle::Protobuf::FileOptions }
12
12
 
13
13
  ##
14
14
  # Message Classes
@@ -8,7 +8,7 @@ require 'protobuf'
8
8
  module Contrast
9
9
  module Api
10
10
  module Settings
11
- ::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
11
+ ::Protobuf::Optionable.inject(self) { ::CSGoogle::Protobuf::FileOptions }
12
12
 
13
13
  ##
14
14
  # Enum Classes
@@ -7,18 +7,6 @@ module Contrast
7
7
  # This module will include all methods for different patch applies from Patch module and some other module
8
8
  # methods from the same place, so we can ease the main module
9
9
  module PatchUtils
10
- # Method to choose which replaced return from the post_patch to actually return.
11
- #
12
- # @param propagated_ret [Object, nil] The replaced return from the propagation patch.
13
- # @param source_ret [Object, nil] The replaced return from the source patch.
14
- # @param ret [Object, nil] The original return of the patched method.
15
- # @return [Object, nil] The thing to return from the post patch.
16
- def handle_return propagated_ret, source_ret, ret
17
- safe_return = propagated_ret || source_ret || ret
18
- safe_return.rewind if Contrast::Utils::IOUtil.should_rewind?(safe_return)
19
- safe_return
20
- end
21
-
22
10
  # Given a module and method, construct an expected name for the alias by which Contrast will reference the
23
11
  # original.
24
12
  #
@@ -123,8 +111,6 @@ module Contrast
123
111
  # @param args [Array<Object>] The arguments passed to the method being invoked.
124
112
  # @param block [Proc] The block passed to the method that was invoked.
125
113
  def apply_assess method_policy, preshift, object, ret, args, block
126
- source_ret = nil
127
- propagated_ret = nil
128
114
  return ret unless method_policy && ::Contrast::ASSESS.enabled?
129
115
 
130
116
  current_context = Contrast::Agent::REQUEST_TRACKER.current
@@ -135,27 +121,24 @@ module Contrast
135
121
  Contrast::Agent::Assess::Policy::TriggerMethod.apply_trigger_rule(trigger_node, object, ret, args)
136
122
  end
137
123
  if method_policy.source_node
138
- # If we were given a frozen return, and it was the target of a source, and we have frozen sources enabled,
139
- # we'll need to replace the return. Note, this is not the default case.
140
- source_ret = Contrast::Agent::Assess::Policy::SourceMethod.apply_source(method_policy, object, ret, args)
124
+ Contrast::Agent::Assess::Policy::SourceMethod.apply_source(method_policy, object, ret, args)
141
125
  end
142
126
  if method_policy.propagation_node
143
- propagated_ret = Contrast::Agent::Assess::Policy::PropagationMethod.apply_propagation(
127
+ Contrast::Agent::Assess::Policy::PropagationMethod.apply_propagation(
144
128
  method_policy,
145
129
  preshift,
146
130
  object,
147
- source_ret || ret,
131
+ ret,
148
132
  args,
149
133
  block)
150
134
  end
151
- handle_return(propagated_ret, source_ret, ret)
152
135
  rescue StandardError => e
153
136
  logger.error('Unable to assess method call.', e)
154
- handle_return(propagated_ret, source_ret, ret)
155
137
  rescue Exception => e # rubocop:disable Lint/RescueException
156
138
  logger.error('Unable to assess method call.', e)
157
- handle_return(propagated_ret, source_ret, ret)
158
139
  raise(e)
140
+ ensure
141
+ ret.rewind if Contrast::Utils::IOUtil.should_rewind?(ret)
159
142
  end
160
143
 
161
144
  # Generic invocation of the Inventory or Protect patch which apply to the given method.
data/lib/contrast.rb CHANGED
@@ -21,6 +21,39 @@ class Object
21
21
  alias_method :cs__singleton_class, :singleton_class
22
22
  end
23
23
 
24
+ # ActiveRecord gives access to the `String#blank?` method, which we've started using. We need to make sure that method
25
+ # actually exists.
26
+ # From https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/object/blank.rb
27
+ class String
28
+ unless cs__respond_to?(:blank?)
29
+
30
+ CS__BLANK_RE = /\A[[:space:]]*\z/.cs__freeze
31
+ # A string is blank if it's empty or contains whitespaces only:
32
+ #
33
+ # ''.blank? # => true
34
+ # ' '.blank? # => true
35
+ # "\t\n\r".blank? # => true
36
+ # ' blah '.blank? # => false
37
+ #
38
+ # Unicode whitespace is supported:
39
+ #
40
+ # "\u00a0".blank? # => true
41
+ #
42
+ # @return [true, false]
43
+ def blank?
44
+ # The regexp that matches blank strings is expensive. For the case of empty
45
+ # strings we can speed up this method (~3.5x) with an empty? call. The
46
+ # penalty for the rest of strings is marginal.
47
+ empty? ||
48
+ begin
49
+ CS__BLANK_RE.match?(self)
50
+ rescue Encoding::CompatibilityError
51
+ false
52
+ end
53
+ end
54
+ end
55
+ end
56
+
24
57
  if RUBY_VERSION >= '3.0.0' && RUBY_VERSION < '3.1.0'
25
58
  # This fixes Ruby 3.0 issues with Module#(some instance method) patching by preventing the prepending of
26
59
  # a JSON helper on protobuf load. String.instance_method(:+) is one of the most noticeable.
@@ -50,6 +83,7 @@ require 'contrast/components/settings'
50
83
  require 'contrast/utils/telemetry_hash'
51
84
  require 'contrast/utils/telemetry'
52
85
  require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_event'
86
+ require 'protobuf' # TODO: RUBY-1438
53
87
 
54
88
  module Contrast
55
89
  API = Contrast::Components::Api::Interface.new
@@ -0,0 +1,129 @@
1
+ require 'active_support/core_ext/module/aliasing'
2
+ require 'protobuf/generators/file_generator'
3
+
4
+ module Protobuf
5
+ class CodeGenerator
6
+
7
+ CodeGeneratorFatalError = Class.new(RuntimeError)
8
+
9
+ def self.fatal(message)
10
+ fail CodeGeneratorFatalError, message
11
+ end
12
+
13
+ def self.print_tag_warning_suppress
14
+ STDERR.puts "Suppress tag warning output with PB_NO_TAG_WARNINGS=1."
15
+ def self.print_tag_warning_suppress; end # rubocop:disable Lint/DuplicateMethods, Lint/NestedMethodDefinition
16
+ end
17
+
18
+ def self.warn(message)
19
+ STDERR.puts("[WARN] #{message}")
20
+ end
21
+
22
+ private
23
+
24
+ attr_accessor :request
25
+
26
+ public
27
+
28
+ def initialize(request_bytes)
29
+ @request_bytes = request_bytes
30
+ self.request = ::CSGoogle::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes)
31
+ end
32
+
33
+ def eval_unknown_extensions!
34
+ request.proto_file.each do |file_descriptor|
35
+ ::Protobuf::Generators::FileGenerator.new(file_descriptor).eval_unknown_extensions!
36
+ end
37
+ self.request = ::CSGoogle::Protobuf::Compiler::CodeGeneratorRequest.decode(@request_bytes)
38
+ end
39
+
40
+ def generate_file(file_descriptor)
41
+ ::Protobuf::Generators::FileGenerator.new(file_descriptor).generate_output_file
42
+ end
43
+
44
+ def response_bytes
45
+ generated_files = request.proto_file.map do |file_descriptor|
46
+ generate_file(file_descriptor)
47
+ end
48
+
49
+ ::CSGoogle::Protobuf::Compiler::CodeGeneratorResponse.encode(
50
+ :file => generated_files,
51
+ :supported_features => supported_features,
52
+ )
53
+ end
54
+
55
+ def supported_features
56
+ # The only available feature is proto3 with optional fields.
57
+ # This is backwards compatible with proto2 optional fields.
58
+ ::CSGoogle::Protobuf::Compiler::CodeGeneratorResponse::Feature::FEATURE_PROTO3_OPTIONAL.to_i
59
+ end
60
+
61
+ Protobuf::Field::BaseField.module_eval do
62
+ def define_set_method!
63
+ end
64
+
65
+ def set_without_options(message_instance, bytes)
66
+ return message_instance[name] = decode(bytes) unless repeated?
67
+
68
+ if map?
69
+ hash = message_instance[name]
70
+ entry = decode(bytes)
71
+ # decoded value could be nil for an
72
+ # enum value that is not recognized
73
+ hash[entry.key] = entry.value unless entry.value.nil?
74
+ return hash[entry.key]
75
+ end
76
+
77
+ return message_instance[name] << decode(bytes) unless packed?
78
+
79
+ array = message_instance[name]
80
+ stream = StringIO.new(bytes)
81
+
82
+ if wire_type == ::Protobuf::WireType::VARINT
83
+ array << decode(Varint.decode(stream)) until stream.eof?
84
+ elsif wire_type == ::Protobuf::WireType::FIXED64
85
+ array << decode(stream.read(8)) until stream.eof?
86
+ elsif wire_type == ::Protobuf::WireType::FIXED32
87
+ array << decode(stream.read(4)) until stream.eof?
88
+ end
89
+ end
90
+
91
+ # Sets a MessageField that is known to be an option.
92
+ # We must allow fields to be set one at a time, as option syntax allows us to
93
+ # set each field within the option using a separate "option" line.
94
+ def set_with_options(message_instance, bytes)
95
+ if message_instance[name].is_a?(::Protobuf::Message)
96
+ gp = CSGoogle::Protobuf
97
+ if message_instance.is_a?(gp::EnumOptions) || message_instance.is_a?(gp::EnumValueOptions) ||
98
+ message_instance.is_a?(gp::FieldOptions) || message_instance.is_a?(gp::FileOptions) ||
99
+ message_instance.is_a?(gp::MethodOptions) || message_instance.is_a?(gp::ServiceOptions) ||
100
+ message_instance.is_a?(gp::MessageOptions)
101
+
102
+ original_field = message_instance[name]
103
+ decoded_field = decode(bytes)
104
+ decoded_field.each_field do |subfield, subvalue|
105
+ option_set(original_field, subfield, subvalue) { decoded_field.field?(subfield.tag) }
106
+ end
107
+ return
108
+ end
109
+ end
110
+
111
+ set_without_options(message_instance, bytes)
112
+ end
113
+ alias_method :set, :set_with_options
114
+
115
+ def option_set(message_field, subfield, subvalue)
116
+ return unless yield
117
+ if subfield.repeated?
118
+ message_field[subfield.tag].concat(subvalue)
119
+ elsif message_field[subfield.tag] && subvalue.is_a?(::Protobuf::Message)
120
+ subvalue.each_field do |f, v|
121
+ option_set(message_field[subfield.tag], f, v) { subvalue.field?(f.tag) }
122
+ end
123
+ else
124
+ message_field[subfield.tag] = subvalue
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,28 @@
1
+ module Protobuf
2
+ class Decoder
3
+
4
+ # Read bytes from +stream+ and pass to +message+ object.
5
+ def self.decode_each_field(stream)
6
+ until stream.eof?
7
+ bits = Varint.decode(stream)
8
+ wire_type = bits & 0x07
9
+ tag = bits >> 3
10
+
11
+ bytes = if wire_type == ::Protobuf::WireType::VARINT
12
+ Varint.decode(stream)
13
+ elsif wire_type == ::Protobuf::WireType::LENGTH_DELIMITED
14
+ value_length = Varint.decode(stream)
15
+ stream.read(value_length)
16
+ elsif wire_type == ::Protobuf::WireType::FIXED64
17
+ stream.read(8)
18
+ elsif wire_type == ::Protobuf::WireType::FIXED32
19
+ stream.read(4)
20
+ else
21
+ fail InvalidWireType, wire_type
22
+ end
23
+
24
+ yield(tag, bytes)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,117 @@
1
+ require 'active_support/deprecation'
2
+
3
+ module Protobuf
4
+ if ::ActiveSupport::Deprecation.is_a?(Class)
5
+ class DeprecationBase < ::ActiveSupport::Deprecation
6
+ def deprecate_methods(*args)
7
+ deprecation_options = { :deprecator => self }
8
+
9
+ if args.last.is_a?(Hash)
10
+ args.last.merge!(deprecation_options)
11
+ else
12
+ args.push(deprecation_options)
13
+ end
14
+
15
+ super
16
+ end
17
+
18
+ def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil)
19
+ # This ensures ActiveSupport::Deprecation doesn't look for the caller, which is very costly.
20
+ super(deprecated_method_name, message, caller_backtrace) unless ENV.key?('PB_IGNORE_DEPRECATIONS')
21
+ end
22
+ end
23
+
24
+ class Deprecation < DeprecationBase
25
+ def define_deprecated_methods(target_module, method_hash)
26
+ target_module.module_eval do
27
+ method_hash.each do |old_method, new_method|
28
+ alias_method old_method, new_method
29
+ end
30
+ end
31
+
32
+ deprecate_methods(target_module, method_hash)
33
+ end
34
+ end
35
+
36
+ class FieldDeprecation < DeprecationBase
37
+ # this is a convenience deprecator for deprecated proto fields
38
+
39
+ def deprecate_method(target_module, method_name)
40
+ deprecate_methods(target_module, method_name => target_module)
41
+ end
42
+
43
+ private
44
+
45
+ def deprecated_method_warning(method_name, target_module)
46
+ "#{target_module.name}##{method_name} field usage is deprecated"
47
+ end
48
+ end
49
+ else
50
+ # TODO: remove this clause when Rails < 4 support is no longer needed
51
+ deprecator = ::ActiveSupport::Deprecation.clone
52
+ deprecator.instance_eval do
53
+ def new(deprecation_horizon = nil, *)
54
+ self.deprecation_horizon = deprecation_horizon if deprecation_horizon
55
+ self
56
+ end
57
+ end
58
+ Deprecation = deprecator.clone
59
+ FieldDeprecation = deprecator.clone
60
+
61
+ Deprecation.instance_eval do
62
+ def define_deprecated_methods(target_module, method_hash)
63
+ target_module.module_eval do
64
+ method_hash.each do |old_method, new_method|
65
+ alias_method old_method, new_method
66
+ end
67
+ end
68
+
69
+ deprecate_methods(target_module, method_hash)
70
+ end
71
+ end
72
+
73
+ FieldDeprecation.instance_eval do
74
+ def deprecate_method(target_module, method_name)
75
+ deprecate_methods(target_module, method_name => target_module)
76
+ end
77
+
78
+ private
79
+
80
+ def deprecated_method_warning(method_name, target_module)
81
+ "#{target_module.name}##{method_name} field usage is deprecated"
82
+ end
83
+ end
84
+ end
85
+
86
+ def self.deprecator
87
+ @deprecator ||= Deprecation.new('4.0', to_s).tap do |deprecation|
88
+ deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
89
+ deprecation.behavior = :stderr
90
+ end
91
+ end
92
+
93
+ def self.field_deprecator
94
+ @field_deprecator ||= FieldDeprecation.new.tap do |deprecation|
95
+ deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
96
+ deprecation.behavior = :stderr
97
+ end
98
+ end
99
+
100
+ # Print Deprecation Warnings
101
+ #
102
+ # Default: true
103
+ #
104
+ # Simple boolean to define whether we want field deprecation warnings to
105
+ # be printed to stderr or not. The rpc_server has an option to set this value
106
+ # explicitly, or you can turn this option off by setting
107
+ # ENV['PB_IGNORE_DEPRECATIONS'] to a non-empty value.
108
+ #
109
+ # The rpc_server option will override the ENV setting.
110
+ def self.print_deprecation_warnings?
111
+ !field_deprecator.silenced
112
+ end
113
+
114
+ def self.print_deprecation_warnings=(value)
115
+ field_deprecator.silenced = !value
116
+ end
117
+ end
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'google/protobuf/descriptor.pb'
13
+
14
+ module CSGoogle
15
+ module Protobuf
16
+ module Compiler
17
+ ::Protobuf::Optionable.inject(self) { ::CSGoogle::Protobuf::FileOptions }
18
+
19
+ ##
20
+ # Message Classes
21
+ #
22
+ class Version < ::Protobuf::Message; end
23
+ class CodeGeneratorRequest < ::Protobuf::Message; end
24
+ class CodeGeneratorResponse < ::Protobuf::Message
25
+ class Feature < ::Protobuf::Enum
26
+ define :FEATURE_NONE, 0
27
+ define :FEATURE_PROTO3_OPTIONAL, 1
28
+ end
29
+
30
+ class File < ::Protobuf::Message; end
31
+
32
+ end
33
+
34
+
35
+
36
+ ##
37
+ # File Options
38
+ #
39
+ set_option :java_package, "com.google.protobuf.compiler"
40
+ set_option :java_outer_classname, "PluginProtos"
41
+ set_option :go_package, "google.golang.org/protobuf/types/pluginpb"
42
+
43
+
44
+ ##
45
+ # Message Fields
46
+ #
47
+ class Version
48
+ optional :int32, :major, 1
49
+ optional :int32, :minor, 2
50
+ optional :int32, :patch, 3
51
+ optional :string, :suffix, 4
52
+ end
53
+
54
+ class CodeGeneratorRequest
55
+ repeated :string, :file_to_generate, 1
56
+ optional :string, :parameter, 2
57
+ repeated ::CSGoogle::Protobuf::FileDescriptorProto, :proto_file, 15
58
+ optional ::CSGoogle::Protobuf::Compiler::Version, :compiler_version, 3
59
+ end
60
+
61
+ class CodeGeneratorResponse
62
+ class File
63
+ optional :string, :name, 1
64
+ optional :string, :insertion_point, 2
65
+ optional :string, :content, 15
66
+ optional ::CSGoogle::Protobuf::GeneratedCodeInfo, :generated_code_info, 16
67
+ end
68
+
69
+ optional :string, :error, 1
70
+ optional :uint64, :supported_features, 2
71
+ repeated ::CSGoogle::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+