-
Notifications
You must be signed in to change notification settings - Fork 973
Conversation
I would prefer if this allowed specific cookies or cookie domains instead of all 3p cookies on Facebook and Google Drive. I use both FB and Google Drive with 3p cookies blocked (the default right now) and have never had a problem, so I don't want Brave to automatically change the setting to 'allow'. |
ac891d8
to
dc208c1
Compare
dc208c1
to
3e1bc32
Compare
@@ -46,9 +47,6 @@ let initializedPartitions = {} | |||
const transparent1pxGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' | |||
const pdfjsOrigin = `chrome-extension://${config.PDFJSExtensionId}` | |||
|
|||
// Third party domains that require a valid referer to work | |||
const refererExceptions = ['use.typekit.net', 'cloud.typography.com', 'www.moremorewin.net'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
app/filtering.js
Outdated
@@ -273,9 +271,15 @@ function registerForBeforeSendHeaders (session, partition) { | |||
|
|||
if (cookieSetting === 'blockAllCookies' || | |||
isThirdPartyHost(parsedFirstPartyUrl.hostname, parsedTargetUrl.hostname)) { | |||
let hasCookieException = false | |||
cookieExceptions.forEach((exceptionPair) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this would be more efficient if cookieExceptions were a map like {firstPartyOrigin: [origins]}
instead of a list like [[firstPartyOrigin, origin],...]
. but this seems ok for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is HUGE 😛 I'd love to see this (the cookieSetting logic) moved into it's own method so we can easily unit test it. If you don't mind, maybe I can try a rev1 for the test?
fixes #9810 Auditors: @diracdeltas, @bsclifton, @bbondy Test Plan: 1. Go to google drive 2. Make sure block 3rd party cookies 3. You should be able to download file
Auditors: @darkdh, @diracdeltas Test Plan: `npm run unittest -- --grep="filtering unit tests"`
3e1bc32
to
695f0f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdh @diracdeltas I rebased this, pulled the logic out to a method, and then added some unit tests 😄 I was going to give this as feedback after reviewing, but had some free cycles. Let me know what you think!
The unit tests I added help add this coverage (and I think also help prevent regressions):
- Statement coverage from 15.63% to 19.05%
- Branch coverage from 0% to 7.3%
- Function coverage from 0% to 4.17%
- Line coverage from 15.63% to 19.05%
app/filtering.js
Outdated
@@ -273,9 +271,15 @@ function registerForBeforeSendHeaders (session, partition) { | |||
|
|||
if (cookieSetting === 'blockAllCookies' || | |||
isThirdPartyHost(parsedFirstPartyUrl.hostname, parsedTargetUrl.hostname)) { | |||
let hasCookieException = false | |||
cookieExceptions.forEach((exceptionPair) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is HUGE 😛 I'd love to see this (the cookieSetting logic) moved into it's own method so we can easily unit test it. If you don't mind, maybe I can try a rev1 for the test?
test/unit/app/filteringTest.js
Outdated
assert(cookieException) | ||
|
||
const url = cookieException[0] | ||
const firstPartyUrl = cookieException[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
�The firstPartyUrl should be cookieException[0]. I will make it right in the commit changing the cookie exception to map
app/filtering.js
Outdated
@@ -220,6 +218,38 @@ function registerForBeforeRedirect (session, partition) { | |||
}) | |||
} | |||
|
|||
module.exports.considerRequestExceptions = (requestHeaders, url, firstPartyUrl, isPrivate) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rename this to something more descriptive like applyCookieSetting
app/filtering.js
Outdated
firstPartyOrigin !== pdfjsOrigin && !hasCookieException) { | ||
requestHeaders['Cookie'] = undefined | ||
} | ||
if (cookieSetting !== 'blockAllCookies' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the cookieSetting !== 'blockAllCookies'
part is a bug in the original code and should be omitted. the referer should be blocked when the cookieSetting is 'blockAllCookies'.
['https://inbox.google.com', 'https://hangouts.google.com'], | ||
['https://mail.google.com', 'https://hangouts.google.com'] | ||
] | ||
module.exports.cookieExceptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will probably need to be a map of domains to list, like 'https://inbox.google.com': [...]
because we may need multiple cookie exception origins for the same top-level origin
thanks for adding tests! |
this doesn't seem to fix the cookie issue on drive.google.com for me. i don't see any requests to https://doc-0g-3g-docs.googleusercontent.com, only https://lh*.googleusercontent.com |
@diracdeltas I downloaded .pdf, .html, .txt, .mp4 files from google drive and it will send request to doc-*-3g-doc.googleusercontent.com |
the wildcard fixes the issue for me 👍 |
Add cookieException for google drive
fixes #9810
Auditors: @diracdeltas, @bsclifton, @bbondy
Test Plan:
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests