Skip to content

Commit

Permalink
[fuzz] Create ext authz http fuzzer with dynamic metadata (envoyproxy…
Browse files Browse the repository at this point in the history
…#15520)

* Create ext authz http fuzzer with dynamic metadata

Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa authored Dec 7, 2021
1 parent 2361a93 commit aa4058f
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ build:asan --copt -O1
build:asan --copt -fno-optimize-sibling-calls

# Clang ASAN/UBSAN
build:clang-asan --config=clang
build:clang-asan --config=asan
build:clang-asan --linkopt -fuse-ld=lld
build:clang-asan --linkopt --rtlib=compiler-rt
Expand Down Expand Up @@ -322,7 +323,7 @@ build:plain-fuzzer --copt=-fsanitize=fuzzer-no-link
build:plain-fuzzer --linkopt=-fsanitize=fuzzer-no-link

build:asan-fuzzer --config=plain-fuzzer
build:asan-fuzzer --config=asan
build:asan-fuzzer --config=clang-asan
build:asan-fuzzer --copt=-fno-omit-frame-pointer
# Remove UBSAN halt_on_error to avoid crashing on protobuf errors.
build:asan-fuzzer --test_env=UBSAN_OPTIONS=print_stacktrace=1
Expand Down
30 changes: 30 additions & 0 deletions test/extensions/filters/http/ext_authz/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_fuzz_test",
"envoy_package",
"envoy_proto_library",
)
load(
"//test/extensions:extensions_build_system.bzl",
Expand Down Expand Up @@ -77,3 +79,31 @@ envoy_extension_cc_test(
"@envoy_api//envoy/service/auth/v3:pkg_cc_proto",
],
)

envoy_proto_library(
name = "ext_authz_fuzz_proto",
srcs = ["ext_authz_fuzz.proto"],
deps = [
"//test/fuzz:common_proto",
"@envoy_api//envoy/config/core/v3:pkg",
"@envoy_api//envoy/extensions/filters/http/ext_authz/v3:pkg",
],
)

envoy_cc_fuzz_test(
name = "ext_authz_fuzz_test",
srcs = ["ext_authz_fuzz_test.cc"],
corpus = "ext_authz_corpus",
deps = [
":ext_authz_fuzz_proto_cc_proto",
"//source/common/http:context_lib",
"//source/common/network:address_lib",
"//source/extensions/filters/http/ext_authz",
"//test/extensions/filters/common/ext_authz:ext_authz_mocks",
"//test/extensions/filters/http/common/fuzz:http_filter_fuzzer_lib",
"//test/mocks/http:http_mocks",
"//test/mocks/network:network_mocks",
"//test/mocks/runtime:runtime_mocks",
"@envoy_api//envoy/extensions/filters/http/ext_authz/v3:pkg_cc_proto",
],
)
33 changes: 33 additions & 0 deletions test/extensions/filters/http/ext_authz/ext_authz_corpus/bad_config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions test/extensions/filters/http/ext_authz/ext_authz_fuzz.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";
package envoy.extensions.filters.http.ext_authz;

import "envoy/extensions/filters/http/ext_authz/v3/ext_authz.proto";
import "test/fuzz/common.proto";
import "envoy/config/core/v3/base.proto";
import "google/protobuf/empty.proto";
import "validate/validate.proto";

// We only fuzz a single request per iteration.
message ExtAuthzTestCase {
enum AuthResult {
// Possible results for a check call. Taken from
// https://github.com/envoyproxy/envoy/blob/945b5833f094dee31d2971cee8d40553bb0fe714/source/extensions/filters/common/ext_authz/ext_authz.h#L65
OK = 0;
DENIED = 1;
ERROR = 2;
}

envoy.extensions.filters.http.ext_authz.v3.ExtAuthz config = 1
[(validate.rules).message = {required: true}];
// HTTP request data.
test.fuzz.HttpData request_data = 2 [(validate.rules).message = {required: true}];
// Set default auth check result.
AuthResult result = 3;
// Filter metadata.
envoy.config.core.v3.Metadata filter_metadata = 4;
// TODO: Add headers and data to ExtAuthz::Response and check that the request headers and data
// were updated.
}
Loading

0 comments on commit aa4058f

Please sign in to comment.