From 5a80fd883f22bb9adb980d896dfb9da566275958 Mon Sep 17 00:00:00 2001 From: Sam Macbeth Date: Fri, 16 Feb 2024 09:37:32 +0100 Subject: [PATCH 1/3] Add tests for wildcard rule match behavior --- .../tracker_allowlist_matching_tests.json | 18 ++++++++++++++++++ .../tracker_allowlist_reference.json | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json index 191c3bb..610d926 100644 --- a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json +++ b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json @@ -150,5 +150,23 @@ "site": "https://testsite.com", "request": "http://a.b.c.videos.allowlist-tracker-2.com/a.js", "isAllowlisted": true + }, + { + "description": "should match a wildcard rule with *", + "site": "https://testsite.com", + "request": "https://allowlist-tracker-2.com/anything/wildcard.js", + "isAllowlisted": true + }, + { + "description": "wildcard is not regex", + "site": "https://testsite.com", + "request": "https://allowlist-tracker-2.com/anything/wildcard2.js", + "isAllowlisted": false + }, + { + "description": ". is treated as a literal", + "site": "https://testsite.com", + "request": "https://allowlist-tracker-2.com/.23rdsvs/wildcard2.js", + "isAllowlisted": false } ] diff --git a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_reference.json b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_reference.json index 6793559..c866ba4 100644 --- a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_reference.json +++ b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_reference.json @@ -29,6 +29,16 @@ "rule": "allowlist-tracker-2.com/login.js", "domains": [""], "reason": "match single resource on all sites" + }, + { + "rule": "allowlist-tracker-2.com/*/wildcard.js", + "domains": [""], + "reason": "wildcard rule" + }, + { + "rule": "allowlist-tracker-2.com/.*/wildcard2.js", + "domains": [""], + "reason": "wildcard rule with regex syntax" } ] }, From 9670fd03248b4605ce3526fdd3f23bfae0fa9932 Mon Sep 17 00:00:00 2001 From: Sam Macbeth Date: Fri, 16 Feb 2024 09:40:57 +0100 Subject: [PATCH 2/3] Fix test result --- .../TR-domain-matching/tracker_allowlist_matching_tests.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json index 610d926..c087fb5 100644 --- a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json +++ b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json @@ -167,6 +167,6 @@ "description": ". is treated as a literal", "site": "https://testsite.com", "request": "https://allowlist-tracker-2.com/.23rdsvs/wildcard2.js", - "isAllowlisted": false + "isAllowlisted": true } ] From af0b26b90d6d5602645e0b53bec98851626ab336 Mon Sep 17 00:00:00 2001 From: Sam Macbeth Date: Fri, 16 Feb 2024 18:38:10 +0100 Subject: [PATCH 3/3] Reverse tests to take allowlist rule as regex --- .../tracker_allowlist_matching_tests.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json index c087fb5..3a62820 100644 --- a/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json +++ b/tracker-radar-tests/TR-domain-matching/tracker_allowlist_matching_tests.json @@ -152,21 +152,21 @@ "isAllowlisted": true }, { - "description": "should match a wildcard rule with *", + "description": "* alone does not match wildcard", "site": "https://testsite.com", "request": "https://allowlist-tracker-2.com/anything/wildcard.js", - "isAllowlisted": true + "isAllowlisted": false }, { - "description": "wildcard is not regex", + "description": "* works as a regex operator", "site": "https://testsite.com", - "request": "https://allowlist-tracker-2.com/anything/wildcard2.js", - "isAllowlisted": false + "request": "https://allowlist-tracker-2.com/////wildcard.js", + "isAllowlisted": true }, { - "description": ". is treated as a literal", + "description": "Regex .* is treated as a wildcard", "site": "https://testsite.com", - "request": "https://allowlist-tracker-2.com/.23rdsvs/wildcard2.js", + "request": "https://allowlist-tracker-2.com/anything/wildcard2.js", "isAllowlisted": true } ]