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

Include component versions in webcompat reports #25688

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

vadimstruts
Copy link
Collaborator

@vadimstruts vadimstruts commented Sep 22, 2024

Resolves brave/brave-browser#35674

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • 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 wiki
    • npm run presubmit wiki, 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:

Make sure that Webcompat Report contains the component versions information.
Steps:

  1. Open Brave Shields pop up dialog
  2. Switch off Brave Shields if It is ON
  3. Click "Report broken site", then click "Submit"
  4. Go to the webcompat reporter dashboard and see the component versions information.

@vadimstruts vadimstruts force-pushed the 35674-include-component-versions-webcompat-reports branch 3 times, most recently from 9a6a930 to dc56223 Compare October 2, 2024 11:54
@vadimstruts vadimstruts marked this pull request as ready for review October 3, 2024 11:49
@vadimstruts vadimstruts requested review from a team as code owners October 3, 2024 11:49
@vadimstruts vadimstruts marked this pull request as draft October 3, 2024 20:11
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
@vadimstruts vadimstruts force-pushed the 35674-include-component-versions-webcompat-reports branch from ea63de7 to b54f416 Compare October 10, 2024 12:55
vadimstruts and others added 7 commits October 10, 2024 21:53
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: vadym <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
@vadimstruts vadimstruts marked this pull request as ready for review October 11, 2024 13:38
@vadimstruts vadimstruts requested a review from a team as a code owner October 11, 2024 13:38
@StephenHeaps StephenHeaps self-requested a review October 11, 2024 14:03
@@ -50,12 +52,14 @@ namespace {
constexpr char kUISourceHistogramName[] = "Brave.Webcompat.UISource";
constexpr int kMaxScreenshotPixelCount = 1280 * 720;

const std::string BoolToString(bool value) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const std::string BoolToString(bool value) {
std::string BoolToString(bool value) {

content::BrowserContext*
WebcompatReporterServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
Copy link
Member

Choose a reason for hiding this comment

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

pls use ProfileKeyedServiceFactory configured for incognito appropriately.

Copy link
Member

Choose a reason for hiding this comment

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

now that you have ProfileKeyedServiceFactory, you need to remove GetBrowserContextToUse override.

@@ -63,7 +63,8 @@ class WebcompatReporterDOMHandler : public content::WebUIMessageHandler {

raw_ptr<content::RenderWidgetHostView> render_widget_host_view_;
scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
std::unique_ptr<webcompat_reporter::WebcompatReportUploader> uploader_;
std::unique_ptr<webcompat_reporter::WebcompatReporterService>
reporter_service_;
Copy link
Member

Choose a reason for hiding this comment

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

is this variable used somehow or is it a leftover? It looks wrong, because you should never own a KeyedService.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was leftover


private:
raw_ptr<component_updater::ComponentUpdateService> component_update_service_;
raw_ptr<brave_shields::AdBlockService> adblock_service_;
Copy link
Member

Choose a reason for hiding this comment

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

const raw_ptr<...> both members.


// static
mojo::PendingRemote<mojom::WebcompatReporterHandler>
WebcompatReporterServiceFactory::GetForContext(
Copy link
Member

Choose a reason for hiding this comment

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

GetMojoReportHandlerForContext

format: "%@ (%@)",
AppInfo.appVersion,
AppInfo.buildNumber
),
Copy link
Member

Choose a reason for hiding this comment

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

channel is missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, channel has separate property: "channel": "developer"
mentioned code helps to combine version value. ex: "version": "1.73 (0)"

]

deps = [
":webcompat_reporter_mojom_wrappers",
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be a public_deps instead?

std::optional<std::vector<ComponentInfo>> GetComponentInfos() const override;

private:
raw_ptr<component_updater::ComponentUpdateService> component_update_service_;
Copy link
Member

Choose a reason for hiding this comment

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

const


std::optional<std::vector<std::string>>
WebcompatReporterServiceDelegateImpl::GetAdblockFilterListNames() const {
return std::nullopt;
Copy link
Member

Choose a reason for hiding this comment

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

is this accessible in some other way on iOS? If so, this should have a comment.

return std::nullopt;
}

return result;
Copy link
Member

Choose a reason for hiding this comment

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

seems like this exact code is duplicated. Pls create a base delegate impl that will be shared on iOS and desktop/android.

Signed-off-by: Vadym Struts <[email protected]>
Copy link
Contributor

The following commits were not verified:
f9ab08f (unsigned)

Signed-off-by: Vadym Struts <[email protected]>
public WebcompatReporterHandler getWebcompatReporterHandler(
ConnectionErrorHandler connectionErrorHandler) {
Profile profile = Utils.getProfile(false); // Always use regular profile
if (profile == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Utils.getProfile is marked as @NonNull and it tries to get the profile in several different ways, so I would not use the null check

Copy link
Contributor

@AlexeyBarabash AlexeyBarabash left a comment

Choose a reason for hiding this comment

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

Android Java code lgtm.

These imports look strange:

import org.chromium.chrome.browser.crypto_wallet.util.Utils;
at src/brave/android/java/org/chromium/chrome/browser/webcompat_reporter/WebcompatReporterServiceFactory.java

and

import org.chromium.chrome.browser.BraveRewardsHelper;
import org.chromium.chrome.browser.BraveRewardsNativeWorker;

at src/brave/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java

And this is an issue beyond the current PR, crypto_wallet.util.Utils and BraveRewardsHelper are widely used beyond rewards/wallet.

Follow-up issues:
brave/brave-browser#41689
brave/brave-browser#41690

auto service =
webcompat_reporter::WebcompatReporterServiceFactory::GetForBrowserState(
browserState);
if (!service) {
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 a mojo interface, not a keyed service.

I think the variable and the method name GetForBrowserState should be renamed accordingly to not confuse people.

content::BrowserContext*
WebcompatReporterServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
Copy link
Member

Choose a reason for hiding this comment

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

now that you have ProfileKeyedServiceFactory, you need to remove GetBrowserContextToUse override.

"//brave/components/brave_shields/core/common:mojom",
"//brave/components/brave_stats/browser",
"//brave/components/constants",
"//brave/components/version_info",
"//brave/components/webcompat_reporter/buildflags",
"//content/public/browser",
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 also do "-content" in components/webcompat_reporter/browser/DEPS.

if (!is_ios) {
deps += [
"//brave/components/brave_shields/content/browser",
"//chrome/test:test_support",
Copy link
Member

Choose a reason for hiding this comment

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

what is it for? you shouldn't have //chrome in components.

std::optional<std::string> brave_vpn_connected;
std::optional<std::string> details;
std::optional<std::string> contact;
std::optional<base::Value> ad_block_components;
Copy link
Member

Choose a reason for hiding this comment

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

you added a mojo structure that's just similar to this one. Do we really need to have both? Why not just use mojo structure everywhere from now on? Seems like the right thing to do.

Signed-off-by: Vadym Struts <[email protected]>
Copy link
Contributor

[puLL-Merge] - brave/brave-core@25688

Description

This PR introduces a new WebcompatReporter service for reporting web compatibility issues in the Brave browser. The changes span across multiple platforms (Android, iOS, and desktop) and include the implementation of a new mojo interface for handling webcompat reports.

Possible Issues

  1. The implementation differs slightly between platforms, which could lead to inconsistent behavior or maintenance challenges.
  2. The PR introduces a significant amount of new code, which may increase the complexity of the codebase and the potential for bugs.

Security Hotspots

  1. The WebcompatReporter service handles user-submitted data and screenshots, which could potentially contain sensitive information. Ensure proper sanitization and handling of this data.
  2. The service interacts with network operations to submit reports, which could be a vector for data leaks if not properly secured.
Changes

Changes

  1. Android:

    • Added WebcompatReporterServiceFactory.java to handle the creation of the WebcompatReporter service.
    • Modified BraveShieldsHandler.java to use the new WebcompatReporter service for submitting reports.
  2. iOS:

    • Added new files for WebcompatReporter service implementation, including WebcompatReporterServiceFactory and WebcompatReporterServiceDelegate.
    • Updated WebcompatReporter.swift to use the new service for report submission.
  3. Desktop/Common:

    • Added new files for WebcompatReporter service implementation, including webcompat_reporter_service.cc, webcompat_reporter_service.h, and related test files.
    • Created a new mojo interface webcompat_reporter.mojom for handling webcompat reports.
  4. Build System:

    • Updated various build files (GN) to include the new WebcompatReporter service components.
  5. Testing:

    • Added unit tests for the new WebcompatReporter service implementation.

Overall, this PR introduces a more unified and structured approach to handling webcompat reports across different platforms in the Brave browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include component versions in webcompat reports
3 participants