From 8f0f05b8c3ce89018b363b84548dceca314360b0 Mon Sep 17 00:00:00 2001 From: Asra Ali Date: Mon, 26 Aug 2019 13:43:42 -0400 Subject: [PATCH 1/3] fuzz: add bounds to statsh flush interval Signed-off-by: Asra Ali --- api/envoy/config/bootstrap/v2/bootstrap.proto | 8 +++++++- ...-testcase-server_fuzz_test-5734693923717120 | 18 ++++++++++++++++++ test/server/server_fuzz_test.cc | 10 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/server/server_corpus/clusterfuzz-testcase-server_fuzz_test-5734693923717120 diff --git a/api/envoy/config/bootstrap/v2/bootstrap.proto b/api/envoy/config/bootstrap/v2/bootstrap.proto index 477aeac5a141..05f37acfa562 100644 --- a/api/envoy/config/bootstrap/v2/bootstrap.proto +++ b/api/envoy/config/bootstrap/v2/bootstrap.proto @@ -99,7 +99,13 @@ message Bootstrap { // performance reasons Envoy latches counters and only flushes counters and // gauges at a periodic interval. If not specified the default is 5000ms (5 // seconds). - google.protobuf.Duration stats_flush_interval = 7 [(gogoproto.stdduration) = true]; + google.protobuf.Duration stats_flush_interval = 7 [ + (validate.rules).duration = { + lt: {seconds: 5}, + gte: {nanos: 1000000} + }, + (gogoproto.stdduration) = true + ]; // Optional watchdog configuration. Watchdog watchdog = 8; diff --git a/test/server/server_corpus/clusterfuzz-testcase-server_fuzz_test-5734693923717120 b/test/server/server_corpus/clusterfuzz-testcase-server_fuzz_test-5734693923717120 new file mode 100644 index 000000000000..187e397539d2 --- /dev/null +++ b/test/server/server_corpus/clusterfuzz-testcase-server_fuzz_test-5734693923717120 @@ -0,0 +1,18 @@ +static_resources { + clusters { + name: "@" + connect_timeout { + nanos: 250000000 + } + common_lb_config { + zone_aware_lb_config { + min_cluster_size { + value: 38 + } + } + } + } +} +stats_flush_interval { + nanos: 32256 +} diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index 2ee39d2f8d88..973527c7b05d 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -1,5 +1,7 @@ #include +#include "envoy/config/bootstrap/v2/bootstrap.pb.validate.h" + #include "common/network/address_impl.h" #include "common/thread_local/thread_local_impl.h" @@ -61,6 +63,14 @@ class AllFeaturesHooks : public DefaultListenerHooks { }; DEFINE_PROTO_FUZZER(const envoy::config::bootstrap::v2::Bootstrap& input) { + try { + // Validate the input early. + TestUtility::validate(input); + } catch (const EnvoyException& ex) { + ENVOY_LOG_MISC(debug, "Controlled EnvoyException exit: {}", ex.what()); + return; + } + testing::NiceMock options; AllFeaturesHooks hooks; testing::NiceMock restart; From bd255b403b96662f77f0c36c0164d5c029e89966 Mon Sep 17 00:00:00 2001 From: Asra Ali Date: Mon, 26 Aug 2019 14:26:06 -0400 Subject: [PATCH 2/3] fix max Signed-off-by: Asra Ali --- api/envoy/config/bootstrap/v2/bootstrap.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/envoy/config/bootstrap/v2/bootstrap.proto b/api/envoy/config/bootstrap/v2/bootstrap.proto index 05f37acfa562..567957efdc87 100644 --- a/api/envoy/config/bootstrap/v2/bootstrap.proto +++ b/api/envoy/config/bootstrap/v2/bootstrap.proto @@ -101,7 +101,7 @@ message Bootstrap { // seconds). google.protobuf.Duration stats_flush_interval = 7 [ (validate.rules).duration = { - lt: {seconds: 5}, + lt: {seconds: 60}, gte: {nanos: 1000000} }, (gogoproto.stdduration) = true From 821623c69d126e606646759940df831c1f6a0db1 Mon Sep 17 00:00:00 2001 From: Asra Ali Date: Tue, 27 Aug 2019 10:43:39 -0400 Subject: [PATCH 3/3] address comments Signed-off-by: Asra Ali --- api/envoy/config/bootstrap/v2/bootstrap.proto | 3 ++- test/server/server_fuzz_test.cc | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/api/envoy/config/bootstrap/v2/bootstrap.proto b/api/envoy/config/bootstrap/v2/bootstrap.proto index 567957efdc87..9e3d9fe1cdb1 100644 --- a/api/envoy/config/bootstrap/v2/bootstrap.proto +++ b/api/envoy/config/bootstrap/v2/bootstrap.proto @@ -99,9 +99,10 @@ message Bootstrap { // performance reasons Envoy latches counters and only flushes counters and // gauges at a periodic interval. If not specified the default is 5000ms (5 // seconds). + // Duration must be at least 1ms and at most 5 min. google.protobuf.Duration stats_flush_interval = 7 [ (validate.rules).duration = { - lt: {seconds: 60}, + lt: {seconds: 300}, gte: {nanos: 1000000} }, (gogoproto.stdduration) = true diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index 973527c7b05d..b47f1aed9622 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -63,14 +63,6 @@ class AllFeaturesHooks : public DefaultListenerHooks { }; DEFINE_PROTO_FUZZER(const envoy::config::bootstrap::v2::Bootstrap& input) { - try { - // Validate the input early. - TestUtility::validate(input); - } catch (const EnvoyException& ex) { - ENVOY_LOG_MISC(debug, "Controlled EnvoyException exit: {}", ex.what()); - return; - } - testing::NiceMock options; AllFeaturesHooks hooks; testing::NiceMock restart;