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

Ipv6 host validation support #3250

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ SigningFutureOutcome sign(std::shared_ptr<HttpRequest> httpRequest, const AwsCre
const bool m_includeSha256HashHeader{true};
const bool m_urlEscape{true};
const Aws::Set<Aws::String> m_unsignedHeaders{USER_AGENT,X_AMZN_TRACE_ID};
const Aws::Crt::Auth::SignatureType m_signatureType{Aws::Crt::Auth::SignatureType::HttpRequestViaQueryParams};
const Aws::Crt::Auth::SignatureType m_signatureType{Aws::Crt::Auth::SignatureType::HttpRequestViaHeaders};
std::condition_variable m_cv;
std::mutex m_mutex;
};
Expand Down
4 changes: 3 additions & 1 deletion src/aws-cpp-sdk-core/source/utils/DNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <aws/core/utils/DNS.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/common/host_utils.h>
#include <aws/crt/DnsUtils.h>

namespace Aws
{
Expand Down Expand Up @@ -49,7 +51,7 @@ namespace Aws
return false;
}

return !std::any_of(labels.begin(), labels.end(), [](const Aws::String& label){ return !IsValidDnsLabel(label); });
return !std::any_of(labels.begin(), labels.end(), [](const Aws::String& label){ return !IsValidDnsLabel(label); }) || Aws::Crt::DnsUtils::IsValidIpV6(host.c_str(), false);
}
}
}
26 changes: 26 additions & 0 deletions tests/aws-cpp-sdk-core-tests/utils/DNSTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,29 @@ TEST_F(DnsTest, TestHost)
ASSERT_FALSE(IsValidHost("0123456789012345678901234567890123456789012345678901234567890123.com")); // 64 characters

}

TEST_F(DnsTest, TestIPV6)
{
Aws::Vector< std::pair<Aws::String, bool> > inputs = {
{"2001:0db8:85a3:0000:0000:8a2e:0370:7334", true},
{"2001:DB8:85A3::8A2E:370:7334", true},
{"::ffff", true},
{"::", true},
{"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",true},
{"2001:db8:85a3:0:0:8a2e:370:7334",true},
{"2001:db8:85a3:0000:0000:8a2e:0370:7334:1", false},
{"2001:db8:85a3:0000", false},
{"2001:0db8:85a3:0000:0000:8a2e:0370:7334:", false},
{"g001:0db8:85a3:0000:0000:8a2e:0370:7334", false},
{"2001:db8::85a3::1", false},
{":2001:db8:85a3:0000:0000:8a2e:0370:7334", false},
{"0:0:0:0:0:0:0:0", true},
{"2001:db8::", true}
};

for(auto t : inputs)
{
ASSERT_EQ(IsValidHost(t.first), t.second);
}

}
Loading