Commit 143fdbd3 authored by Eric Orth's avatar Eric Orth Committed by Commit Bot

Fix DNS.SB DoH entry

The server template never got updated on a previous format change, but
still managed to compile.  Add a validation in the constructor to ensure
only valid server templates are listed.  Also add a test to make sure
the list can be loaded without error (not completely necessary since
other tests load the list, but a specific test helps make it extra
obvious).

Bug: 1065338
Change-Id: Ie2b131a37bf7bd82c46747b5ab4e67d5b2f7eb7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153319
Commit-Queue: Eric Orth <ericorth@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Auto-Submit: Eric Orth <ericorth@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759803}
parent 7736202d
......@@ -34,7 +34,10 @@ source_set("public") {
source_set("tests") {
testonly = true
sources = [ "util_unittest.cc" ]
sources = [
"doh_provider_list_unittest.cc",
"util_unittest.cc",
]
deps = [
"//net",
......
......@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/no_destructor.h"
#include "net/dns/public/util.h"
namespace net {
......@@ -29,6 +30,10 @@ DohProviderEntry::DohProviderEntry(
privacy_policy(std::move(privacy_policy)),
display_globally(display_globally),
display_countries(std::move(display_countries)) {
DCHECK(!this->dns_over_https_template.empty());
DCHECK(dns_util::IsValidDohTemplate(this->dns_over_https_template,
nullptr /* server_method */));
DCHECK(!display_globally || this->display_countries.empty());
if (display_globally || !this->display_countries.empty()) {
DCHECK(!this->ui_name.empty());
......@@ -103,10 +108,9 @@ const std::vector<DohProviderEntry>& GetDohProviderList() {
"Dnssb", base::nullopt /* provider_id_for_histogram */,
{"185.222.222.222", "185.184.222.222", "2a09::", "2a09::1"},
{"dns.sb"} /* dns_over_tls_hostnames */,
{"https://doh.dns.sb/dns-query?no_ecs=true{&dns}",
false /* use_post */},
"" /* ui_name */, "" /* privacy_policy */,
false /* display_globally */, {} /* display_countries */),
"https://doh.dns.sb/dns-query?no_ecs=true{&dns}", "" /* ui_name */,
"" /* privacy_policy */, false /* display_globally */,
{} /* display_countries */),
DohProviderEntry("Google", DohProviderIdForHistogram::kGoogle,
{"8.8.8.8", "8.8.4.4", "2001:4860:4860::8888",
"2001:4860:4860::8844"},
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/dns/public/doh_provider_list.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
TEST(DohProviderListTest, GetDohProviderList) {
const std::vector<DohProviderEntry>& list = GetDohProviderList();
EXPECT_FALSE(list.empty());
}
} // namespace
} // namespace net
......@@ -51,9 +51,10 @@ bool IsValidDohTemplate(base::StringPiece server_template,
return false;
}
// If the template contains a dns variable, use GET, otherwise use POST.
DCHECK(server_method);
*server_method =
(vars_found.find("dns") == vars_found.end()) ? "POST" : "GET";
if (server_method) {
*server_method =
(vars_found.find("dns") == vars_found.end()) ? "POST" : "GET";
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment