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

Use extension for data file updates #76

Merged
merged 11 commits into from
Apr 28, 2018
Merged

Use extension for data file updates #76

merged 11 commits into from
Apr 28, 2018

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Mar 29, 2018

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions

@@ -0,0 +1,150 @@
// Copyright 2014 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MPL-2.0 headers for new files

using component_updater::ComponentUpdateService;

namespace {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra newline

#include "brave/components/brave_shields/browser/base_brave_shields_service.h"
#include "content/public/common/resource_type.h"

class AdBlockClient;
class AdBlockServiceTest;

const uint8_t kAdBlockPlusUpdaterPublicKey[294] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls move this directly to an encoded string.

@simonhong
Copy link
Member

IIUC, src/brave/components and src/components are equivalent layer.
If so, accessing directly to chrome layer from components layer is layer violation.

@emerick
Copy link
Contributor Author

emerick commented Mar 30, 2018

@simonhong Thanks for pointing that out, I didn't realize that. I assume you're referring to my use of g_browser_process? I take it the appropriate way to do this would be to pass the browser process in when constructing the ad block service? It seems that several files in that directory are breaking this rule, unfortunately.

@simonhong
Copy link
Member

simonhong commented Mar 30, 2018

Referring src/brave/browser is same.
I think src/brave/browser and src/chrome/browser are same layer, too.

brave/components/brave_shields/browser has dependency to chrome/common.
I think this dependency should be removed, too if we want to use src/brave/components as src/components.

We should add dependency check rules to modules that we created.

@bbondy
Copy link
Member

bbondy commented Mar 31, 2018

I always viewed src/brave/* as equivalent to something that would be in src/chrome/* and then browser files can use browser and common chrome files. Renderer can use renderer and common files.

void OnComponentReady(
const std::string& extension_id,
const base::FilePath& install_dir);

friend class ::AdBlockServiceTest;
static GURL g_ad_block_url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just get rid of this g_ad_block_url now

}
// scoped_refptr<base::SequencedTaskRunner> GetTaskRunner() {
// return task_runner_;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by the browser tests but those will need to be updated anyway. You can just remove the code for it.

bool initialized_;
std::unique_ptr<DATFileWebRequest> web_request_;
std::mutex init_mutex_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you'll need the init_mutex

@simonhong
Copy link
Member

@bbondy If we think src/brave and src/chrome as a equivalent layer, where is the proper place if we want to add new modules to content layer or components layer?

@bbondy
Copy link
Member

bbondy commented Apr 1, 2018

I think we should use src/chromium_src for that. It is special and has include path equivalent to src. It also supports overwriting .cc files if they happen to match the equivalent files in src, which should very infrequently be used, but can be useful for cases like a config only file.

@bbondy
Copy link
Member

bbondy commented Apr 2, 2018

For anything outside of this, just post a new issue and we can start to move thing that apply to chromium_src if others agree.

"VwIDAQAB";

const std::string kAdBlockPlusUpdaterId("cffkpbalmllkdoenhmdmpbkajipdjfam");
const std::string kAdBlockPlusUpdaterName("AdBlock Plus Updater");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter syntax that this library uses is AdBlockPlus Filter syntax, but the actual library it uses has nothing to do with AdBlockPlus so please call this:
Brave Ad Block Updater

static void SetAdBlockURLForTest(const GURL& url);
void OnComponentRegistered(const std::string& extension_id);
void OnComponentReady(const std::string& extension_id,
const base::FilePath& install_dir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make these overrides here, and in the base virtual.

base::Unretained(this), kAdBlockPlusUpdaterId);
brave::RegisterComponent(g_browser_process->component_updater(),
kAdBlockPlusUpdaterName, kAdBlockPlusUpdaterBase64PublicKey,
registered_callback, ready_callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls handle all of this in the base, and then pass kAdBlockPlusUpdaterName, kAdBlockPlusUpdaterBase64PublicKey, and kAdBlockPlusUpdaterId to the base class.

brave::RegisterComponent(g_browser_process->component_updater(),
kHTTPSEverywhereUpdaterName, kHTTPSEverywhereUpdaterBase64PublicKey,
registered_callback, ready_callback);
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per above, this will be removed after that change.

}

bool HTTPSEverywhereService::GetHTTPSURL(
const GURL* url, const uint64_t& request_identifier,
std::string& new_url) {
base::AssertBlockingAllowed();
if (!IsInitialized() || url->scheme() == "https") {
if (!IsInitialized() || url->scheme() == url::kHttpsScheme) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

brave::RegisterComponent(g_browser_process->component_updater(),
kTrackingProtectionUpdaterName, kTrackingProtectionUpdaterBase64PublicKey,
registered_callback, ready_callback);
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above, this will be common code.

@@ -0,0 +1,7 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls ensure that the keys here are for a different public key than we use in prod. You might need a hack similar to SetAdBlockURLForTest for the tests.

"manifest_version": 2,
"name": "HTTPS Everywhere updater",
"version": "1.0.0"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind also doing a test for tracking-protection at this point? Ask Serg if he can give you a test case example that will be blocked by tracking protection library but not the ad-block library.

@bbondy
Copy link
Member

bbondy commented Apr 16, 2018

Great work so far, looks very close.

@emerick emerick changed the title WIP: Use extension for data file updates Use extension for data file updates Apr 17, 2018
@emerick emerick force-pushed the dat-file-extension branch 2 times, most recently from 238b201 to 20df890 Compare April 26, 2018 16:12
@@ -12,6 +14,6 @@ const char kTwitterReferrer[] = "https://twitter.com/*";
const char kTwitterRedirectURL[] = "https://mobile.twitter.com/i/nojs_router*";

const char kCookieHeader[] = "Cookie";
// Intentional mispelling on referrer to match HTTP spec
// Intentional misspelling on referrer to match HTTP spec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 LOL! This is too good.

"eclbkhjphkhalklhipiicaldjbnhdfkc");

const std::string kTrackingProtectionComponentTestBase64PublicKey =
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsleoSxQ3DN+6xym2P1uX"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the test manifest is still referencing the non-test public key.

@emerick emerick force-pushed the dat-file-extension branch from 20df890 to 52c516f Compare April 27, 2018 18:39
"importer/brave_external_process_importer_client.cc",
"importer/brave_external_process_importer_client.h",
"importer/brave_external_process_importer_host.cc",
"importer/brave_external_process_importer_host.h",
"importer/brave_in_process_importer_bridge.cc",
"importer/brave_in_process_importer_bridge.h",
"importer/brave_profile_writer.cc",
"importer/brave_profile_writer.h",
"importer/brave_profile_writer.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing commas are OK for future ref in .gn files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not just ok, trailing commas are preferred

@bbondy
Copy link
Member

bbondy commented Apr 28, 2018

🎉

@bbondy bbondy merged commit 2eac229 into master Apr 28, 2018
NejcZdovc added a commit that referenced this pull request Dec 10, 2018
bbondy pushed a commit that referenced this pull request Feb 18, 2019
Package updates to fix security issues
fmarier pushed a commit that referenced this pull request Oct 29, 2019
symbol_level is set to 1 for x86 Linux
petemill pushed a commit that referenced this pull request Jul 27, 2020
symbol_level is set to 1 for x86 Linux
petemill pushed a commit that referenced this pull request Jul 28, 2020
symbol_level is set to 1 for x86 Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants