contrast-agent 6.7.0 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.simplecov +0 -1
  4. data/Rakefile +0 -1
  5. data/ext/cs__assess_array/cs__assess_array.c +41 -10
  6. data/ext/cs__assess_array/cs__assess_array.h +4 -1
  7. data/lib/contrast/agent/assess/policy/trigger_method.rb +2 -2
  8. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
  9. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
  10. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
  11. data/lib/contrast/agent/excluder.rb +52 -34
  12. data/lib/contrast/agent/exclusion_matcher.rb +21 -9
  13. data/lib/contrast/agent/middleware.rb +4 -4
  14. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
  15. data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
  16. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
  17. data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
  18. data/lib/contrast/agent/protect/rule/base.rb +45 -53
  19. data/lib/contrast/agent/protect/rule/base_service.rb +48 -24
  20. data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
  21. data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
  22. data/lib/contrast/agent/protect/rule/cmd_injection.rb +18 -1
  23. data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -5
  24. data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +22 -22
  25. data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +69 -0
  26. data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +68 -0
  27. data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
  28. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  29. data/lib/contrast/agent/protect/rule/deserialization.rb +3 -14
  30. data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
  31. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
  32. data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
  33. data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
  34. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
  35. data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
  36. data/lib/contrast/agent/protect/rule/path_traversal.rb +38 -12
  37. data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +33 -15
  38. data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +0 -14
  39. data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
  40. data/lib/contrast/agent/protect/rule/sqli.rb +70 -0
  41. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
  42. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
  43. data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
  44. data/lib/contrast/agent/protect/rule/xss.rb +14 -20
  45. data/lib/contrast/agent/protect/rule/xxe.rb +4 -24
  46. data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +18 -39
  47. data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
  48. data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +10 -2
  49. data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +8 -2
  50. data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
  51. data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
  52. data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
  53. data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +16 -2
  54. data/lib/contrast/agent/reporting/masker/masker.rb +2 -0
  55. data/lib/contrast/agent/reporting/reporter.rb +1 -14
  56. data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +15 -12
  57. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +3 -3
  58. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -2
  59. data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
  60. data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +0 -1
  61. data/lib/contrast/agent/reporting/reporting_events/finding.rb +4 -4
  62. data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +0 -5
  63. data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
  64. data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
  65. data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +0 -1
  66. data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +0 -1
  67. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +2 -2
  68. data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
  69. data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +0 -3
  70. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +1 -0
  71. data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
  72. data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
  73. data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
  74. data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
  75. data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
  76. data/lib/contrast/agent/request.rb +2 -14
  77. data/lib/contrast/agent/request_context.rb +6 -9
  78. data/lib/contrast/agent/request_context_extend.rb +9 -148
  79. data/lib/contrast/agent/thread_watcher.rb +3 -18
  80. data/lib/contrast/agent/version.rb +1 -1
  81. data/lib/contrast/agent.rb +0 -11
  82. data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
  83. data/lib/contrast/agent_lib/api/init.rb +101 -0
  84. data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
  85. data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
  86. data/lib/contrast/agent_lib/api/panic.rb +87 -0
  87. data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
  88. data/lib/contrast/agent_lib/interface.rb +260 -0
  89. data/lib/contrast/agent_lib/interface_base.rb +118 -0
  90. data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
  91. data/lib/contrast/agent_lib/test.rb +29 -0
  92. data/lib/contrast/api/communication/connection_status.rb +5 -5
  93. data/lib/contrast/components/agent.rb +0 -14
  94. data/lib/contrast/components/app_context.rb +0 -2
  95. data/lib/contrast/components/app_context_extend.rb +0 -25
  96. data/lib/contrast/components/config.rb +1 -18
  97. data/lib/contrast/components/protect.rb +4 -1
  98. data/lib/contrast/components/ruby_component.rb +1 -1
  99. data/lib/contrast/components/settings.rb +37 -89
  100. data/lib/contrast/config/protect_rule_configuration.rb +7 -7
  101. data/lib/contrast/config/protect_rules_configuration.rb +20 -58
  102. data/lib/contrast/configuration.rb +1 -10
  103. data/lib/contrast/extension/assess/array.rb +9 -0
  104. data/lib/contrast/extension/delegator.rb +2 -0
  105. data/lib/contrast/framework/manager.rb +3 -1
  106. data/lib/contrast/framework/rails/railtie.rb +0 -1
  107. data/lib/contrast/framework/rails/support.rb +0 -1
  108. data/lib/contrast/tasks/config.rb +1 -8
  109. data/lib/contrast/utils/duck_utils.rb +1 -0
  110. data/lib/contrast/utils/input_classification_base.rb +156 -0
  111. data/lib/contrast/utils/os.rb +0 -20
  112. data/lib/contrast/utils/response_utils.rb +0 -16
  113. data/lib/contrast/utils/stack_trace_utils.rb +3 -15
  114. data/lib/contrast/utils/string_utils.rb +10 -7
  115. data/lib/contrast.rb +2 -3
  116. data/resources/protect/policy.json +1 -2
  117. data/ruby-agent.gemspec +2 -5
  118. metadata +42 -112
  119. data/exe/contrast_service +0 -23
  120. data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
  121. data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
  122. data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
  123. data/lib/contrast/agent/reaction_processor.rb +0 -47
  124. data/lib/contrast/agent/service_heartbeat.rb +0 -35
  125. data/lib/contrast/api/communication/messaging_queue.rb +0 -128
  126. data/lib/contrast/api/communication/response_processor.rb +0 -90
  127. data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
  128. data/lib/contrast/api/communication/socket.rb +0 -44
  129. data/lib/contrast/api/communication/socket_client.rb +0 -130
  130. data/lib/contrast/api/communication/speedracer.rb +0 -138
  131. data/lib/contrast/api/communication/tcp_socket.rb +0 -32
  132. data/lib/contrast/api/communication/unix_socket.rb +0 -28
  133. data/lib/contrast/api/communication.rb +0 -20
  134. data/lib/contrast/api/decorators/address.rb +0 -59
  135. data/lib/contrast/api/decorators/agent_startup.rb +0 -56
  136. data/lib/contrast/api/decorators/application_settings.rb +0 -43
  137. data/lib/contrast/api/decorators/application_startup.rb +0 -56
  138. data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
  139. data/lib/contrast/api/decorators/http_request.rb +0 -137
  140. data/lib/contrast/api/decorators/input_analysis.rb +0 -18
  141. data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
  142. data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
  143. data/lib/contrast/api/decorators/message.rb +0 -67
  144. data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -52
  145. data/lib/contrast/api/decorators/response_type.rb +0 -17
  146. data/lib/contrast/api/decorators/server_features.rb +0 -25
  147. data/lib/contrast/api/decorators/user_input.rb +0 -51
  148. data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
  149. data/lib/contrast/api/decorators.rb +0 -22
  150. data/lib/contrast/api/dtm.pb.rb +0 -363
  151. data/lib/contrast/api/settings.pb.rb +0 -500
  152. data/lib/contrast/api.rb +0 -16
  153. data/lib/contrast/components/contrast_service.rb +0 -88
  154. data/lib/contrast/components/service.rb +0 -55
  155. data/lib/contrast/tasks/service.rb +0 -84
  156. data/lib/contrast/utils/input_classification.rb +0 -73
  157. data/lib/protobuf/code_generator.rb +0 -129
  158. data/lib/protobuf/decoder.rb +0 -28
  159. data/lib/protobuf/deprecation.rb +0 -117
  160. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
  161. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
  162. data/lib/protobuf/descriptors.rb +0 -3
  163. data/lib/protobuf/encoder.rb +0 -11
  164. data/lib/protobuf/enum.rb +0 -365
  165. data/lib/protobuf/exceptions.rb +0 -9
  166. data/lib/protobuf/field/base_field.rb +0 -380
  167. data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
  168. data/lib/protobuf/field/bool_field.rb +0 -64
  169. data/lib/protobuf/field/bytes_field.rb +0 -67
  170. data/lib/protobuf/field/double_field.rb +0 -25
  171. data/lib/protobuf/field/enum_field.rb +0 -56
  172. data/lib/protobuf/field/field_array.rb +0 -102
  173. data/lib/protobuf/field/field_hash.rb +0 -122
  174. data/lib/protobuf/field/fixed32_field.rb +0 -25
  175. data/lib/protobuf/field/fixed64_field.rb +0 -28
  176. data/lib/protobuf/field/float_field.rb +0 -43
  177. data/lib/protobuf/field/int32_field.rb +0 -21
  178. data/lib/protobuf/field/int64_field.rb +0 -34
  179. data/lib/protobuf/field/integer_field.rb +0 -23
  180. data/lib/protobuf/field/message_field.rb +0 -51
  181. data/lib/protobuf/field/sfixed32_field.rb +0 -27
  182. data/lib/protobuf/field/sfixed64_field.rb +0 -28
  183. data/lib/protobuf/field/signed_integer_field.rb +0 -29
  184. data/lib/protobuf/field/sint32_field.rb +0 -21
  185. data/lib/protobuf/field/sint64_field.rb +0 -21
  186. data/lib/protobuf/field/string_field.rb +0 -51
  187. data/lib/protobuf/field/uint32_field.rb +0 -21
  188. data/lib/protobuf/field/uint64_field.rb +0 -21
  189. data/lib/protobuf/field/varint_field.rb +0 -77
  190. data/lib/protobuf/field.rb +0 -74
  191. data/lib/protobuf/generators/base.rb +0 -85
  192. data/lib/protobuf/generators/enum_generator.rb +0 -39
  193. data/lib/protobuf/generators/extension_generator.rb +0 -27
  194. data/lib/protobuf/generators/field_generator.rb +0 -193
  195. data/lib/protobuf/generators/file_generator.rb +0 -262
  196. data/lib/protobuf/generators/group_generator.rb +0 -122
  197. data/lib/protobuf/generators/message_generator.rb +0 -104
  198. data/lib/protobuf/generators/option_generator.rb +0 -17
  199. data/lib/protobuf/generators/printable.rb +0 -160
  200. data/lib/protobuf/generators/service_generator.rb +0 -50
  201. data/lib/protobuf/lifecycle.rb +0 -33
  202. data/lib/protobuf/logging.rb +0 -39
  203. data/lib/protobuf/message/fields.rb +0 -233
  204. data/lib/protobuf/message/serialization.rb +0 -85
  205. data/lib/protobuf/message.rb +0 -241
  206. data/lib/protobuf/optionable.rb +0 -72
  207. data/lib/protobuf/tasks/compile.rake +0 -80
  208. data/lib/protobuf/tasks.rb +0 -1
  209. data/lib/protobuf/varint.rb +0 -20
  210. data/lib/protobuf/varint_pure.rb +0 -31
  211. data/lib/protobuf/version.rb +0 -3
  212. data/lib/protobuf/wire_type.rb +0 -10
  213. data/lib/protobuf.rb +0 -91
  214. data/proto/dynamic_discovery.proto +0 -46
  215. data/proto/google/protobuf/compiler/plugin.proto +0 -183
  216. data/proto/google/protobuf/descriptor.proto +0 -911
  217. data/proto/rpc.proto +0 -71
  218. data/service_executables/.gitkeep +0 -0
  219. data/service_executables/VERSION +0 -1
  220. data/service_executables/linux/contrast-service +0 -0
  221. data/service_executables/mac/contrast-service +0 -0
