Skip to content

Commit ef85b6e

Browse files
authored
Update the lists (#487)
* update the lists * update the script * fix tests
1 parent 48ed2a4 commit ef85b6e

File tree

8 files changed

+36184
-38592
lines changed

8 files changed

+36184
-38592
lines changed

data/brave/brave-main-list.txt

Lines changed: 22049 additions & 25082 deletions
Large diffs are not rendered by default.

data/easylist.to/easylist/easylist.txt

Lines changed: 12235 additions & 12531 deletions
Large diffs are not rendered by default.

data/easylist.to/easylist/easyprivacy.txt

Lines changed: 1585 additions & 793 deletions
Large diffs are not rendered by default.

data/easylist.to/easylistgermany/easylistgermany.txt

Lines changed: 273 additions & 154 deletions
Large diffs are not rendered by default.

data/update-lists.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const args = process.argv.slice(2);
77

88
if (args.length < 2) {
99
console.error(
10-
"Usage: node update-lists.js <Brave Services Key> <target version for brave list (i.e. 1.0.10268)>"
10+
"Usage: node update-lists.js <Brave Services Key> <target version for brave list (i.e. 1.0.10268)>\n" +
11+
"The component name is 'Brave Ad Block Updater'"
1112
);
1213
process.exit(1);
1314
}
@@ -28,20 +29,32 @@ execSync(
2829
"curl -o data/easylist.to/easylistgermany/easylistgermany.txt https://easylist.to/easylistgermany/easylistgermany.txt"
2930
);
3031

31-
execSync(
32-
`curl -o extension.zip -H "BraveServiceKey: ${apiKey}" ` +
33-
`https://brave-core-ext.s3.brave.com/release/${extensionId}/extension_${versionNumber}.crx`
32+
const rootDir = path.join(__dirname, "..");
33+
const tempDir = path.resolve(
34+
fs.mkdtempSync("temp-brave-list", {
35+
dir: rootDir,
36+
})
3437
);
3538

36-
const tempDir = fs.mkdtempSync("temp-brave-list");
37-
const listPath = path.join(tempDir, "list.txt");
3839
try {
39-
execSync("unzip extension.zip -d " + tempDir);
40-
} catch (e) {
41-
if (!fs.existsSync(listPath)) {
42-
console.error("Failed to find list.txt in extension.zip");
43-
process.exit(1);
40+
process.chdir(tempDir);
41+
42+
execSync(
43+
`curl -o extension.zip -H "BraveServiceKey: ${apiKey}" ` +
44+
`https://brave-core-ext.s3.brave.com/release/${extensionId}/extension_${versionNumber}.crx`
45+
);
46+
47+
const listPath = path.join(tempDir, "list.txt");
48+
try {
49+
execSync("unzip extension.zip -d .");
50+
} catch (e) {
51+
// .crx is not a zip file, so we expect an error here.
52+
if (!fs.existsSync(listPath)) {
53+
throw new Error("Failed to find list.txt in extension.zip");
54+
}
4455
}
45-
}
4656

47-
execSync(`mv -f ${listPath} data/brave/brave-main-list.txt`);
57+
fs.renameSync(listPath, path.join(rootDir, "data/brave/brave-main-list.txt"));
58+
} finally {
59+
fs.rmdirSync(tempDir, { recursive: true });
60+
}

tests/matching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,5 @@ fn check_rule_matching_browserlike() {
202202
let (blocked, passes) = bench_rule_matching_browserlike(&engine, &requests);
203203
let msg = "The number of blocked/passed requests has changed. ".to_string()
204204
+ "If this is expected, update the expected values in the test.";
205-
assert_eq!((blocked, passes), (103973, 138972), "{}", msg);
205+
assert_eq!((blocked, passes), (101756, 141189), "{}", msg);
206206
}

tests/unit/blocker.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,30 +1368,27 @@ mod legacy_rule_parsing_tests {
13681368
}
13691369
}
13701370

1371-
// number of expected EasyList cosmetic rules from old engine is 31144, but is incorrect as it skips a few particularly long rules that are nevertheless valid
1372-
// easyList = { 24478, 31144, 0, 5589 };
1373-
// not handling (and not including) filters with the following options:
1374-
// - $popup
1375-
// - $elemhide
1376-
// difference from original counts caused by not handling document/subdocument options and possibly miscounting on the blocker side.
1377-
// Printing all non-cosmetic, non-html, non-comment/-empty rules and ones with no unsupported options yields 29142 items
1378-
// This engine also handles 3 rules that old one does not
1371+
// The number of loaded rules differs from the text files due to:
1372+
// * not handling (and not including) filters with the following options:
1373+
// - $popup
1374+
// - $elemhide
1375+
// * not handling document/subdocument options;
1376+
// * the optimizer that merges multiple rules into one;
13791377
const EASY_LIST: ListCounts = ListCounts {
1380-
filters: 35597, // 36259 - 662 exceptions
1378+
filters: 35043,
13811379
cosmetic_filters: if cfg!(feature = "css-validation") {
1382-
23072
1380+
23668
13831381
} else {
1384-
23080
1382+
23682
13851383
},
1386-
exceptions: 662,
1384+
exceptions: 706,
13871385
duplicates: 0,
13881386
};
1389-
// easyPrivacy = { 11817, 0, 0, 1020 };
13901387
// differences in counts explained by hashset size underreporting as detailed in the next two cases
13911388
const EASY_PRIVACY: ListCounts = ListCounts {
1392-
filters: 52278, // 52998 - 720 exceptions
1393-
cosmetic_filters: 21,
1394-
exceptions: 720,
1389+
filters: 53029, // total - exceptions
1390+
cosmetic_filters: 28,
1391+
exceptions: 737,
13951392
duplicates: 2,
13961393
};
13971394
// ublockUnbreak = { 4, 8, 0, 94 };

tests/unit/engine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ mod tests {
219219
let data = engine.serialize().unwrap();
220220

221221
let expected_hash = if cfg!(feature = "css-validation") {
222-
6718506180720782170
222+
7254547691107602751
223223
} else {
224-
6839468684492187294
224+
4130628479730907288
225225
};
226226

227227
assert_eq!(hash(&data), expected_hash, "{}", HASH_MISMATCH_MSG);

0 commit comments

Comments
 (0)