Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Add HTTPS Everywhere #128

Merged
merged 14 commits into from
Jan 13, 2016
Merged

Add HTTPS Everywhere #128

merged 14 commits into from
Jan 13, 2016

Conversation

diracdeltas
Copy link
Member

The rulesets.sqlite file is taken from the tip of https://github.com/efforg/https-everywhere/tree/stable. Eventually we need a script to automatically fetch this and run npm run-script preload-httpse per release or so.

The rewrite logic is basically:

  1. On app start, open a connection to the rulesets sqlite DB and load the pre-computed mapping of ruleset ID's to hostnames (httpse-targets.json).
  2. In webrequest.onBeforeRequest, check if the URL has been blacklisted due to causing an infinite redirect loop. If not, look up applicable rulesets from the DB by ID and apply the first-matching rewrite rule. (This can be made more efficient by caching recently-used rulesets in memory.)
  3. Redirect the request to the rewritten URL.

@diracdeltas
Copy link
Member Author

Update: thanks to the Electron maintainers who pointed out my very-obvious typo, this is now actually doing redirects. :)

@diracdeltas diracdeltas changed the title Add non-working HTTPS Everywhere module Add HTTPS Everywhere Jan 11, 2016
@@ -9,7 +9,7 @@ module.exports.register = (wnd, filteringFn) => {
filteringFns.push(filteringFn)
if (!wnds.has(wnd)) {
wnds.add(wnd)
wnd.webContents.session.webRequest.onBeforeRequest((details, cb) => {
wnd.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is it any slower to block onBeforeSendHeaders instead of onBeforeRequest?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd expect them to be roughly the same

@bbondy
Copy link
Member

bbondy commented Jan 11, 2016

For js/data/rulesets.sqlite I think this is GPL so should probably be loaded remotely. See adblock.js and trackingProtection.js which use the dataFile module. I can throw it on S3 if you want, just ping me on slack.

Please push back if you think it's ok to include it as is.

if (dbErr) {
console.log('error loading httpse rulesets.sqlite')
} else {
console.log('loaded httpse ruleset db')
Copy link
Member

Choose a reason for hiding this comment

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

We can probably comment this one out, and other non error cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, this was just here to prove that it is doing something for subresource loads

@bbondy
Copy link
Member

bbondy commented Jan 11, 2016

Looking great, I'd love to get this in before the beta. The main thing before merging is just to check if the DB is also GPL'ed or get permission for including that statically.

@bbondy
Copy link
Member

bbondy commented Jan 11, 2016

Please also add a switch in app/appConfig.js for enabled in case we need to disable this last minute before the 20th.

@diracdeltas
Copy link
Member Author

For js/data/rulesets.sqlite I think this is GPL so should probably be loaded remotely. See adblock.js and trackingProtection.js which use the dataFile module. I can throw it on S3 if you want, just ping me on slack.

Yep, it's GPL so this sounds right.

@diracdeltas
Copy link
Member Author

Please also add a switch in app/appConfig.js for enabled in case we need to disable this last minute before the 20th.

will do. will these switches be exposed to users eventually or even for the beta?

@bbondy
Copy link
Member

bbondy commented Jan 11, 2016

The config is just for us currently but anything in there should be moved to app settings once we have them.

@bbondy
Copy link
Member

bbondy commented Jan 11, 2016

I'd love to have settings for beta but I don't think we'll have enough time for 0.7 maybe shortly after though.

@diracdeltas
Copy link
Member Author

I've updated this so HTTPS Everywhere also uses dataFile.init

@bbondy
Copy link
Member

bbondy commented Jan 13, 2016

Great, good to merge?

@diracdeltas
Copy link
Member Author

Will resolve and merge for now!

Note: this is not quite working yet due to a possible Electron webRequest bug
Registering multiple listeners on onBeforeRequest caused the request to be
completed before HTTPS Everywhere got the chance to rewrite it. This may
be a bug in how Electron handles conflict resolution between multiple
request listeners.
It seems that usually the rulesets have loaded by the time the first network request
happens. So instead of aborting if the rulesets haven't loaded, load the listeners anyway.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants