Closed
Bug 1484876
Opened 7 years ago
Closed 7 years ago
Refactor the code responsible for checking whether the top window URI is on the content blocking allow list into AntiTrackingCommon
Categories
(Firefox :: Protections UI, enhancement, P2)
Firefox
Protections UI
Tracking
()
RESOLVED
FIXED
Firefox 63
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
Attachments
(5 files, 1 obsolete file)
3.35 KB,
patch
|
johannh
:
review+
|
Details | Diff | Splinter Review |
4.08 KB,
patch
|
francois
:
review+
|
Details | Diff | Splinter Review |
4.77 KB,
patch
|
johannh
:
review+
|
Details | Diff | Splinter Review |
8.57 KB,
patch
|
johannh
:
review+
|
Details | Diff | Splinter Review |
8.63 KB,
patch
|
francois
:
review+
|
Details | Diff | Splinter Review |
This is the required refactoring for bug 1484788.
Assignee | ||
Comment 1•7 years ago
|
||
Session permissions aren't persisted to disk, so we can easily add a
new permission type and only store session permissions in the permission
manager database, and drop the in-memory allow list that this service
maintains.
This has the advantage that the permission manager already has the IPC
machinery to make this information available in the content processes,
so we can also check this allow list in the content process.
Attachment #9002632 -
Flags: review?(jhofmann)
Assignee | ||
Comment 2•7 years ago
|
||
Attachment #9002633 -
Flags: review?(francois)
Assignee | ||
Comment 3•7 years ago
|
||
Attachment #9002634 -
Flags: review?(francois)
Comment 5•7 years ago
|
||
Comment on attachment 9002632 [details] [diff] [review]
Part 1: Refactor the PrivateBrowsingTrackingProtectionWhitelist service on top of the permission manager
Review of attachment 9002632 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks!
Attachment #9002632 -
Flags: review?(jhofmann) → review+
Assignee | ||
Comment 6•7 years ago
|
||
Attachment #9002761 -
Flags: review?(jhofmann)
Assignee | ||
Comment 7•7 years ago
|
||
Attachment #9002762 -
Flags: review?(jhofmann)
Updated•7 years ago
|
Priority: -- → P2
Updated•7 years ago
|
Attachment #9002633 -
Flags: review?(francois) → review+
Comment 8•7 years ago
|
||
Comment on attachment 9002634 [details] [diff] [review]
Part 3: Refactor the code responsible for checking whether the top window URI is on the content blocking allow list into AntiTrackingCommon
Review of attachment 9002634 [details] [diff] [review]:
-----------------------------------------------------------------
Looks fine, but I'd like to double-check any changes to the noisy warning to ensure we don't change the behaviour.
::: netwerk/base/nsChannelClassifier.cpp
@@ -469,5 @@
> - if (permissions == nsIPermissionManager::ALLOW_ACTION) {
> - if (LOG_ENABLED()) {
> - nsCString chanSpec = chanURI->GetSpecOrDefault();
> - chanSpec.Truncate(std::min(chanSpec.Length(), sMaxSpecLength));
> - LOG(("nsChannelClassifier[%p]: User override on channel[%p] (%s) for %s (%s)",
It would be good to preserve the type of override (normal v. pb) in the log message. It has been useful in the past in debugging some bad behaviours.
::: toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ +530,5 @@
> + // allowlisting to depend on scheme.
> + nsresult rv = NS_ERROR_FAILURE;
> + nsCOMPtr<nsIURL> url = do_QueryInterface(aTopWinURI, &rv);
> + if (NS_FAILED(rv)) {
> + return rv; // normal for some loads, no need to print a warning
This will now print a warning due to the NS_ENSURE_SUCCESS() after AntiTrackingCommon::IsOnContentBlockingAllowList() in nsChannelClassifier::ShouldEnableTrackingProtectionInternal().
It used to be a very noisy warning (bug 1205138).
Attachment #9002634 -
Flags: review?(francois) → review-
Assignee | ||
Comment 9•7 years ago
|
||
(In reply to François Marier [:francois] from comment #8)
> ::: netwerk/base/nsChannelClassifier.cpp
> @@ -469,5 @@
> > - if (permissions == nsIPermissionManager::ALLOW_ACTION) {
> > - if (LOG_ENABLED()) {
> > - nsCString chanSpec = chanURI->GetSpecOrDefault();
> > - chanSpec.Truncate(std::min(chanSpec.Length(), sMaxSpecLength));
> > - LOG(("nsChannelClassifier[%p]: User override on channel[%p] (%s) for %s (%s)",
>
> It would be good to preserve the type of override (normal v. pb) in the log
> message. It has been useful in the past in debugging some bad behaviours.
I couldn't figure out a way to do that without leaking the implementation detail out of AntiTrackingCommon.cpp which I didn't want to do, but earlier today I added logging to that file as well, so now it's easy to log this information.
> ::: toolkit/components/antitracking/AntiTrackingCommon.cpp
> @@ +530,5 @@
> > + // allowlisting to depend on scheme.
> > + nsresult rv = NS_ERROR_FAILURE;
> > + nsCOMPtr<nsIURL> url = do_QueryInterface(aTopWinURI, &rv);
> > + if (NS_FAILED(rv)) {
> > + return rv; // normal for some loads, no need to print a warning
>
> This will now print a warning due to the NS_ENSURE_SUCCESS() after
> AntiTrackingCommon::IsOnContentBlockingAllowList() in
> nsChannelClassifier::ShouldEnableTrackingProtectionInternal().
>
> It used to be a very noisy warning (bug 1205138).
Nice catch!
Assignee | ||
Comment 10•7 years ago
|
||
Attachment #9002634 -
Attachment is obsolete: true
Attachment #9002957 -
Flags: review?(francois)
Comment 11•7 years ago
|
||
Comment on attachment 9002957 [details] [diff] [review]
Part 3: Refactor the code responsible for checking whether the top window URI is on the content blocking allow list into AntiTrackingCommon
Review of attachment 9002957 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ +521,5 @@
> + bool& aIsAllowListed)
> +{
> + aIsAllowListed = false;
> +
> + LOG_SPEC(("Deciding whether the user has overridden content blocking for %s",
I'd recommend truncating the URL like in nsChannelClassifier.cpp (see https://hg.mozilla.org/mozilla-central/rev/58c256b60254).
Some of the tracking URLs have enormous query strings and it's super-annoying to scroll past them in the debug logs.
Attachment #9002957 -
Flags: review?(francois) → review+
Comment 12•7 years ago
|
||
Comment on attachment 9002761 [details] [diff] [review]
Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList()
Review of attachment 9002761 [details] [diff] [review]:
-----------------------------------------------------------------
Yay!
::: browser/base/content/browser-contentblocking.js
@@ +437,5 @@
> let hasException = false;
> + let type = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser) ?
> + "trackingprotection-pb" :
> + "trackingprotection";
> + hasException = Services.perms.testExactPermission(baseURI, type) ==
nit: just do "let hasException" here and remove the line that initializes this
Attachment #9002761 -
Flags: review?(jhofmann) → review+
Comment 13•7 years ago
|
||
Comment on attachment 9002762 [details] [diff] [review]
Part 5: Merge the PrivateBrowsingTrackingProtectionWhitelist service with PrivateBrowsingUtils.jsm
Review of attachment 9002762 [details] [diff] [review]:
-----------------------------------------------------------------
🤩
::: toolkit/modules/PrivateBrowsingUtils.jsm
@@ +28,5 @@
> + /**
> + * Remove the provided URI from the list of allowed tracking sites.
> + *
> + * @param uri nsIURI
> + * The URI to add to the list.
nit: to remove from the list
Attachment #9002762 -
Flags: review?(jhofmann) → review+
Comment 14•7 years ago
|
||
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1c9895ab06c6
Part 1: Refactor the PrivateBrowsingTrackingProtectionWhitelist service on top of the permission manager; r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/babf6abc7f4c
Part 2: Check the trackingprotection-pb permission in the channel classifier code instead of accessing nsIPrivateBrowsingTrackingProtectionWhitelist; r=francois
https://hg.mozilla.org/integration/mozilla-inbound/rev/d31e39a47704
Part 3: Refactor the code responsible for checking whether the top window URI is on the content blocking allow list into AntiTrackingCommon; r=francois
https://hg.mozilla.org/integration/mozilla-inbound/rev/cd2ced689895
Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList(); r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/b1cb63d8c8bb
Part 5: Merge the PrivateBrowsingTrackingProtectionWhitelist service with PrivateBrowsingUtils.jsm; r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/e80737d6af55
Part 6: Truncate the tracking URIs in the anti-tracking logs to 128 characters since they may be really long; r=francois
Comment 15•7 years ago
|
||
Backed out for eslint failure on PrivateBrowsingUtils.
Push with failures: https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&fromchange=e80737d6af552187ffeb8099c8d6fd936febed5e&tochange=41ebcb085bb01e54c1a7eea9e794cde45afbe734&selectedJob=195293076&filter-searchStr=Linting%20opt%20source-test-mozlint-eslint%20(ES)
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=195293076&repo=mozilla-inbound&lineNumber=241
Backout link:
https://hg.mozilla.org/integration/mozilla-inbound/rev/41ebcb085bb01e54c1a7eea9e794cde45afbe734
[task 2018-08-22T13:14:16.995Z] Error processing command. Ignoring because optional. (optional:packages.txt:comm/build/virtualenv_packages.txt)
[task 2018-08-22T13:19:59.693Z] TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/toolkit/modules/PrivateBrowsingUtils.jsm:8:1 | 'XPCOMUtils' is defined but never used. (no-unused-vars)
Flags: needinfo?(ehsan)
Comment 16•7 years ago
|
||
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/bddf9e4f6f3a
Part 1: Refactor the PrivateBrowsingTrackingProtectionWhitelist service on top of the permission manager; r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/66519e95427e
Part 2: Check the trackingprotection-pb permission in the channel classifier code instead of accessing nsIPrivateBrowsingTrackingProtectionWhitelist; r=francois
https://hg.mozilla.org/integration/mozilla-inbound/rev/5ffff7652f87
Part 3: Refactor the code responsible for checking whether the top window URI is on the content blocking allow list into AntiTrackingCommon; r=francois
https://hg.mozilla.org/integration/mozilla-inbound/rev/5c3668fde5e5
Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList(); r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/9b7ecee484b0
Part 5: Merge the PrivateBrowsingTrackingProtectionWhitelist service with PrivateBrowsingUtils.jsm; r=johannh
https://hg.mozilla.org/integration/mozilla-inbound/rev/d4222536f35f
Part 6: Truncate the tracking URIs in the anti-tracking logs to 128 characters since they may be really long; r=francois
Assignee | ||
Updated•7 years ago
|
Flags: needinfo?(ehsan)
Comment 17•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bddf9e4f6f3a
https://hg.mozilla.org/mozilla-central/rev/66519e95427e
https://hg.mozilla.org/mozilla-central/rev/5ffff7652f87
https://hg.mozilla.org/mozilla-central/rev/5c3668fde5e5
https://hg.mozilla.org/mozilla-central/rev/9b7ecee484b0
https://hg.mozilla.org/mozilla-central/rev/d4222536f35f
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 63
You need to log in
before you can comment on or make changes to this bug.
Description
•