Skip to content

Commit

Permalink
runtime: deprecating consistent_header_validation (#38137)
Browse files Browse the repository at this point in the history
Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: inline
fixes #38038

Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk authored Jan 28, 2025
1 parent ecce678 commit dd2f3b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
3 changes: 3 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ bug_fixes:
removed_config_or_runtime:
# *Normally occurs at the end of the* :ref:`deprecation period <deprecated>`
- area: http
change: |
Removed runtime guard ``envoy.reloadable_features.consistent_header_validation`` and legacy code paths.
- area: http
change: |
Removed runtime guard ``envoy.reloadable_features.sanitize_http2_headers_without_nghttp2`` and legacy code paths.
Expand Down
17 changes: 4 additions & 13 deletions source/common/formatter/substitution_format_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,10 @@ SubstitutionFormatUtils::parseSubcommandHeaders(absl::string_view subcommand) {
absl::StrCat("More than 1 alternative header specified in token: ", subcommand));
}

if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.consistent_header_validation")) {
if (!Http::HeaderUtility::headerNameIsValid(absl::AsciiStrToLower(main_header)) ||
!Http::HeaderUtility::headerNameIsValid(absl::AsciiStrToLower(alternative_header))) {
return absl::InvalidArgumentError(
"Invalid header configuration. Format string contains invalid characters.");
}
} else {
// The main and alternative header should not contain invalid characters {NUL, LR, CF}.
if (!Envoy::Http::validHeaderString(main_header) ||
!Envoy::Http::validHeaderString(alternative_header)) {
return absl::InvalidArgumentError(
"Invalid header configuration. Format string contains null or newline.");
}
if (!Http::HeaderUtility::headerNameIsValid(absl::AsciiStrToLower(main_header)) ||
!Http::HeaderUtility::headerNameIsValid(absl::AsciiStrToLower(alternative_header))) {
return absl::InvalidArgumentError(
"Invalid header configuration. Format string contains invalid characters.");
}
return {std::make_pair(main_header, alternative_header)};
}
Expand Down
1 change: 0 additions & 1 deletion source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RUNTIME_GUARD(envoy_reloadable_features_async_host_selection);
RUNTIME_GUARD(envoy_reloadable_features_avoid_dfp_cluster_removal_on_cds_update);
RUNTIME_GUARD(envoy_reloadable_features_boolean_to_string_fix);
RUNTIME_GUARD(envoy_reloadable_features_check_switch_protocol_websocket_handshake);
RUNTIME_GUARD(envoy_reloadable_features_consistent_header_validation);
RUNTIME_GUARD(envoy_reloadable_features_dfp_fail_on_empty_host_header);
RUNTIME_GUARD(envoy_reloadable_features_disallow_quic_client_udp_mmsg);
RUNTIME_GUARD(envoy_reloadable_features_dns_nodata_noname_is_success);
Expand Down
13 changes: 3 additions & 10 deletions source/extensions/filters/common/expr/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,9 @@ template <class T> class HeadersWrapper : public google::api::expr::runtime::Cel
return {};
}
auto str = std::string(key.StringOrDie().value());
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.consistent_header_validation")) {
if (!Http::HeaderUtility::headerNameIsValid(str)) {
// Reject key if it is an invalid header string
return {};
}
} else {
if (!::Envoy::Http::validHeaderString(str)) {
// Reject key if it is an invalid header string
return {};
}
if (!Http::HeaderUtility::headerNameIsValid(str)) {
// Reject key if it is an invalid header string
return {};
}
return convertHeaderEntry(arena_, ::Envoy::Http::HeaderUtility::getAllOfHeaderAsString(
*value_, ::Envoy::Http::LowerCaseString(str)));
Expand Down
11 changes: 0 additions & 11 deletions test/extensions/filters/common/expr/context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ TEST(Context, InvalidRequest) {
EXPECT_FALSE(header.has_value());
}

TEST(Context, InvalidRequestLegacy) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.consistent_header_validation", "false"}});

Http::TestRequestHeaderMapImpl header_map{{"referer", "dogs.com"}};
Protobuf::Arena arena;
HeadersWrapper<Http::RequestHeaderMap> headers(arena, &header_map);
auto header = headers[CelValue::CreateStringView("referer\n")];
EXPECT_FALSE(header.has_value());
}

TEST(Context, RequestAttributes) {
NiceMock<StreamInfo::MockStreamInfo> info;
NiceMock<StreamInfo::MockStreamInfo> empty_info;
Expand Down

0 comments on commit dd2f3b9

Please sign in to comment.