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

Block ChromeMetadataSource network access #769

Merged
merged 1 commit into from
Oct 30, 2018
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/third_party/libaddressinput/chromium/chrome_metadata_source.cc b/third_party/libaddressinput/chromium/chrome_metadata_source.cc
index ffd583eea8eb..bcda8a02dc19 100644
--- a/third_party/libaddressinput/chromium/chrome_metadata_source.cc
+++ b/third_party/libaddressinput/chromium/chrome_metadata_source.cc
@@ -57,7 +57,7 @@ ChromeMetadataSource::Request::Request(
void ChromeMetadataSource::Download(const std::string& key,
const Callback& downloaded) {
pilgrim-brave marked this conversation as resolved.
Show resolved Hide resolved
GURL resource(validation_data_url_ + key);
- if (!resource.SchemeIsCryptographic()) {
+ if (1) { // feature disabled in Brave
downloaded(false, key, NULL);
return;
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ test("brave_unit_tests") {
"//brave/components/brave_shields/browser/ad_block_regional_service_unittest.cc",
"//brave/components/brave_webtorrent/browser/net/brave_torrent_redirect_network_delegate_helper_unittest.cc",
"//brave/components/gcm_driver/gcm_unittest.cc",
"//brave/third_party/libaddressinput/chromium/chrome_metadata_source_unittest.cc",
"//chrome/common/importer/mock_importer_bridge.cc",
"//chrome/common/importer/mock_importer_bridge.h",
"../browser/importer/chrome_profile_lock_unittest.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "third_party/libaddressinput/chromium/chrome_metadata_source.h"

#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/core/embedder/embedder.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

static const char kFakeUrl[] = "https://example.com";

class ChromeMetadataSourceTest : public testing::Test {
public:
ChromeMetadataSourceTest()
: test_shared_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_)) {
mojo::core::Init();
}
virtual ~ChromeMetadataSourceTest() {}

void Get() {
ChromeMetadataSource impl(std::string(), test_shared_loader_factory_);
std::unique_ptr<::i18n::addressinput::Source::Callback> callback(
::i18n::addressinput::BuildCallback(
this, &ChromeMetadataSourceTest::OnDownloaded));
impl.Get(kFakeUrl, *callback);
}

void OnDownloaded(bool success,
const std::string& url,
std::string* data) {
EXPECT_FALSE(success);
}

protected:
base::MessageLoop loop_;
network::TestURLLoaderFactory test_url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_;
};

TEST_F(ChromeMetadataSourceTest, NoFetch) {
bool network_access_occurred = false;
base::RunLoop loop;
test_url_loader_factory_.SetInterceptor(
base::BindLambdaForTesting([&](const network::ResourceRequest& request) {
network_access_occurred = true;
loop.Quit();
}));
Get();
loop.RunUntilIdle();
EXPECT_FALSE(network_access_occurred);
}

} // namespace autofill