Giter VIP home page Giter VIP logo

tracking-protection's Introduction

tracking-protection

C++ tracking protection filter parser for lists like https://github.com/disconnectme/disconnect-tracking-protection/blob/master/services.json

Setup

npm install --save tracking-protection

Installation

  1. Clone the git repository from GitHub:

     git clone https://github.com/SergeyZhukovsky/tracking-protection
    
  2. Open the working directory:

     cd tracking-protection
    
  3. Install the Node (v5+) dependencies:

     npm install
    

Sample

#include <iostream>
#include "./TPParser.h"

using std::cout;
using std::endl;

int main(int argc, char **argv) {
    CTPParser parser;
    parser.addTracker("facebook.com");
    parser.addTracker("facebook.de");

    // Prints matches
    if (parser.matchesTracker("facebook.com")) {
        cout << "matches" << endl;
    }
    else {
        cout << "does not match" << endl;
    }

    // Prints does not match
    if (parser.matchesTracker("facebook1.com")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    // Prints does not match
    if (parser.matchesTracker("subdomain.google-analytics.com.")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    parser.addFirstPartyHosts("facebook.com", "facebook.fr,facebook.de");
    parser.addFirstPartyHosts("google.com", "2mdn.net,admeld.com");
    parser.addFirstPartyHosts("subdomain.google.com", "facebook.fr,facebook.de");

    // Returns combined result of third party hosts for "google.com" and for "subdomain.google.com"
    // "facebook.fr,facebook.de,2mdn.net,admeld.com"
    char* thirdPartyHosts = parser.findFirstPartyHosts("subdomain.google.com");
    if (nullptr != thirdPartyHosts) {
        cout << thirdPartyHosts << endl;
        delete []thirdPartyHosts;
    }

    unsigned int totalSize = 0;
    // Serialize data
    char* data = parser.serialize(&totalSize);

    // Deserialize data
    parser.deserialize(data);

    // Prints matches
    if (parser.matchesTracker("facebook.com")) {
        cout << "matches" << endl;
    }
    else {
        cout << "does not match" << endl;
    }
    // Prints does not match
    if (parser.matchesTracker("facebook1.com")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    // Prints "2mdn.net,admeld.com"
    thirdPartyHosts = parser.findFirstPartyHosts("google.com");
    if (nullptr != thirdPartyHosts) {
        cout << thirdPartyHosts << endl;
    }

    if (data) {
        delete []data;
    }

    return 0;
}

Build everything in release

make

Build everything in debug

make build-debug

Running sample

make sample

Running tests

make test

Clearing build files

make clean

tracking-protection's People

Contributors

bbondy avatar bridiver avatar darkdh avatar diracdeltas avatar emerick avatar fmarier avatar jumde avatar sergeyzhukovsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tracking-protection's Issues

platform.linkedin.com link wrongly blocked on businessinsider.com

The slideshow here:
http://www.businessinsider.com/yahoo-roaring-20s-holiday-party-pictures-2015-12?op=0#/%23yahoos-20th-anniversary-holiday-party-was-roaring-20s-themed-1

has a problem with tracking protection.
It works with Chrome with Disconnect installed.

But does not load with Brave because brave blocks it.
the host of lookup that gets blocked is:
platform.linkedin.com
And it finds it should block with that.

Then it looks for exceptions from:
businessinsider.com but does not find any.

The 10th entry of each section is ignored by the generation script

My new test page for the various categories on the Disconnect list highlighted that the login.yahoo.com entry, part of the Social category, isn't anywhere in the .dat file.

After adding some more debugging output, I also noticed these missing entries:

I looked through all entries for the Yahoo entry in Social:

"Yahoo!": {
  "http://www.yahoo.com/": [
    "mybloglog.com",
    "rocketmail.com",
    "address.yahoo.com",
    "alerts.yahoo.com",
    "avatars.yahoo.com",
    "buzz.yahoo.com",
    "calendar.yahoo.com",
    "edit.yahoo.com",
    "legalredirect.yahoo.com",
    "login.yahoo.com",
    "mail.yahoo.com",
    "my.yahoo.com",
    "notepad.yahoo.com",
    "pulse.yahoo.com",
    "webmessenger.yahoo.com",
    "ymail.com"
  ]
}

and of these, only the 10th one (i.e. index 9) is missing.

Same thing for the valueclick.com entry:

(0,adserver.com)
(1,dotomi.com)
(2,dtmpub.com)
(3,emjcd.com)
(4,fastclick.com)
(5,fastclick.net)
(6,greystripe.com)
(7,lduhtrp.net)
(8,mediaplex.com)
(9,valueclick.com)
(10,valueclick.net)
(11,valueclickmedia.com)

I added the following debug output:

console.log("previousKey = " + previousKey);
if (undefined != previousKey && k <= previousKey) {
  console.log("!!!! " + k + "<= " + previousKey);
  values.delete(previousValue);
}

and I found the problem:

previousKey = 9
!!!! 10<= 9
previousKey = 10
previousKey = 11
previousKey = undefined

which is of course because the comparison is done over strings instead of integers:

> 10 <= 9
false
> '10' <= '9'
true

Prevent tracking based on link decoration via query string or fragment

ITP 2.2 is reducing the lifetime of cookies set via document.cookie when the navigation came from a tracking-enabled page and the destination URL includes query string parameters or a fragment: https://webkit.org/blog/8828/intelligent-tracking-prevention-2-2/

We already block the third-party scripts that would be extracting these IDs and setting a first-party tracking cookie, but we could in theory go further by:

  • emulating the cookie lifetime restriction, or
  • stripping out tracking query string parameters (e.g. gclid and fbclid).

Symbol not found using require

Hello,

I'm trying to require the library from the NPM registry but something is failing:

> const TrackingProtection = require('tracking-protection')
Error: dlopen(/Users/josefranciscoverdugambin/Projects/browserless/packages/browserless/node_modules/tracking-protection/build/Release/tp_node_addon.node, 1): Symbol not found: __ZTV6HashFn
  Referenced from: /Users/josefranciscoverdugambin/Projects/browserless/packages/browserless/node_modules/tracking-protection/build/Release/tp_node_addon.node
  Expected in: flat namespace
 in /Users/josefranciscoverdugambin/Projects/browserless/packages/browserless/node_modules/tracking-protection/build/Release/tp_node_addon.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)

this is the installation log.

I tried using different node versions but without successfully. Any idea?

[FIXED] npm ERR! [email protected] install: `node-gyp rebuild`

Hi,

When trying to install the brave browser, I ran into the error below with [email protected] or [email protected].

Npm and node versions are the latest at this time. I'm running ubuntu. I've also attached the npm-debug.log file.

If you have any info, please let me know.

Regards,

Versions of software used:

% npm --version
3.5.3
% node --version
v4.2.6
% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty
% uname -a
Linux subway 3.13.0-76-generic #120-Ubuntu SMP Mon Jan 18 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Error message:

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tracking-protection package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs tracking-protection
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls tracking-protection
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/yann/src/browser-laptop/npm-debug.log

npm-debug.log.zip

Unnecessary first_party entries in TrackingProtection.dat

Using my script for dumping the contents of .dat files, I noticed that the datfile contains a number of unnecessary entries like:

  • vizu.com: vizu.com
  • vizury.com: vizury.com
  • webads.co.uk: webads.co.uk
  • webclicktracker.com: webclicktracker.com
  • webtraxs.com: webtraxs.com

since their same-origin'ness should alleviate the need for explicit whitelisting.

This could shrink the size of the extension we ship to users, though zipping will also reduce the bloating caused by these entries.

npm run install fails with unresolved externals on Windows

When running npm run install on Windows, it fails with the following error:

     Creating library C:\work\tracking-protection\build\Release\tp_node_addon.lib and object C:\work\tracking-protection\build\Release\tp_node_addon.exp
TrackerData.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl HashFn::operator()(char const *,int,unsigned char,unsigned __int64)" (??RHashFn@@UEAA_KPEBDHE_K@Z) [C:\work\tracking-protection\build\tp_node_addon.vcxproj]
TrackerData.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl HashFn::operator()(char const *,int)" (??RHashFn@@UEAA_KPEBDH@Z) [C:\work\tracking-protection\build\tp_node_addon.vcxproj]
C:\work\tracking-protection\build\Release\tp_node_addon.node : fatal error LNK1120: 2 unresolved externals [C:\work\tracking-protection\build\tp_node_addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\work\tracking-protection
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\emerick\AppData\Roaming\npm-cache\_logs\2018-08-13T20_03_54_648Z-debug.log

Allow everything from parent domain

For example we have alexa.com in amazon.com section to allow it for amazon, but it is in the list to block. So the parent domain alexa.com should allow everything like that template *.alexa.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.