Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
Add EasyPrivacy
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Apr 7, 2018
1 parent 888cd4e commit 0ebbade
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
15 changes: 8 additions & 7 deletions ad_block_client.cc
Expand Up @@ -799,19 +799,20 @@ bool AdBlockClient::parse(const char *input) {
// Otherwise it needs to be done manually via initBloomFilter and
// initExceptionBloomFilter
if (!bloomFilter) {
bloomFilter = new BloomFilter(15, 40000);
bloomFilter = new BloomFilter(15, 80000);
}
if (!exceptionBloomFilter) {
exceptionBloomFilter = new BloomFilter(10, 10000);
exceptionBloomFilter = new BloomFilter(10, 20000);
}
if (!hostAnchoredHashSet) {
// Optimized to be 1:1 with the easylist number of host anchored hosts
hostAnchoredHashSet = new HashSet<Filter>(5395);
// Optimized to be 1:1 with the easylist / easyprivacy
// number of host anchored hosts.
hostAnchoredHashSet = new HashSet<Filter>(18000);
}
if (!hostAnchoredExceptionHashSet) {
// Optimized to be 1:1 with the easylist number of host anchored
// exception hosts
hostAnchoredExceptionHashSet = new HashSet<Filter>(428);
// Optimized to be 1:1 with the easylist / easyprivacy
// number of host anchored exception hosts.
hostAnchoredExceptionHashSet = new HashSet<Filter>(2000);
}

const char *p = input;
Expand Down
6 changes: 6 additions & 0 deletions lists/default.h
Expand Up @@ -16,6 +16,12 @@ const std::vector<FilterList> default_lists = {
"EasyList",
{},
"https://easylist.to/"
}, {
"48010209-AD34-4DF5-A80C-3D2A7C3920C0",
"https://easylist.to/easylist/easyprivacy.txt",
"EasyPrivacy",
{},
"https://easylist.to/"
}, {
"200392E7-9A0F-40DF-86EB-6AF7E4071322",
"https://raw.githubusercontent.com/brave/adblock-lists/master/ublock-unbreak.txt", // NOLINT
Expand Down
3 changes: 3 additions & 0 deletions main.cc
Expand Up @@ -88,6 +88,8 @@ int checkForClient(AdBlockClient *pClient, const char *outputPath,

int main(int argc, char**argv) {
std::string && easyListTxt = getFileContents("./test/data/easylist.txt");
std::string && easyPrivacyTxt =
getFileContents("./test/data/easyprivacy.txt");
std::string && ublockUnblockTxt =
getFileContents("./test/data/ublock-unbreak.txt");
std::string && braveUnblockTxt =
Expand All @@ -100,6 +102,7 @@ int main(int argc, char**argv) {
// Parse filter lists for adblock
AdBlockClient adBlockClient;
adBlockClient.parse(easyListTxt.c_str());
adBlockClient.parse(easyPrivacyTxt.c_str());
adBlockClient.parse(ublockUnblockTxt.c_str());
adBlockClient.parse(braveUnblockTxt.c_str());
std::vector<std::string> checkVector;
Expand Down
4 changes: 4 additions & 0 deletions perf.cc
Expand Up @@ -70,6 +70,8 @@ void doSiteList(AdBlockClient *pClient, bool outputPerf) {
int main(int argc, char**argv) {
std::string && easyListTxt =
getFileContents("./test/data/easylist.txt");
std::string && easyPrivacyTxt =
getFileContents("./test/data/easyprivacy.txt");
std::string && braveUnblockTxt =
getFileContents("./test/data/brave-unbreak.txt");
std::string && ublockUnblockTxt =
Expand All @@ -87,6 +89,7 @@ int main(int argc, char**argv) {

AdBlockClient adBlockClient;
adBlockClient.parse(easyListTxt.c_str());
adBlockClient.parse(easyPrivacyTxt.c_str());
adBlockClient.parse(ublockUnblockTxt.c_str());
adBlockClient.parse(braveUnblockTxt.c_str());
doSiteList(&adBlockClient, true);
Expand All @@ -110,6 +113,7 @@ int main(int argc, char**argv) {
AdBlockClient allClient;
allClient.enableBadFingerprintDetection();
allClient.parse(easyListTxt.c_str());
allClient.parse(easyPrivacyTxt.c_str());
allClient.parse(ublockUnblockTxt.c_str());
allClient.parse(braveUnblockTxt.c_str());
allClient.parse(spam404MainBlacklistTxt.c_str());
Expand Down
10 changes: 8 additions & 2 deletions scripts/check.js
Expand Up @@ -20,6 +20,8 @@
* node scripts/check.js --host www.cnet.com --list ./test/data/sitelist.txt
* Checking a list of URLS with discovery:
* node scripts/check.js --host www.cnet.com --list ./test/data/sitelist.txt --discover
* Get stats for a particular adblock list:
* node scripts/check.js --uuid 67F880F5-7602-4042-8A3D-01481FD7437A --stats
*/
const commander = require('commander')
const {makeAdBlockClientFromListUUID, makeAdBlockClientFromDATFile, makeAdBlockClientFromListURL, makeAdBlockClientFromString, makeAdBlockClientFromFilePath, readSiteList} = require('../lib/util')
Expand All @@ -38,13 +40,14 @@ commander
.option('-o, --output [output]', 'Optionally saves a DAT file')
.option('-L --list [list]', 'Filename for list of sites to check')
.option('-D --discover', 'If speciied does filter discovery for matched filter')
.option('-s --stats', 'If speciied outputs parsing stats')
.option('-C, --cache', 'Optionally cache results and use cached results')
.option('-O, --filter-option [filterOption]', 'Filter option to use', filterStringToFilterOption, FilterOptions.noFilterOption)
.parse(process.argv)

let p = Promise.reject('Usage: node check.js --location <location> --host <host> [--uuid <uuid>]')

if (commander.host && (commander.location || commander.list)) {
if (commander.host && (commander.location || commander.list) || commander.stats) {
p.catch(() => {})
if (commander.uuid) {
p = makeAdBlockClientFromListUUID(commander.uuid)
Expand All @@ -64,7 +67,10 @@ if (commander.host && (commander.location || commander.list)) {
}

p.then((adBlockClient) => {
console.log('Parsing stats:', adBlockClient.getParsingStats())
if (commander.stats) {
console.log('Parsing stats:', adBlockClient.getParsingStats())
return
}
if (commander.location) {
console.log('params:', commander.location, commander.filterOption, commander.host)
if (commander.discover) {
Expand Down
2 changes: 1 addition & 1 deletion test/js/filterListTest.js
Expand Up @@ -9,7 +9,7 @@ const {adBlockLists} = require('../..')
describe('adBlockLists', function () {
describe('default', function () {
it('contains 4 default lists', function () {
assert.equal(adBlockLists.default.length, 4)
assert.equal(adBlockLists.default.length, 5)
})
it('has uuid property', function () {
adBlockLists.default.forEach((list) => {
Expand Down

0 comments on commit 0ebbade

Please sign in to comment.