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

Fix #17462: Refactor component-updater URL overwrites #9933

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Aug 31, 2021

Resolves brave/brave-browser#17462

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Specified here: https://github.com/brave/internal/issues/802

@jumde jumde requested review from iefremov and a team as code owners August 31, 2021 22:39
@jumde jumde self-assigned this Aug 31, 2021
@jumde jumde force-pushed the component_updater_refactor branch 3 times, most recently from dedf0a7 to 2a7d689 Compare September 1, 2021 17:00
@jumde jumde requested a review from a team as a code owner September 1, 2021 17:00
test/BUILD.gn Outdated
@@ -146,6 +147,7 @@ test("brave_unit_tests") {
]

defines = brave_service_key_defines
defines += brave_updater_defines
Copy link
Collaborator

Choose a reason for hiding this comment

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

you shouldn't do this. brave_updater_defines and brave_service_key_defines should either go in a public config of the component updater target or go in //brave/build:compiler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!

@@ -11,6 +11,8 @@ static_library("browser") {
"switches.h",
]

configs += [ "//brave/common:updater_config" ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not correct, this should be automatically inherited as a public config or from build:compiler as specified below https://github.com/brave/brave-core/pull/9933/files#r700430714

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!

@@ -27,8 +27,8 @@
#include "base/task_runner_util.h"
#include "base/values.h"
#include "base/version.h"
#include "brave/components/brave_component_updater/browser/features.h"
#include "brave/components/brave_component_updater/browser/switches.h"
#include "brave/common/brave_features.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this change seems backwards, why would we move something component updater specific from components -> common? That creates a layering violation where none existed before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!

@jumde jumde force-pushed the component_updater_refactor branch 3 times, most recently from aa65ca2 to 923a127 Compare September 2, 2021 16:19
@jumde jumde requested a review from a team as a code owner September 2, 2021 16:19
@jumde jumde force-pushed the component_updater_refactor branch from 923a127 to 85ffaeb Compare September 2, 2021 18:07
@jumde jumde requested a review from a team as a code owner September 2, 2021 18:07
@jumde jumde force-pushed the component_updater_refactor branch 3 times, most recently from 83b9167 to 9cd313f Compare September 3, 2021 02:21
@jumde jumde added the CI/run-network-audit Run network-audit label Sep 3, 2021
@jumde jumde requested a review from bridiver September 3, 2021 02:24
@jumde jumde changed the title [WIP] Fix #17462: Refactor component-updater URL overwrites Fix #17462: Refactor component-updater URL overwrites Sep 3, 2021
@jumde jumde force-pushed the component_updater_refactor branch 3 times, most recently from 7e7c71f to 4cca4ed Compare September 3, 2021 19:07
namespace extension_urls {

GURL GetDefaultWebstoreUpdateUrl() {
return GURL(brave_component_updater::GetUpdateURLHost());
Copy link
Collaborator

Choose a reason for hiding this comment

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

this creates a dep on //brave/components/brave_component_updater for //extensions which does not currently exist and is not necessary to change the updater url. Subclass ChromeExtensionsClient and override GetWebstoreUpdateURL

@@ -19,6 +19,8 @@ class PrefService;

namespace brave_component_updater {

std::string GetUpdateURLHost();
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not a good place to put this, we should be able to have a dep for GetUpdateURLHost without including all of components/brave_component_updater/browser

@jumde jumde force-pushed the component_updater_refactor branch 2 times, most recently from 292f826 to 3163090 Compare September 9, 2021 17:57
@jumde jumde force-pushed the component_updater_refactor branch from 3163090 to 61fcb3c Compare September 14, 2021 21:25
@jumde jumde force-pushed the component_updater_refactor branch 5 times, most recently from bc61f08 to 804785b Compare September 24, 2021 20:58
@@ -86,6 +89,17 @@ const char kBraveOriginTrialsPublicKey[] =

const char kDummyUrl[] = "https://no-thanks.invalid";

std::string GetUpdateURLHost() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should belong to the anonymous namespace, together we some other vars above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!

@@ -165,6 +179,12 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitch(switches::kEnableDomDistiller);
command_line.AppendSwitch(switches::kNoPings);

auto update_url = GetUpdateURLHost();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather use std::string instead of auto, because it's not clear whether this is GURL or string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!


const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(brave_component_updater::kUseGoUpdateDev) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

command_line.h feature_list.h extensions/buildflags/buildflags.h are not used now, pls check other includes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!

@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "brave/browser/net/url_context.h"
#include "brave/common/network_constants.h"
#include "brave/components/brave_component_updater/browser/switches.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

component_updater_url_constants not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved!


namespace extensions {

class ChromeExtensionsClient : public ChromeExtensionsClient_ChromiumImpl {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not we add a fully-functioning BraveExtensionsClient and override only instantiation spot? @bridiver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

options, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);

for (const auto& flag : flags) {
if (flag.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it can't be empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved


void BraveExtensionsClient::InitializeWebStoreUrls(
base::CommandLine* command_line) {
webstore_update_url_ = GURL(ParseUpdateUrlHost(
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether there is a step somewhere on CI that validates that the URL is correct...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

npm run network-audit verifies the URL

@jumde jumde requested a review from iefremov September 27, 2021 17:16
@jumde jumde force-pushed the component_updater_refactor branch 2 times, most recently from d729bc4 to 76d21cd Compare September 27, 2021 17:57
@jumde jumde force-pushed the component_updater_refactor branch from 76d21cd to b3802c6 Compare September 27, 2021 21:39
@jumde jumde merged commit f69b13e into master Sep 28, 2021
@jumde jumde deleted the component_updater_refactor branch September 28, 2021 14:55
@jumde jumde added this to the 1.32.x - Nightly milestone Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-network-audit Run network-audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor component-updater code
3 participants