Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fuzz] fix h1 end to end fuzz test issue #15318

Merged
merged 4 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions source/common/filesystem/posix/filesystem_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ bool InstanceImplPosix::illegalPath(const std::string& path) {
absl::StartsWith(canonical_path.rc_, "/proc")) {
return true;
}
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
// Allow temporary files in OSS-Fuzz to prevent failures running (h1/h2)_capture_fuzz_test.
// Ideally this would be TestEnvironment::temporaryPath() but this avoids depending on test
// libraries.
if (absl::StartsWith(canonical_path.rc_, "/mnt")) {
return true;
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that the fuzzer code won't be able to access files in /mnt?
Could this impact fuzz tests that may need to access external files under the /mnt directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OMG thanks for pointing that out. The fix was meant to do the opposite.

return false;
}

Expand Down
7 changes: 4 additions & 3 deletions test/integration/h1_capture_direct_response_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ namespace Envoy {

void H1FuzzIntegrationTest::initialize() {
const std::string body = "Response body";
const std::string file_path = TestEnvironment::writeStringToFileForTest("test_envoy", body);
const std::string prefix("/");
const Http::Code status(Http::Code::OK);
config_helper_.addConfigModifier(
[&file_path, &prefix](
[&body, &prefix](
envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void {
auto* route_config = hcm.mutable_route_config();
Expand All @@ -19,7 +18,9 @@ void H1FuzzIntegrationTest::initialize() {
hcm.mutable_route_config()->mutable_virtual_hosts(0)->mutable_routes(0);
default_route->mutable_match()->set_prefix(prefix);
default_route->mutable_direct_response()->set_status(static_cast<uint32_t>(status));
default_route->mutable_direct_response()->mutable_body()->set_filename(file_path);
// Use inline bytes rather than a filename to avoid using a path that may look illegal to
// Envoy.
default_route->mutable_direct_response()->mutable_body()->set_inline_bytes(body);
// adding headers to the default route
auto* header_value_option = route_config->mutable_response_headers_to_add()->Add();
header_value_option->mutable_header()->set_value("direct-response-enabled");
Expand Down

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.