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

Do not allow wildcard content settings entries for "shields enabled" #14031

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

petemill
Copy link
Member

@petemill petemill commented Jul 1, 2022

Also remove any existing entries that may mistakingly be there

Resolves brave/brave-browser#23214

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
  • 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, 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:

Add an entry for shields down for any site
Close Brave and open Default/Preferences file
in braveShield section, change the site.com,* to *,*
Open and close Brave
*,* entry for braveShield should be removed

We don't current know how that entry gets created in normal use so there is no test plan for preventing it, but the code no longer allows default entries to be added for shields

@petemill petemill self-assigned this Jul 1, 2022
@petemill petemill force-pushed the shields-enabled-migrate-wildcard-content-setting branch from 6880632 to 0cc33c2 Compare July 1, 2022 23:12
@@ -168,6 +172,17 @@ void BravePrefProvider::MigrateShieldsSettings(bool incognito) {
MigrateShieldsSettingsV2ToV3();
}

void BravePrefProvider::EnsureNoWildcardEntries() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems you also need to add one 'if' in SetWebsiteSettingInternal. You can check it by clicking on 'Reset Settings'

Copy link
Collaborator

Choose a reason for hiding this comment

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

one if for what? Not sure what Reset Settings has to do with this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

everything seems to be working correctly, I'm not understanding what the issue is here

@bridiver bridiver force-pushed the shields-enabled-migrate-wildcard-content-setting branch from 174a4b3 to 4b02a84 Compare July 4, 2022 17:43
@bridiver bridiver merged commit 82a983c into master Jul 6, 2022
@bridiver bridiver deleted the shields-enabled-migrate-wildcard-content-setting branch July 6, 2022 18:52
@bridiver bridiver added this to the 1.43.x - Nightly milestone Jul 6, 2022
@LaurenWags
Copy link
Member

Verified using:

Brave | 1.43.6 Chromium: 103.0.5060.114 (Official Build) nightly (x86_64)
-- | --
Revision | a1c2360c5b02a6d4d6ab33796ad8a268a6128226-refs/branch-heads/5060@{#1124}
OS | macOS Version 12.4 (Build 21F79)

Also tried the following scenario:

  • Installed 1.41.94
  • Visited several sites and modified shield configurations (some up, some down, some with various changes to individual settings like Aggressively Block Ads, Aggressively Block Fingerprinting, etc)
  • Closed 1.41.94
  • Modified Preferences file as per Do not allow wildcard content settings entries for "shields enabled" #14031 (comment) for just one of the entries
  • Relaunched 1.41.94 and experienced the issue
  • "Upgraded" (renamed profile to Nightly) and launched with 1.43.6
  • Confirmed new sites visited did not reproduce the issue and shields were up for them
  • Confirmed previously set shield settings (up, down, modifications to individual settings) were now showing as expected
  • Closed Nightly and viewed the Preferences file
  • Confirmed the wildcard *,* was removed from braveShield section of Preferences file

brave-builds pushed a commit that referenced this pull request Jul 7, 2022
bridiver added a commit that referenced this pull request Jul 7, 2022
…-content-setting

Do not allow wildcard content settings entries for "shields enabled"
@kjozwiak
Copy link
Member

Using the STR/Cases outlined via #14031 (comment), reproduced the original issue using 1.41.94 Chromium: 103.0.5060.114. Once *,* was added into the Preference file, Brave Shields stopped working and was disabled for every website.

Verification PASSED on Win 11 x64 using the following build(s):

Brave | 1.43.9 Chromium: 103.0.5060.114 (Official Build) nightly (64-bit) 
--- | ---
Revision | a1c2360c5b02a6d4d6ab33796ad8a268a6128226-refs/branch-heads/5060@{#1124}
OS | Windows 11 Version 21H2 (Build 22000.739)

Test Case #1 - Basic/Simple check using STR/Cases from #14031 (comment)

  • installed 1.43.9 Chromium: 103.0.5060.114
  • visited https://videocardz.com
  • closed Brave and opened AppData\Local\BraveSoftware\Brave-Browser-Nightly\User Data\Default\Preferences
  • changed "videocardz.com,*" -> "*,*" via the braveShields section
  • relaunched the browser and ensured that Brave shields was enabled under https://videocardz.com
  • visited several other websites and ensured that Brave shields was still enabled

Test Case #2 - Upgrading (renaming the affected profile to Brave-Browser-Nightly)

  • installed 1.41.94 Chromium: 103.0.5060.114
  • visited https://videocardz.com and several other websites
  • closed Brave and opened AppData\Local\BraveSoftware\Brave-Browser\User Data\Default\Preferences
  • changed "videocardz.com,*" -> "*,*" via the braveShields section
  • re-launched the browser and reproduced the issue re: shields being disabled
  • opened ~10 websites and closed the browser (each website had shields disabled due to the issue)
  • renamed the Brave-Browser profile to Brave-Browser-Nightly
  • launched using 1.43.9 Chromium: 103.0.5060.114
  • ensured that Brave shields was enabled for all the opened tabs including https://videocardz.com
  • ensured "*,*" was removed from AppData\Local\BraveSoftware\Brave-Browser-Nightly\User Data\Default\Preferences

Test Case #3 - Clean Upgrading (no issue present when upgrading)

Quick check to ensure that shields settings are being retained on profiles that are not experiencing the issue

  • installed 1.41.94 Chromium: 103.0.5060.114
  • visited several websites and changed their Brave shields settings (Settings that were changed/modified):
    • Aggressively block trackers & ads, Block trackers & ads, Allow all trackers & ads
    • Upgrade connections to HTTPS, Block Scripts
    • Aggressively block fingerprinting, Block fingerprinting, Allow fingerprinting
    • Block all cookies, Block cross-site cookies, Allow all cookies
  • renamed the Brave-Browser profile to Brave-Browser-Nightly
  • launched using 1.43.9 Chromium: 103.0.5060.114
  • ensured that all the shields settings were retained without any issues

Test Case #4 - Upgrading affected profile

  • installed 1.41.94 Chromium: 103.0.5060.114
  • visited several websites and changed their Brave shields settings (Settings that were changed/modified):
    • Aggressively block trackers & ads, Block trackers & ads, Allow all trackers & ads
    • Upgrade connections to HTTPS, Block Scripts
    • Aggressively block fingerprinting, Block fingerprinting, Allow fingerprinting
    • Block all cookies, Block cross-site cookies, Allow all cookies
  • closed Brave and opened AppData\Local\BraveSoftware\Brave-Browser\User Data\Default\Preferences
  • changed one of the settings to "*,*" via the braveShields section
  • launched the browser and verified the that issue was reproducible
  • renamed the Brave-Browser profile to Brave-Browser-Nightly
  • launched using 1.43.9 Chromium: 103.0.5060.114
  • ensured that all the shields settings were retained without any issues and the issue wasn't occurring

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.

default shield-on option lost since a recent update
5 participants