thrift 0.22.0 → 0.24.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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +235 -17
  3. data/benchmark/benchmark.rb +23 -8
  4. data/benchmark/client.rb +50 -6
  5. data/benchmark/server.rb +46 -7
  6. data/benchmark/thin_server.rb +2 -0
  7. data/ext/binary_protocol_accelerated.c +154 -42
  8. data/ext/bytes.c +14 -0
  9. data/ext/compact_protocol.c +138 -45
  10. data/ext/constants.h +12 -0
  11. data/ext/extconf.rb +17 -8
  12. data/ext/memory_buffer.c +44 -7
  13. data/ext/protocol.c +29 -0
  14. data/ext/protocol.h +35 -0
  15. data/ext/struct.c +48 -17
  16. data/ext/thrift_native.c +28 -3
  17. data/lib/thrift/bytes.rb +70 -100
  18. data/lib/thrift/client.rb +54 -13
  19. data/lib/thrift/exceptions.rb +6 -5
  20. data/lib/thrift/multiplexed_processor.rb +20 -10
  21. data/lib/thrift/processor.rb +7 -6
  22. data/lib/thrift/protocol/base_protocol.rb +52 -21
  23. data/lib/thrift/protocol/binary_protocol.rb +65 -20
  24. data/lib/thrift/protocol/binary_protocol_accelerated.rb +6 -5
  25. data/lib/thrift/protocol/compact_protocol.rb +76 -41
  26. data/lib/thrift/protocol/header_protocol.rb +321 -0
  27. data/lib/thrift/protocol/json_protocol.rb +44 -27
  28. data/lib/thrift/protocol/multiplexed_protocol.rb +6 -5
  29. data/lib/thrift/protocol/protocol_decorator.rb +13 -4
  30. data/lib/thrift/serializer/deserializer.rb +6 -5
  31. data/lib/thrift/serializer/serializer.rb +5 -5
  32. data/lib/thrift/server/base_server.rb +5 -4
  33. data/lib/thrift/server/mongrel_http_server.rb +7 -6
  34. data/lib/thrift/server/nonblocking_server.rb +35 -9
  35. data/lib/thrift/server/simple_server.rb +13 -5
  36. data/lib/thrift/server/thin_http_server.rb +4 -3
  37. data/lib/thrift/server/thread_pool_server.rb +7 -6
  38. data/lib/thrift/server/threaded_server.rb +13 -5
  39. data/lib/thrift/struct.rb +12 -11
  40. data/lib/thrift/struct_union.rb +14 -9
  41. data/lib/thrift/thrift_native.rb +3 -2
  42. data/lib/thrift/transport/base_server_transport.rb +8 -5
  43. data/lib/thrift/transport/base_transport.rb +18 -14
  44. data/lib/thrift/transport/buffered_transport.rb +7 -6
  45. data/lib/thrift/transport/framed_transport.rb +8 -7
  46. data/lib/thrift/transport/header_transport.rb +562 -0
  47. data/lib/thrift/transport/http_client_transport.rb +2 -1
  48. data/lib/thrift/transport/io_stream_transport.rb +4 -3
  49. data/lib/thrift/transport/memory_buffer_transport.rb +13 -6
  50. data/lib/thrift/transport/server_socket.rb +14 -8
  51. data/lib/thrift/transport/socket.rb +126 -60
  52. data/lib/thrift/transport/ssl_server_socket.rb +4 -3
  53. data/lib/thrift/transport/ssl_socket.rb +45 -13
  54. data/lib/thrift/transport/unix_server_socket.rb +9 -5
  55. data/lib/thrift/transport/unix_socket.rb +7 -6
  56. data/lib/thrift/types.rb +10 -6
  57. data/lib/thrift/union.rb +15 -8
  58. data/lib/thrift/uuid.rb +50 -0
  59. data/lib/thrift.rb +4 -1
  60. data/spec/ThriftSpec.thrift +21 -1
  61. data/spec/base_protocol_spec.rb +21 -2
  62. data/spec/base_transport_spec.rb +48 -8
  63. data/spec/binary_protocol_accelerated_spec.rb +1 -0
  64. data/spec/binary_protocol_spec.rb +1 -2
  65. data/spec/binary_protocol_spec_shared.rb +206 -155
  66. data/spec/bytes_spec.rb +71 -114
  67. data/spec/client_spec.rb +86 -19
  68. data/spec/compact_protocol_spec.rb +153 -16
  69. data/spec/constants_demo_spec.rb +102 -0
  70. data/spec/exception_spec.rb +1 -1
  71. data/spec/flat_spec.rb +1 -0
  72. data/spec/header_protocol_spec.rb +476 -0
  73. data/spec/header_transport_spec.rb +431 -0
  74. data/spec/http_client_spec.rb +5 -6
  75. data/spec/json_protocol_spec.rb +69 -47
  76. data/spec/multiplexed_processor_spec.rb +75 -0
  77. data/spec/namespaced_spec.rb +1 -1
  78. data/spec/nonblocking_server_spec.rb +174 -8
  79. data/spec/processor_spec.rb +1 -1
  80. data/spec/recursion_depth_spec.rb +223 -0
  81. data/spec/serializer_spec.rb +1 -1
  82. data/spec/server_socket_spec.rb +38 -1
  83. data/spec/server_spec.rb +60 -9
  84. data/spec/socket_spec.rb +119 -13
  85. data/spec/socket_spec_shared.rb +73 -9
  86. data/spec/spec_helper.rb +2 -1
  87. data/spec/ssl_server_socket_spec.rb +52 -1
  88. data/spec/ssl_socket_spec.rb +181 -11
  89. data/spec/struct_nested_containers_spec.rb +2 -2
  90. data/spec/struct_spec.rb +114 -9
  91. data/spec/support/header_protocol_helper.rb +55 -0
  92. data/spec/thin_http_server_spec.rb +4 -18
  93. data/spec/types_spec.rb +26 -26
  94. data/spec/union_spec.rb +70 -11
  95. data/spec/unix_socket_spec.rb +17 -2
  96. data/spec/uuid_validation_spec.rb +239 -0
  97. data/test/fuzz/Makefile +779 -0
  98. data/test/fuzz/Makefile.am +173 -0
  99. data/test/fuzz/Makefile.in +775 -0
  100. data/test/fuzz/README.md +149 -0
  101. data/test/fuzz/fuzz_common.rb +96 -0
  102. data/{lib/thrift/core_ext.rb → test/fuzz/fuzz_parse_binary_protocol.rb} +4 -4
  103. data/{lib/thrift/core_ext/fixnum.rb → test/fuzz/fuzz_parse_binary_protocol_accelerated.rb} +7 -13
  104. data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +23 -0
  105. data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +23 -0
  106. data/test/fuzz/fuzz_parse_compact_protocol.rb +23 -0
  107. data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +23 -0
  108. data/test/fuzz/fuzz_parse_json_protocol.rb +23 -0
  109. data/test/fuzz/fuzz_parse_json_protocol_harness.rb +23 -0
  110. data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +23 -0
  111. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +23 -0
  112. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +23 -0
  113. data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +23 -0
  114. data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +23 -0
  115. data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +23 -0
  116. data/test/fuzz/fuzz_roundtrip_json_protocol.rb +23 -0
  117. data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +23 -0
  118. data/test/fuzz/fuzz_tracer.rb +29 -0
  119. metadata +105 -70
