Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/common/stats/stat_merger_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void testDynamicEncoding(absl::string_view data, SymbolTable& symbol_table) {
// TODO(#10008): We should remove the "1 +" below, so we can get empty
// segments, which trigger some inconsistent handling as described in that
// bug.
uint32_t num_bytes = 1 + data[index] & 0x7;
uint32_t num_bytes = (1 + data[index]) & 0x7;
Copy link
Copy Markdown
Contributor

@antoniovicente antoniovicente May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarantz

If you look at the comment above, I think the intent of this line was:
uint32_t num_bytes = 1 + (data[index] & 0x7);

Copy link
Copy Markdown
Contributor

@twghu twghu May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to initial byte count has resolved fuzz crash 30088 and removed need for additional testing of num_bytes.

num_bytes = std::min(static_cast<uint32_t>(data.size() - 1),
num_bytes); // restrict number up to the size of data

Expand Down
48 changes: 24 additions & 24 deletions test/extensions/filters/http/common/fuzz/filter_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ namespace Extensions {
namespace HttpFilters {

DEFINE_PROTO_FUZZER(const test::extensions::filters::http::FilterFuzzTestCase& input) {
static PostProcessorRegistration reg = {[](test::extensions::filters::http::FilterFuzzTestCase*
input,
unsigned int seed) {
// This ensures that the mutated configs all have valid filter names and type_urls. The list of
// names and type_urls is pulled from the NamedHttpFilterConfigFactory. All Envoy extensions are
// built with this test (see BUILD file).
// This post-processor mutation is applied only when libprotobuf-mutator calls mutate on an
// input, and *not* during fuzz target execution. Replaying a corpus through the fuzzer will not
// be affected by the post-processor mutation.
static const std::vector<absl::string_view> filter_names = Registry::FactoryRegistry<
Server::Configuration::NamedHttpFilterConfigFactory>::registeredNames();
static const auto factories =
Registry::FactoryRegistry<Server::Configuration::NamedHttpFilterConfigFactory>::factories();
// Choose a valid filter name.
if (std::find(filter_names.begin(), filter_names.end(), input->config().name()) ==
std::end(filter_names)) {
absl::string_view filter_name = filter_names[seed % filter_names.size()];
input->mutable_config()->set_name(std::string(filter_name));
}
// Set the corresponding type_url for Any.
auto& factory = factories.at(input->config().name());
input->mutable_config()->mutable_typed_config()->set_type_url(absl::StrCat(
"type.googleapis.com/", factory->createEmptyConfigProto()->GetDescriptor()->full_name()));
}};
ABSL_ATTRIBUTE_UNUSED static PostProcessorRegistration reg = {
[](test::extensions::filters::http::FilterFuzzTestCase* input, unsigned int seed) {
// This ensures that the mutated configs all have valid filter names and type_urls. The list
// of names and type_urls is pulled from the NamedHttpFilterConfigFactory. All Envoy
// extensions are built with this test (see BUILD file). This post-processor mutation is
// applied only when libprotobuf-mutator calls mutate on an input, and *not* during fuzz
// target execution. Replaying a corpus through the fuzzer will not be affected by the
// post-processor mutation.
static const std::vector<absl::string_view> filter_names = Registry::FactoryRegistry<
Server::Configuration::NamedHttpFilterConfigFactory>::registeredNames();
static const auto factories = Registry::FactoryRegistry<
Server::Configuration::NamedHttpFilterConfigFactory>::factories();
// Choose a valid filter name.
if (std::find(filter_names.begin(), filter_names.end(), input->config().name()) ==
std::end(filter_names)) {
absl::string_view filter_name = filter_names[seed % filter_names.size()];
input->mutable_config()->set_name(std::string(filter_name));
}
// Set the corresponding type_url for Any.
auto& factory = factories.at(input->config().name());
input->mutable_config()->mutable_typed_config()->set_type_url(
absl::StrCat("type.googleapis.com/",
factory->createEmptyConfigProto()->GetDescriptor()->full_name()));
}};

try {
// Catch invalid header characters.
Expand Down
2 changes: 2 additions & 0 deletions test/server/filter_chain_benchmark_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ const char YamlSingleDstPortBottom[] = R"EOF(

class FilterChainBenchmarkFixture : public benchmark::Fixture {
public:
using benchmark::Fixture::SetUp;

void SetUp(::benchmark::State& state) override {
int64_t input_size = state.range(0);
std::vector<std::string> port_chains;
Expand Down