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

1.31 backport: Relax recent SNI restrictions (#36950) #36997

Merged
merged 2 commits into from
Nov 7, 2024
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
4 changes: 4 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ minor_behavior_changes:

bug_fixes:
# *Changes expected to improve the state of the world and are unlikely to have negative effects*
- area: access_log
change: |
Relaxed the restriction on SNI logging to allow the ``_`` character, even if
``envoy.reloadable_features.sanitize_sni_in_access_log`` is enabled.

removed_config_or_runtime:
# *Normally occurs at the end of the* :ref:`deprecation period <deprecated>`
Expand Down
3 changes: 2 additions & 1 deletion source/common/common/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ std::string StringUtil::sanitizeInvalidHostname(const absl::string_view source)
std::string ret_str = std::string(source);
bool sanitized = false;
for (size_t i = 0; i < ret_str.size(); ++i) {
if (absl::ascii_isalnum(ret_str[i]) || ret_str[i] == '.' || ret_str[i] == '-') {
if (absl::ascii_isalnum(ret_str[i]) || ret_str[i] == '.' || ret_str[i] == '-' ||
ret_str[i] == '_') {
continue;
}
sanitized = true;
Expand Down
4 changes: 2 additions & 2 deletions source/common/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ class StringUtil {

/**
* Sanitize host name strings for logging purposes. Replace invalid hostname characters (anything
* that's not alphanumeric, hyphen, or period) with underscore. The sanitized string is not a
* valid host name.
* that's not alphanumeric, hyphen, or period) with underscore. The sanitized string
* is not a valid host name.
* @param source supplies the string to sanitize.
* @return sanitized string.
*/
Expand Down
9 changes: 9 additions & 0 deletions test/common/formatter/substitution_formatter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,15 @@ TEST(SubstitutionFormatterTest, streamInfoFormatter) {
ProtoEq(ValueUtil::nullValue()));
}

{
StreamInfoFormatter upstream_format("REQUESTED_SERVER_NAME");
std::string requested_server_name = "outbound_.8080_._.example.com";
stream_info.downstream_connection_info_provider_->setRequestedServerName(requested_server_name);
EXPECT_EQ("outbound_.8080_._.example.com", upstream_format.formatWithContext({}, stream_info));
EXPECT_THAT(upstream_format.formatValueWithContext({}, stream_info),
ProtoEq(ValueUtil::stringValue("outbound_.8080_._.example.com")));
}

{
StreamInfoFormatter upstream_format("REQUESTED_SERVER_NAME");
std::string requested_server_name = "stub-server";
Expand Down