@@ -0,0 +1,149 @@
1
+ # Ruby Fuzzing README
2
+
3
+ The Ruby Thrift implementation uses [Ruzzy](https://github.com/trailofbits/ruzzy) for fuzzing. Ruzzy is a coverage-guided fuzzer for pure Ruby code and Ruby C extensions.
4
+
5
+ We currently have several fuzz targets that test different aspects of the Thrift implementation:
6
+
7
+ - `fuzz_parse_binary_protocol.rb` -- fuzzes deserialization of the Binary protocol
8
+ - `fuzz_parse_binary_protocol_accelerated.rb` -- fuzzes deserialization of the accelerated Binary protocol
9
+ - `fuzz_parse_compact_protocol.rb` -- fuzzes deserialization of the Compact protocol
10
+ - `fuzz_parse_json_protocol.rb` -- fuzzes JSON protocol messages
11
+ - `fuzz_roundtrip_binary_protocol.rb` -- fuzzes Binary roundtrips (deserialize, serialize, deserialize, compare)
12
+ - `fuzz_roundtrip_binary_protocol_accelerated.rb` -- fuzzes accelerated Binary roundtrips
13
+ - `fuzz_roundtrip_compact_protocol.rb` -- fuzzes Compact roundtrips
14
+ - `fuzz_roundtrip_json_protocol.rb` -- fuzzes JSON message roundtrips
15
+
16
+ The runnable files in this directory are tracer entrypoints. Ruzzy requires that pure Ruby fuzzing starts from a tracer script which then loads a separate harness, so do not invoke the matching `_harness.rb` files directly.
17
+
18
+ The fuzzers use Ruzzy's mutation engine to generate test cases. Each target uses common testing code from `fuzz_common.rb`.
19
+
20
+ For more information about Ruzzy and its options, see the [Ruzzy documentation](https://github.com/trailofbits/ruzzy).
21
+
22
+ You can also use the corpus generator from the Rust implementation to generate initial Binary and Compact corpora that can be reused by the Ruby fuzzers, since those wire formats are identical between implementations.
23
+
24
+ ## Setup
25
+
26
+ Run these commands from the repository root:
27
+
28
+ ```bash
29
+ apt install -y clang-19
30
+
31
+ # from https://github.com/trailofbits/ruzzy?tab=readme-ov-file#installing
32
+ MAKE="make --environment-overrides V=1" \
33
+ CC="/usr/bin/clang-19" \
34
+ CXX="/usr/bin/clang++-19" \
35
+ LDSHARED="/usr/bin/clang-19 -shared" \
36
+ LDSHAREDXX="/usr/bin/clang++-19 -shared" \
37
+ gem install ruzzy
38
+
39
+ # Validate the fuzz directory.
40
+ # This generates test/fuzz/gen-rb, syntax-checks the fuzz scripts,
41
+ # and verifies that Fuzz::FuzzTest loads correctly.
42
+ make -C lib/rb/test/fuzz check
43
+ ```
44
+
45
+ `make -C lib/rb check` now recurses into `lib/rb/test/fuzz`, so the same validation also runs as part of the normal Ruby `make check` flow.
46
+
47
+ ## Running Fuzzers
48
+
49
+ The Makefile in this directory hides the `LD_PRELOAD` and `ASAN_OPTIONS` setup needed by Ruzzy.
50
+
51
+ Pure Ruby targets only need `fuzz-prepare`, which is the same work as `check`:
52
+
53
+ ```bash
54
+ make -C lib/rb/test/fuzz fuzz-parse-binary
55
+ make -C lib/rb/test/fuzz fuzz-roundtrip-compact
56
+ make -C lib/rb/test/fuzz fuzz-parse-json
57
+ ```
58
+
59
+ Accelerated targets rebuild `thrift_native` with sanitizer flags first:
60
+
61
+ ```bash
62
+ make -C lib/rb/test/fuzz fuzz-parse-binary-accelerated
63
+ make -C lib/rb/test/fuzz fuzz-roundtrip-binary-accelerated
64
+ ```
65
+
66
+ Use `CORPUS=...` to point at an input corpus. The path is resolved from `lib/rb`, which matches the old manual commands:
67
+
68
+ ```bash
69
+ make -C lib/rb/test/fuzz fuzz-parse-binary \
70
+ CORPUS=../rs/test/fuzz/corpus/binary
71
+
72
+ make -C lib/rb/test/fuzz fuzz-parse-compact \
73
+ CORPUS=../rs/test/fuzz/corpus/compact
74
+ ```
75
+
76
+ Use `FUZZ_ARGS=...` for extra libFuzzer-style arguments. For a short local run, the Makefile also provides bounded smoke targets:
77
+
78
+ ```bash
79
+ make -C lib/rb/test/fuzz fuzz-smoke-parse-binary
80
+ make -C lib/rb/test/fuzz fuzz-smoke-parse-binary-accelerated \
81
+ FUZZ_CC=/usr/bin/clang-19 \
82
+ FUZZ_CXX=/usr/bin/clang++-19
83
+ ```
84
+
85
+ If the default `clang` and `clang++` names are not correct for your system, override these variables for accelerated targets:
86
+
87
+ ```bash
88
+ make -C lib/rb/test/fuzz fuzz-build-ext \
89
+ FUZZ_CC=/usr/bin/clang-19 \
90
+ FUZZ_CXX=/usr/bin/clang++-19
91
+ ```
92
+
93
+ The underlying manual command from `lib/rb` is still:
94
+
95
+ ```bash
96
+ # Memory allocation failures are common and low impact (DoS), so skip them for now.
97
+ # Like Python, the Ruby interpreter leaks data, so ignore these for now.
98
+ # Ruby recommends disabling sigaltstack.
99
+ export ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0"
100
+
101
+ LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
102
+ ruby test/fuzz/fuzz_parse_binary_protocol.rb
103
+ ```
104
+
105
+ ## Rust Corpus Generator
106
+
107
+ We can use the Rust corpus generator to prepare corpora for the Binary and Compact protocol targets. Run it from the repository root:
108
+
109
+ ```bash
110
+ cargo run --manifest-path lib/rs/test/fuzz/Cargo.toml --bin corpus_generator -- \
111
+ --output-dir <output_dir> \
112
+ --protocol <binary|compact> \
113
+ --generate <num_files> \
114
+ --buffer-size <buffer_size> \
115
+ --random-size <random_size>
116
+ ```
117
+
118
+ Reasonable values (determined empirically):
119
+
120
+ ```bash
121
+ cargo run --manifest-path lib/rs/test/fuzz/Cargo.toml --bin corpus_generator -- \
122
+ --output-dir ./lib/rs/test/fuzz/corpus/binary \
123
+ --protocol binary \
124
+ --generate 1000 \
125
+ --buffer-size 65536 \
126
+ --random-size 16384
127
+
128
+ cargo run --manifest-path lib/rs/test/fuzz/Cargo.toml --bin corpus_generator -- \
129
+ --output-dir ./lib/rs/test/fuzz/corpus/compact \
130
+ --protocol compact \
131
+ --generate 1000 \
132
+ --buffer-size 16384 \
133
+ --random-size 16384
134
+ ```
135
+
136
+ Then run a matching Ruby target:
137
+
138
+ ```bash
139
+ make -C lib/rb/test/fuzz fuzz-parse-binary \
140
+ CORPUS=../rs/test/fuzz/corpus/binary
141
+ ```
142
+
143
+ The Rust corpus generator does not emit JSON protocol inputs, so use it only with the Binary and Compact Ruby targets.
144
+
145
+ ## Troubleshooting
146
+
147
+ If libFuzzer prints `WARNING: no interesting inputs were found so far. Is the code instrumented for coverage?` and quickly shrinks the seed corpus to `corp: 1/1b`, coverage tracing is not active. That usually means the tracer script was bypassed or `ruzzy` was not installed with the expected sanitizer-enabled toolchain. Run the `.rb` files in this directory, not the `_harness.rb` files.
148
+
149
+ If an accelerated target starts using the pure Ruby implementation, rebuild the extension with `make -C lib/rb/test/fuzz fuzz-build-ext ...` and then rerun the accelerated target.
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ $:.unshift File.expand_path('../../lib', __dir__)
22
+ $:.unshift File.expand_path('../../ext', __dir__)
23
+ require 'thrift'
24
+ $:.unshift File.dirname(__FILE__) + "/gen-rb"
25
+ require 'fuzz_test_constants'
26
+
27
+ require 'coverage'
28
+ Coverage.start(branches: true) unless Coverage.respond_to?(:running?) && Coverage.running?
29
+ require 'ruzzy'
30
+ # Ruzzy.enable_branch_coverage_hooks
31
+
32
+ def ignorable_fuzz_exception?(error)
33
+ return true if error.is_a?(Thrift::ProtocolException) ||
34
+ error.is_a?(EOFError) ||
35
+ error.is_a?(Encoding::UndefinedConversionError)
36
+
37
+ [
38
+ /don't know what (?:c)?type/,
39
+ /Too many fields for union/,
40
+ /too big to convert to '(?:int|long)'/,
41
+ /bignum too big to convert into 'long'/,
42
+ /negative array size/,
43
+ /Union fields are not set/
44
+ ].any? { |pattern| error.message =~ pattern }
45
+ end
46
+
47
+ def read_fuzz_test(protocol, read_message_begin)
48
+ protocol.read_message_begin if read_message_begin
49
+ obj = Fuzz::FuzzTest.new
50
+ obj.read(protocol)
51
+ protocol.read_message_end if read_message_begin
52
+ obj
53
+ end
54
+
55
+ def write_fuzz_test(protocol, obj, write_message_begin)
56
+ if write_message_begin
57
+ protocol.write_message_begin('fuzz', Thrift::MessageTypes::CALL, 0)
58
+ end
59
+ obj.write(protocol)
60
+ protocol.write_message_end if write_message_begin
61
+ end
62
+
63
+ def create_parser_fuzzer(protocol_factory_class, read_message_begin: false)
64
+ lambda do |data|
65
+ transport = Thrift::MemoryBufferTransport.new(data)
66
+ protocol = protocol_factory_class.new.get_protocol(transport)
67
+ read_fuzz_test(protocol, read_message_begin)
68
+ 0
69
+ rescue StandardError => e
70
+ # We're looking for memory corruption, not Ruby exceptions
71
+ raise unless ignorable_fuzz_exception?(e)
72
+ end
73
+ end
74
+
75
+ def create_roundtrip_fuzzer(protocol_factory_class, read_message_begin: false)
76
+ lambda do |data|
77
+ transport = Thrift::MemoryBufferTransport.new(data)
78
+ protocol = protocol_factory_class.new.get_protocol(transport)
79
+ obj = read_fuzz_test(protocol, read_message_begin)
80
+
81
+ serialized_data = +""
82
+ transport2 = Thrift::MemoryBufferTransport.new(serialized_data)
83
+ protocol2 = protocol_factory_class.new.get_protocol(transport2)
84
+ write_fuzz_test(protocol2, obj, read_message_begin)
85
+
86
+ transport3 = Thrift::MemoryBufferTransport.new(serialized_data)
87
+ protocol3 = protocol_factory_class.new.get_protocol(transport3)
88
+ deserialized_obj = read_fuzz_test(protocol3, read_message_begin)
89
+
90
+ raise "Roundtrip mismatch" unless obj == deserialized_obj
91
+ 0
92
+ rescue StandardError => e
93
+ # We're looking for memory corruption, not Ruby exceptions
94
+ raise unless ignorable_fuzz_exception?(e)
95
+ end
96
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Licensed to the Apache Software Foundation (ASF) under one
3
4
  # or more contributor license agreements. See the NOTICE file
@@ -17,7 +18,6 @@
17
18
  # under the License.
18
19
  #
19
20
 
20
- Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].each do |file|
21
- name = File.basename(file, '.rb')
22
- require "thrift/core_ext/#{name}"
23
- end
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -1,4 +1,5 @@
1
- #
1
+ # frozen_string_literal: true
2
+ #
2
3
  # Licensed to the Apache Software Foundation (ASF) under one
3
4
  # or more contributor license agreements. See the NOTICE file
4
5
  # distributed with this work for additional information
@@ -6,9 +7,9 @@
6
7
  # to you under the Apache License, Version 2.0 (the
7
8
  # "License"); you may not use this file except in compliance
8
9
  # with the License. You may obtain a copy of the License at
9
- #
10
+ #
10
11
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
+ #
12
13
  # Unless required by applicable law or agreed to in writing,
13
14
  # software distributed under the License is distributed on an
14
15
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,13 +18,6 @@
17
18
  # under the License.
18
19
  #
19
20
 
20
- # Versions of ruby pre 1.8.7 do not have an .ord method available in the Fixnum
21
- # class.
22
- #
23
- if RUBY_VERSION < "1.8.7"
24
- class Fixnum
25
- def ord
26
- self
27
- end
28
- end
29
- end
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_parser_fuzzer(Thrift::BinaryProtocolAcceleratedFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_parser_fuzzer(Thrift::BinaryProtocolFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_parser_fuzzer(Thrift::CompactProtocolFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_parser_fuzzer(Thrift::JsonProtocolFactory, read_message_begin: true))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_roundtrip_fuzzer(Thrift::BinaryProtocolAcceleratedFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_roundtrip_fuzzer(Thrift::BinaryProtocolFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_roundtrip_fuzzer(Thrift::CompactProtocolFactory))
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_tracer'
22
+
23
+ trace_fuzz_target(__FILE__)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require_relative 'fuzz_common'
22
+
23
+ Ruzzy.fuzz(create_roundtrip_fuzzer(Thrift::JsonProtocolFactory, read_message_begin: true))
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require 'ruzzy'
22
+
23
+ def trace_fuzz_target(script_path)
24
+ harness_path = File.expand_path(
25
+ "#{File.basename(script_path, '.rb')}_harness.rb",
26
+ File.dirname(script_path)
27
+ )
28
+ Ruzzy.trace(harness_path)
29
+ end