@@ -1,72 +0,0 @@
1
- require 'active_support/core_ext/object/try'
2
-
3
- module Protobuf
4
- module Optionable
5
- module ClassMethods
6
- def get_option(name)
7
- name = name.to_s
8
- option = optionable_descriptor_class.get_field(name, true)
9
- fail ArgumentError, "invalid option=#{name}" unless option
10
- unless option.fully_qualified_name.to_s == name
11
- # Eventually we'll deprecate the use of simple names of fields completely, but for now make sure people
12
- # are accessing options correctly. We allow simple names in other places for backwards compatibility.
13
- fail ArgumentError, "must access option using its fully qualified name: #{option.fully_qualified_name.inspect}"
14
- end
15
- value =
16
- if @_optionable_options.try(:key?, name)
17
- @_optionable_options[name]
18
- else
19
- option.default_value
20
- end
21
- if option.type_class < ::Protobuf::Message
22
- option.type_class.new(value)
23
- else
24
- value
25
- end
26
- end
27
-
28
- def get_option!(name)
29
- get_option(name) if @_optionable_options.try(:key?, name.to_s)
30
- end
31
-
32
- private
33
-
34
- def set_option(name, value = true)
35
- @_optionable_options ||= {}
36
- @_optionable_options[name.to_s] = value
37
- end
38
- end
39
-
40
- def get_option(name)
41
- self.class.get_option(name)
42
- end
43
-
44
- def get_option!(name)
45
- self.class.get_option!(name)
46
- end
47
-
48
- def self.inject(base_class, extend_class = true, &block)
49
- unless block_given?
50
- fail ArgumentError, 'missing option class block (e.g: ::CSGoogle::Protobuf::MessageOptions)'
51
- end
52
- if extend_class
53
- # Check if optionable_descriptor_class is already defined and short circuit if so.
54
- # File options are injected per module, and since a module can be defined more than once,
55
- # we will get a warning if we try to define optionable_descriptor_class twice.
56
- if base_class.respond_to?(:optionable_descriptor_class)
57
- # Don't define optionable_descriptor_class twice
58
- return if base_class.optionable_descriptor_class == block.call
59
-
60
- fail 'A class is being defined with two different descriptor classes, something is very wrong'
61
- end
62
-
63
- base_class.extend(ClassMethods)
64
- base_class.__send__(:include, self)
65
- base_class.define_singleton_method(:optionable_descriptor_class, block)
66
- else
67
- base_class.__send__(:include, ClassMethods)
68
- base_class.module_eval { define_method(:optionable_descriptor_class, block) }
69
- end
70
- end
71
- end
72
- end
@@ -1,80 +0,0 @@
1
- require "fileutils"
2
-
3
- namespace :protobuf do
4
-
5
- desc "Clean & Compile the protobuf source to ruby classes. Pass PB_NO_CLEAN=1 if you do not want to force-clean first."
6
- task :compile, [:package, :source, :destination, :plugin, :file_extension] do |_tasks, args|
7
- binpath = ::File.expand_path("../../../../bin", __FILE__)
8
-
9
- args.with_defaults(:destination => "lib")
10
- args.with_defaults(:source => "definitions")
11
- args.with_defaults(:plugin => "protoc-gen-ruby-protobuf=#{binpath}/protoc-gen-ruby")
12
- args.with_defaults(:file_extension => ".pb.rb")
13
-
14
- # The local Ruby generator collides with the builtin Ruby generator
15
- #
16
- # From the protoc docs:
17
- #
18
- # --plugin=EXECUTABLE
19
- #
20
- # ...EXECUTABLE may be of the form NAME=PATH, in which case the given plugin name
21
- # is mapped to the given executable even if the executable"s own name differs.
22
- #
23
- # Use the NAME=PATH form to specify an alternative plugin name that avoids the name collision
24
- #
25
- plugin_name, _plugin_path = args[:plugin].split("=")
26
-
27
- # The plugin name MUST have the protoc-gen- prefix in order to work, but that prefix is dropped
28
- # when using the plugin to generate definitions
29
- plugin_name.gsub!("protoc-gen-", "")
30
-
31
- unless do_not_clean?
32
- force_clean!
33
- ::Rake::Task[:clean].invoke(args[:package], args[:destination], args[:file_extension])
34
- end
35
-
36
- command = []
37
- command << "protoc"
38
- command << "--plugin=#{args[:plugin]}"
39
- command << "--#{plugin_name}_out=#{args[:destination]}"
40
- command << "-I #{args[:source]}"
41
- command << Dir["#{args[:source]}/#{args[:package]}/**/*.proto"].join(" ")
42
- full_command = command.join(" ")
43
-
44
- puts full_command
45
- system(full_command)
46
- end
47
-
48
- desc "Clean the generated *.pb.rb files from the destination package. Pass PB_FORCE_CLEAN=1 to skip confirmation step."
49
- task :clean, [:package, :destination, :file_extension] do |_task, args|
50
- args.with_defaults(:destination => "lib")
51
- args.with_defaults(:file_extension => ".pb.rb")
52
-
53
- file_extension = args[:file_extension].sub(/\*?\.+/, "")
54
- files_to_clean = ::File.join(args[:destination], args[:package], "**", "*.#{file_extension}")
55
-
56
- if force_clean? || permission_to_clean?(files_to_clean)
57
- ::Dir.glob(files_to_clean).each do |file|
58
- ::FileUtils.rm(file)
59
- end
60
- end
61
- end
62
-
63
- def do_not_clean?
64
- ! ::ENV.key?("PB_NO_CLEAN")
65
- end
66
-
67
- def force_clean?
68
- ::ENV.key?("PB_FORCE_CLEAN")
69
- end
70
-
71
- def force_clean!
72
- ::ENV["PB_FORCE_CLEAN"] = "1"
73
- end
74
-
75
- def permission_to_clean?(files_to_clean)
76
- puts "Do you really want to remove files matching pattern #{files_to_clean}? (y/n)"
77
- ::STDIN.gets.chomp =~ /y(es)?/i
78
- end
79
-
80
- end
@@ -1 +0,0 @@
1
- load 'protobuf/tasks/compile.rake'
@@ -1,20 +0,0 @@
1
- module Protobuf
2
- class Varint
3
- if defined?(::Varint)
4
- extend ::Varint
5
-
6
- def self.encode(value)
7
- bytes = []
8
- until value < 128
9
- bytes << (0x80 | (value & 0x7f))
10
- value >>= 7
11
- end
12
- (bytes << value).pack('C*')
13
- end
14
- elsif defined?(::ProtobufJavaHelpers)
15
- extend ::ProtobufJavaHelpers::EncodeDecode
16
- else
17
- extend VarintPure
18
- end
19
- end
20
- end
@@ -1,31 +0,0 @@
1
- module Protobuf
2
- module VarintPure
3
- CACHE_LIMIT = 2048
4
-
5
- def cached_varint(value)
6
- @_varint_cache ||= {}
7
- (@_varint_cache[value] ||= encode(value, false)).dup
8
- end
9
-
10
- def decode(stream)
11
- value = index = 0
12
- begin
13
- byte = stream.readbyte
14
- value |= (byte & 0x7f) << (7 * index)
15
- index += 1
16
- end while (byte & 0x80).nonzero?
17
- value
18
- end
19
-
20
- def encode(value, use_cache = true)
21
- return cached_varint(value) if use_cache && value >= 0 && value <= CACHE_LIMIT
22
-
23
- bytes = []
24
- until value < 128
25
- bytes << (0x80 | (value & 0x7f))
26
- value >>= 7
27
- end
28
- (bytes << value).pack('C*')
29
- end
30
- end
31
- end
@@ -1,3 +0,0 @@
1
- module Protobuf
2
- VERSION = '3.10.6' # rubocop:disable Style/MutableConstant
3
- end
@@ -1,10 +0,0 @@
1
- module Protobuf
2
- module WireType
3
- VARINT = 0
4
- FIXED64 = 1
5
- LENGTH_DELIMITED = 2
6
- START_GROUP = 3
7
- END_GROUP = 4
8
- FIXED32 = 5
9
- end
10
- end
data/lib/protobuf.rb DELETED
@@ -1,91 +0,0 @@
1
- require 'base64'
2
- require 'logger'
3
- require 'pp'
4
- require 'socket'
5
- require 'stringio'
6
-
7
- # All top-level run time code requires, ordered by necessity
8
- require 'protobuf/wire_type'
9
-
10
- require 'protobuf/varint_pure'
11
- require 'protobuf/varint'
12
-
13
- require 'protobuf/exceptions'
14
- require 'protobuf/deprecation'
15
- require 'protobuf/logging'
16
-
17
- require 'protobuf/encoder'
18
- require 'protobuf/decoder'
19
-
20
- require 'protobuf/optionable'
21
- require 'protobuf/field'
22
- require 'protobuf/enum'
23
- require 'protobuf/message'
24
- require 'protobuf/descriptors'
25
-
26
- module Protobuf
27
- class << self
28
- # Client Host
29
- #
30
- # Default: `hostname` of the system
31
- #
32
- # The name or address of the host to use during client RPC calls.
33
- attr_writer :client_host
34
- end
35
-
36
- def self.after_server_bind
37
- ::ActiveSupport::Notifications.subscribe('after_server_bind') do |*args|
38
- yield(*args)
39
- end
40
- end
41
-
42
- def self.before_server_bind
43
- ::ActiveSupport::Notifications.subscribe('before_server_bind') do |*args|
44
- yield(*args)
45
- end
46
- end
47
-
48
- def self.client_host
49
- @client_host ||= Socket.gethostname
50
- end
51
-
52
- def self.connector_type_class
53
- @connector_type_class ||= ::Protobuf::Rpc::Connectors::Socket
54
- end
55
-
56
- def self.connector_type_class= type_class
57
- @connector_type_class = type_class
58
- end
59
-
60
- # GC Pause during server requests
61
- #
62
- # Default: false
63
- #
64
- # Boolean value to tell the server to disable
65
- # the Garbage Collector when handling an rpc request.
66
- # Once the request is completed, the GC is enabled again.
67
- # This optomization provides a huge boost in speed to rpc requests.
68
- def self.gc_pause_server_request?
69
- return @gc_pause_server_request unless @gc_pause_server_request.nil?
70
-
71
- self.gc_pause_server_request = false
72
- end
73
-
74
- def self.gc_pause_server_request= value
75
- @gc_pause_server_request = !!value
76
- end
77
-
78
- # Permit unknown field on Message initialization
79
- #
80
- # Default: true
81
- #
82
- # Simple boolean to define whether we want to permit unknown fields
83
- # on Message intialization; otherwise a ::Protobuf::FieldNotDefinedError is thrown.
84
- def self.ignore_unknown_fields?
85
- !defined?(@ignore_unknown_fields) || @ignore_unknown_fields
86
- end
87
-
88
- def self.ignore_unknown_fields= value
89
- @ignore_unknown_fields = !!value
90
- end
91
- end
@@ -1,46 +0,0 @@
1
- // Copyright (c) 2013 MoneyDesktop, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
-
21
- // Authors: Devin Christensen
22
- //
23
- // Protobufs needed for dynamic discovery zmq server and client.
24
-
25
- syntax = "proto2";
26
-
27
- package protobuf.rpc.dynamicDiscovery;
28
-
29
- enum BeaconType {
30
- HEARTBEAT = 0;
31
- FLATLINE = 1;
32
- }
33
-
34
- message Server {
35
- optional string uuid = 1;
36
- optional string address = 2;
37
- optional string port = 3;
38
- optional int32 ttl = 4;
39
- repeated string services = 5;
40
- }
41
-
42
- message Beacon {
43
- optional BeaconType beacon_type = 1;
44
- optional Server server = 2;
45
- }
46
-
@@ -1,183 +0,0 @@
1
- // Protocol Buffers - Google's data interchange format
2
- // Copyright 2008 Google Inc. All rights reserved.
3
- // https://developers.google.com/protocol-buffers/
4
- //
5
- // Redistribution and use in source and binary forms, with or without
6
- // modification, are permitted provided that the following conditions are
7
- // met:
8
- //
9
- // * Redistributions of source code must retain the above copyright
10
- // notice, this list of conditions and the following disclaimer.
11
- // * Redistributions in binary form must reproduce the above
12
- // copyright notice, this list of conditions and the following disclaimer
13
- // in the documentation and/or other materials provided with the
14
- // distribution.
15
- // * Neither the name of Google Inc. nor the names of its
16
- // contributors may be used to endorse or promote products derived from
17
- // this software without specific prior written permission.
18
- //
19
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-
31
- // Author: kenton@google.com (Kenton Varda)
32
- //
33
- // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
34
- // change.
35
- //
36
- // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
37
- // just a program that reads a CodeGeneratorRequest from stdin and writes a
38
- // CodeGeneratorResponse to stdout.
39
- //
40
- // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
41
- // of dealing with the raw protocol defined here.
42
- //
43
- // A plugin executable needs only to be placed somewhere in the path. The
44
- // plugin should be named "protoc-gen-$NAME", and will then be used when the
45
- // flag "--${NAME}_out" is passed to protoc.
46
-
47
- syntax = "proto2";
48
-
49
- package google.protobuf.compiler;
50
- option java_package = "com.google.protobuf.compiler";
51
- option java_outer_classname = "PluginProtos";
52
-
53
- option go_package = "google.golang.org/protobuf/types/pluginpb";
54
-
55
- import "google/protobuf/descriptor.proto";
56
-
57
- // The version number of protocol compiler.
58
- message Version {
59
- optional int32 major = 1;
60
- optional int32 minor = 2;
61
- optional int32 patch = 3;
62
- // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
63
- // be empty for mainline stable releases.
64
- optional string suffix = 4;
65
- }
66
-
67
- // An encoded CodeGeneratorRequest is written to the plugin's stdin.
68
- message CodeGeneratorRequest {
69
- // The .proto files that were explicitly listed on the command-line. The
70
- // code generator should generate code only for these files. Each file's
71
- // descriptor will be included in proto_file, below.
72
- repeated string file_to_generate = 1;
73
-
74
- // The generator parameter passed on the command-line.
75
- optional string parameter = 2;
76
-
77
- // FileDescriptorProtos for all files in files_to_generate and everything
78
- // they import. The files will appear in topological order, so each file
79
- // appears before any file that imports it.
80
- //
81
- // protoc guarantees that all proto_files will be written after
82
- // the fields above, even though this is not technically guaranteed by the
83
- // protobuf wire format. This theoretically could allow a plugin to stream
84
- // in the FileDescriptorProtos and handle them one by one rather than read
85
- // the entire set into memory at once. However, as of this writing, this
86
- // is not similarly optimized on protoc's end -- it will store all fields in
87
- // memory at once before sending them to the plugin.
88
- //
89
- // Type names of fields and extensions in the FileDescriptorProto are always
90
- // fully qualified.
91
- repeated FileDescriptorProto proto_file = 15;
92
-
93
- // The version number of protocol compiler.
94
- optional Version compiler_version = 3;
95
-
96
- }
97
-
98
- // The plugin writes an encoded CodeGeneratorResponse to stdout.
99
- message CodeGeneratorResponse {
100
- // Error message. If non-empty, code generation failed. The plugin process
101
- // should exit with status code zero even if it reports an error in this way.
102
- //
103
- // This should be used to indicate errors in .proto files which prevent the
104
- // code generator from generating correct code. Errors which indicate a
105
- // problem in protoc itself -- such as the input CodeGeneratorRequest being
106
- // unparseable -- should be reported by writing a message to stderr and
107
- // exiting with a non-zero status code.
108
- optional string error = 1;
109
-
110
- // A bitmask of supported features that the code generator supports.
111
- // This is a bitwise "or" of values from the Feature enum.
112
- optional uint64 supported_features = 2;
113
-
114
- // Sync with code_generator.h.
115
- enum Feature {
116
- FEATURE_NONE = 0;
117
- FEATURE_PROTO3_OPTIONAL = 1;
118
- }
119
-
120
- // Represents a single generated file.
121
- message File {
122
- // The file name, relative to the output directory. The name must not
123
- // contain "." or ".." components and must be relative, not be absolute (so,
124
- // the file cannot lie outside the output directory). "/" must be used as
125
- // the path separator, not "\".
126
- //
127
- // If the name is omitted, the content will be appended to the previous
128
- // file. This allows the generator to break large files into small chunks,
129
- // and allows the generated text to be streamed back to protoc so that large
130
- // files need not reside completely in memory at one time. Note that as of
131
- // this writing protoc does not optimize for this -- it will read the entire
132
- // CodeGeneratorResponse before writing files to disk.
133
- optional string name = 1;
134
-
135
- // If non-empty, indicates that the named file should already exist, and the
136
- // content here is to be inserted into that file at a defined insertion
137
- // point. This feature allows a code generator to extend the output
138
- // produced by another code generator. The original generator may provide
139
- // insertion points by placing special annotations in the file that look
140
- // like:
141
- // @@protoc_insertion_point(NAME)
142
- // The annotation can have arbitrary text before and after it on the line,
143
- // which allows it to be placed in a comment. NAME should be replaced with
144
- // an identifier naming the point -- this is what other generators will use
145
- // as the insertion_point. Code inserted at this point will be placed
146
- // immediately above the line containing the insertion point (thus multiple
147
- // insertions to the same point will come out in the order they were added).
148
- // The double-@ is intended to make it unlikely that the generated code
149
- // could contain things that look like insertion points by accident.
150
- //
151
- // For example, the C++ code generator places the following line in the
152
- // .pb.h files that it generates:
153
- // // @@protoc_insertion_point(namespace_scope)
154
- // This line appears within the scope of the file's package namespace, but
155
- // outside of any particular class. Another plugin can then specify the
156
- // insertion_point "namespace_scope" to generate additional classes or
157
- // other declarations that should be placed in this scope.
158
- //
159
- // Note that if the line containing the insertion point begins with
160
- // whitespace, the same whitespace will be added to every line of the
161
- // inserted text. This is useful for languages like Python, where
162
- // indentation matters. In these languages, the insertion point comment
163
- // should be indented the same amount as any inserted code will need to be
164
- // in order to work correctly in that context.
165
- //
166
- // The code generator that generates the initial file and the one which
167
- // inserts into it must both run as part of a single invocation of protoc.
168
- // Code generators are executed in the order in which they appear on the
169
- // command line.
170
- //
171
- // If |insertion_point| is present, |name| must also be present.
172
- optional string insertion_point = 2;
173
-
174
- // The file contents.
175
- optional string content = 15;
176
-
177
- // Information describing the file content being inserted. If an insertion
178
- // point is used, this information will be appropriately offset and inserted
179
- // into the code generation metadata for the generated files.
180
- optional GeneratedCodeInfo generated_code_info = 16;
181
- }
182
- repeated File file = 15;
183
- }