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

Surrogates (fixes #400) #935

Merged
merged 39 commits into from
Oct 6, 2016
Merged

Surrogates (fixes #400) #935

merged 39 commits into from
Oct 6, 2016

Conversation

ghostwords
Copy link
Member

WIP pull request for #400

Besides review, what's left is more surrogates and more testing. We should run some queries against the "report broken site" db to get some recent high-profile breakages we can surrogate.

@cooperq cooperq self-assigned this Sep 21, 2016
@cooperq cooperq added this to the Privacy Badger 2.0 milestone Sep 21, 2016
require.scopes.surrogatedb = (function() {

const hostnames = {
'www.google-analytics.com': [
Copy link
Contributor

Choose a reason for hiding this comment

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

This data structure should be better commented.

],
};

const surrogates = {
Copy link
Contributor

Choose a reason for hiding this comment

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

More documentation needed here as well.

function getSurrogateURI(script_url, script_hostname) {
// do we have an entry for the script hostname?
if (db.hostnames.hasOwnProperty(script_hostname)) {
const hosts = db.hostnames[script_hostname];
Copy link
Contributor

Choose a reason for hiding this comment

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

needs more doc

Copy link
Contributor

Choose a reason for hiding this comment

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

rename to tokens

// do any of the pattern tokens for that hostname match the script URL?
for (let i = 0; i < hosts.length; i++) {
const token = hosts[i];
if (script_url.endsWith(token)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle query strings e.g.

ga.com/ga.js?foo=bar


test("surrogate script URL lookups", function() {
// URLs that should have a surrogate
ok(!!getSurrogateURI('http://www.google-analytics.com/ga.js', 'www.google-analytics.com'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Test for no surrogate?
Test other surrogates...

Copy link
Contributor

Choose a reason for hiding this comment

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

test that query strings are handled in a sane way

Copy link
Contributor

Choose a reason for hiding this comment

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

selenium integration test

Copy link
Contributor

@cooperq cooperq left a comment

Choose a reason for hiding this comment

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

Please address the issues I commented on.

Copy link
Contributor

@cooperq cooperq left a comment

Choose a reason for hiding this comment

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

Looks great pending finishing the selenium test.

Still needs to be moved to dedicated testing page:
#928.
So that it can get auto collected.
Copy link
Contributor

@cooperq cooperq left a comment

Choose a reason for hiding this comment

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

Replace avianca with locally hosted page.
Merge master.

@ghostwords
Copy link
Member Author

@cooperq OK, should be good to merge now. Take a look please.
Will need to later:

  • Update the integration test URL from eff.org to pbtest.org at some point.
  • Replace pb by badger in the integration test after WIP ... Privacy Badger Refactor #951 is merged. Depends on which pull request is merged into master first I guess.

@ghostwords
Copy link
Member Author

@gunesacar Let me know if you have any suggestions to improve the script surrogates integration test.

Conflicts:
	src/background.js
	src/domainExceptions.js
	src/webrequest.js
	tests/index.html
@cooperq
Copy link
Contributor

cooperq commented Oct 6, 2016

Looks good to me!

@gunesacar
Copy link
Collaborator

@gunesacar Let me know if you have any suggestions to improve the script surrogates integration test.

It looks pretty good to me.

Maybe you could consider adding a test for outbound link tracking:
https://support.google.com/analytics/answer/1136920?hl=en

@ghostwords ghostwords merged commit beebcb3 into master Oct 6, 2016
@ghostwords ghostwords deleted the surrogates branch October 6, 2016 19:40
@ghostwords ghostwords added the surrogates Replacement blank/noop/dummy/neutered versions of tracking scripts used to avoid site breakages label Nov 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
surrogates Replacement blank/noop/dummy/neutered versions of tracking scripts used to avoid site breakages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants