From 60b5facaa27609d2800ce853eaf19070458cd814 Mon Sep 17 00:00:00 2001 From: wanhose Date: Sun, 6 Oct 2024 00:40:43 +0200 Subject: [PATCH 1/8] fix(api): use hostname as issue title instead of url --- packages/api/src/routes/v3/report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/routes/v3/report.ts b/packages/api/src/routes/v3/report.ts index 5aedf02..14ed8b1 100644 --- a/packages/api/src/routes/v3/report.ts +++ b/packages/api/src/routes/v3/report.ts @@ -69,7 +69,7 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done: labels: ['bug'], owner: environment.github.owner, repo: environment.github.repo, - title: url, + title: hostname, }); reply.send({ From 7a5f08cf836f2e63f60120f02ddfcae1468c3c30 Mon Sep 17 00:00:00 2001 From: wanhose Date: Sun, 6 Oct 2024 17:23:49 +0200 Subject: [PATCH 2/8] fix(database): issue #706 --- database.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database.json b/database.json index f7120eb..4173e6d 100644 --- a/database.json +++ b/database.json @@ -496,6 +496,7 @@ "||cmp.inmobi.com^", "||cmp.prisa.com^", "||cmp.uniconsent.com^", + "||cms.static-bahn.de/cms/consent-layer^", "||consent.cookiebot.com^", "||consent.cookiefirst.com^", "||consent.pdf24.org^", @@ -13988,5 +13989,5 @@ "ytm-consent-bump-v2-renderer" ] }, - "version": "1728035398000" + "version": "1728228200092" } From 0821d179df8297c28cd7532d1871aa8615a5b9ec Mon Sep 17 00:00:00 2001 From: wanhose Date: Sun, 6 Oct 2024 18:01:03 +0200 Subject: [PATCH 3/8] fix(api): issue #1124 --- packages/api/src/routes/v3/report.ts | 4 ++-- packages/api/src/routes/v4/issues.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/api/src/routes/v3/report.ts b/packages/api/src/routes/v3/report.ts index 14ed8b1..6073ef6 100644 --- a/packages/api/src/routes/v3/report.ts +++ b/packages/api/src/routes/v3/report.ts @@ -32,10 +32,10 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done: const ua = new UAParser(userAgent ?? '').getResult(); const hostname = new URL(url).hostname.split('.').slice(-3).join('.').replace('www.', ''); const existingIssues = await octokit.request('GET /search/issues', { - per_page: 1, + per_page: 50, q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`, }); - const existingIssue = existingIssues.data.items[0]; + const existingIssue = existingIssues.data.items.find((issue) => hostname === issue.title); try { if (existingIssue) { diff --git a/packages/api/src/routes/v4/issues.ts b/packages/api/src/routes/v4/issues.ts index 54d937c..2d11f53 100644 --- a/packages/api/src/routes/v4/issues.ts +++ b/packages/api/src/routes/v4/issues.ts @@ -23,17 +23,17 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done: try { const { hostname } = request.params; const existingIssues = await octokit.request('GET /search/issues', { - per_page: 1, + per_page: 50, q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`, }); - const existingIssue = existingIssues.data.items[0]; + const existingIssue = existingIssues.data.items.find( + (issue) => + hostname === issue.title && + (issue.state === 'open' || + (issue.state === 'closed' && issue.labels.some((label) => label.name === 'wontfix'))) + ); - if ( - existingIssue && - (existingIssue.state === 'open' || - (existingIssue.state === 'closed' && - existingIssue.labels.some((label) => label.name === 'wontfix'))) - ) { + if (existingIssue) { reply.send({ data: { flags: existingIssue.labels.map((label) => label.name), From 0dd3b532c90a4a94b370a8e9ec945b436579b295 Mon Sep 17 00:00:00 2001 From: wanhose Date: Mon, 7 Oct 2024 12:12:47 +0200 Subject: [PATCH 4/8] fix(database): issue #996 --- database.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database.json b/database.json index 4173e6d..1b73dc4 100644 --- a/database.json +++ b/database.json @@ -508,6 +508,7 @@ "||cp.as.com^", "||cp.inside-digital.de^", "||download.amd.com/OneTrust^", + "||driftingchef.com/static/*/Sticky2,ConsentManager", "||emp.bbci.co.uk^", "||eu.fastcmp.com^", "||forum.vorondesign.com/js/xf/notice.min.js^", @@ -13989,5 +13990,5 @@ "ytm-consent-bump-v2-renderer" ] }, - "version": "1728228200092" + "version": "1728295948141" } From 0aad2e7454b0a4845debd5641bda35d4ddfb845e Mon Sep 17 00:00:00 2001 From: wanhose Date: Mon, 7 Oct 2024 12:21:31 +0200 Subject: [PATCH 5/8] fix(database): issue #1018 --- database.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/database.json b/database.json index 1b73dc4..1f07b45 100644 --- a/database.json +++ b/database.json @@ -443,6 +443,12 @@ "domain": "staylibere.com", "selector": "[class*=\"LayoutCookieBanner_buttons\"] > button:last-child" }, + { + "action": "reset", + "domain": "thetvdb.com", + "property": "overflow", + "selector": "body" + }, { "action": "click", "domain": "twitch.tv", @@ -13990,5 +13996,5 @@ "ytm-consent-bump-v2-renderer" ] }, - "version": "1728295948141" + "version": "1728296484406" } From 6f3d0ac12a7a3223634c4361d5056c89ece31421 Mon Sep 17 00:00:00 2001 From: wanhose Date: Mon, 7 Oct 2024 13:21:35 +0200 Subject: [PATCH 6/8] fix(database): issue #1034 --- database.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database.json b/database.json index 1f07b45..8436145 100644 --- a/database.json +++ b/database.json @@ -519,6 +519,7 @@ "||eu.fastcmp.com^", "||forum.vorondesign.com/js/xf/notice.min.js^", "||gdpr-tcfv2.sp-prod.net^", + "||get.optad360.io/sf/*/plugin.min.js", "||ilims.de/typo3conf/ext/nb_cookie_banner^", "||itkadmin.de/_javascripts/cookiesolution/es_cookie_solution_sources_v2.js^", "||js.vxcdn.com/usercentrics-sdk^", @@ -13996,5 +13997,5 @@ "ytm-consent-bump-v2-renderer" ] }, - "version": "1728296484406" + "version": "1728300083309" } From b7bf1c1e2b0f29c8edd70be4cce684d89c1081bc Mon Sep 17 00:00:00 2001 From: wanhose Date: Mon, 7 Oct 2024 13:43:18 +0200 Subject: [PATCH 7/8] docs(browser-extension): bump minimum chrome/edge version --- packages/browser-extension/docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/browser-extension/docs/README.md b/packages/browser-extension/docs/README.md index c116634..26d284e 100644 --- a/packages/browser-extension/docs/README.md +++ b/packages/browser-extension/docs/README.md @@ -11,9 +11,9 @@ ## Compatibility -- All browsers based on Chromium 88+ (Blisk, Brave, Colibri, Epic Browser, Iron Browser, Vivaldi and many more) -- Google Chrome 109+ -- Microsoft Edge 109+ +- All browsers based on Chromium 124+ (Blisk, Brave, Colibri, Epic Browser, Iron Browser, Vivaldi and many more) +- Google Chrome 124+ +- Microsoft Edge 124+ - Mozilla Firefox 126+ - Mozilla Firefox Mobile 126+ From c6faa2796befd7e618acb2ba2a0d2957a4c9f0b1 Mon Sep 17 00:00:00 2001 From: wanhose Date: Thu, 10 Oct 2024 11:43:13 +0200 Subject: [PATCH 8/8] feat(api): add issues and version endpoints --- packages/api/src/index.ts | 10 +- packages/api/src/routes/v1/entries.ts | 4 +- packages/api/src/routes/v1/report.ts | 2 +- packages/api/src/routes/v2/data.ts | 10 +- packages/api/src/routes/v2/report.ts | 2 +- packages/api/src/routes/v3/data.ts | 6 +- packages/api/src/routes/v3/report.ts | 15 ++- packages/api/src/routes/v4/data.ts | 44 ++++--- packages/api/src/routes/v5/data.ts | 1 + packages/api/src/routes/{v4 => v5}/issues.ts | 0 packages/api/src/routes/v5/report.ts | 114 +++++++++++++++++++ packages/api/src/routes/v5/version.ts | 27 +++++ packages/api/src/services/environment.ts | 1 + 13 files changed, 192 insertions(+), 44 deletions(-) create mode 100644 packages/api/src/routes/v5/data.ts rename packages/api/src/routes/{v4 => v5}/issues.ts (100%) create mode 100644 packages/api/src/routes/v5/report.ts create mode 100644 packages/api/src/routes/v5/version.ts diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index e5e28fe..788b2d2 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -8,8 +8,11 @@ import v2ReportRoutes from 'routes/v2/report'; import v3DataRoutes from 'routes/v3/data'; import v3ReportRoutes from 'routes/v3/report'; import v4DataRoutes from 'routes/v4/data'; -import v4IssuesRoutes from 'routes/v4/issues'; import v4ReportRoutes from 'routes/v4/report'; +import v5DataRoutes from 'routes/v5/data'; +import v5IssuesRoutes from 'routes/v5/issues'; +import v5ReportRoutes from 'routes/v5/report'; +import v5VersionRoutes from 'routes/v5/version'; import environment from 'services/environment'; const server = fastify({ logger: true }); @@ -35,8 +38,11 @@ server.register(v2ReportRoutes, { prefix: '/rest/v2' }); server.register(v3DataRoutes, { prefix: '/rest/v3' }); server.register(v3ReportRoutes, { prefix: '/rest/v3' }); server.register(v4DataRoutes, { prefix: '/rest/v4' }); -server.register(v4IssuesRoutes, { prefix: '/rest/v4' }); server.register(v4ReportRoutes, { prefix: '/rest/v4' }); +server.register(v5DataRoutes, { prefix: '/rest/v5' }); +server.register(v5IssuesRoutes, { prefix: '/rest/v5' }); +server.register(v5ReportRoutes, { prefix: '/rest/v5' }); +server.register(v5VersionRoutes, { prefix: '/rest/v5' }); server.listen({ host: '0.0.0.0', port: environment.port }, (error, address) => { if (error) { diff --git a/packages/api/src/routes/v1/entries.ts b/packages/api/src/routes/v1/entries.ts index 24f7d38..63c2f5c 100644 --- a/packages/api/src/routes/v1/entries.ts +++ b/packages/api/src/routes/v1/entries.ts @@ -3,8 +3,8 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; /** * @deprecated This API route is no longer supported. Please use a newer version */ -export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { - server.get('/entries/', async (request, reply) => { +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { + server.get('/entries/', async (_request, reply) => { reply.send({ success: false, errors: ['This API route is no longer supported. Please use a newer version'], diff --git a/packages/api/src/routes/v1/report.ts b/packages/api/src/routes/v1/report.ts index 4bedb23..6ec6f57 100644 --- a/packages/api/src/routes/v1/report.ts +++ b/packages/api/src/routes/v1/report.ts @@ -3,7 +3,7 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; /** * @deprecated This API route is no longer supported. Please use a newer version */ -export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { server.post('/report/', {}, async (_request, reply) => { reply.send({ success: false, diff --git a/packages/api/src/routes/v2/data.ts b/packages/api/src/routes/v2/data.ts index ea4e28c..fa0087a 100644 --- a/packages/api/src/routes/v2/data.ts +++ b/packages/api/src/routes/v2/data.ts @@ -1,13 +1,13 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import fetch from 'node-fetch'; import { parseNewFix } from 'services/compatibility'; +import environment from 'services/environment'; -export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { - server.get('/data/', async (request, reply) => { +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { + server.get('/data/', async (_request, reply) => { try { - const databaseUrl = - 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main/database.json'; - const result = await (await fetch(databaseUrl)).json(); + const url = `${environment.github.files}/database.json`; + const result = await (await fetch(url)).json(); reply.send({ data: { diff --git a/packages/api/src/routes/v2/report.ts b/packages/api/src/routes/v2/report.ts index 538d3e4..140d57c 100644 --- a/packages/api/src/routes/v2/report.ts +++ b/packages/api/src/routes/v2/report.ts @@ -18,7 +18,7 @@ const PostReportBodySchema = yup.object().shape({ type PostReportBody = yup.InferType; -export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { server.post<{ Body: PostReportBody }>( '/report/', { diff --git a/packages/api/src/routes/v3/data.ts b/packages/api/src/routes/v3/data.ts index 9a48108..4dfcaa2 100644 --- a/packages/api/src/routes/v3/data.ts +++ b/packages/api/src/routes/v3/data.ts @@ -1,13 +1,13 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import fetch from 'node-fetch'; import { parseNewFix } from 'services/compatibility'; +import environment from 'services/environment'; export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { server.get('/data/', async (_request, reply) => { try { - const databaseUrl = - 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main/database.json'; - const result = await (await fetch(databaseUrl)).json(); + const url = `${environment.github.files}/database.json`; + const result = await (await fetch(url)).json(); reply.send({ data: { diff --git a/packages/api/src/routes/v3/report.ts b/packages/api/src/routes/v3/report.ts index 6073ef6..9fa1c89 100644 --- a/packages/api/src/routes/v3/report.ts +++ b/packages/api/src/routes/v3/report.ts @@ -35,25 +35,30 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done: per_page: 50, q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`, }); - const existingIssue = existingIssues.data.items.find((issue) => hostname === issue.title); + const existingIssue = existingIssues.data.items.find( + (issue) => + hostname === issue.title && + (issue.state === 'open' || + (issue.state === 'closed' && issue.labels.some((label) => label.name === 'wontfix'))) + ); try { if (existingIssue) { if (existingIssue.state === 'closed') { await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { - owner: environment.github.owner, - repo: environment.github.repo, issue_number: existingIssue.number, labels: ['bug'], + owner: environment.github.owner, + repo: environment.github.repo, state: 'open', }); } await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', { + body: generateText(request.body, ua), + issue_number: existingIssue.number, owner: environment.github.owner, repo: environment.github.repo, - issue_number: existingIssue.number, - body: generateText(request.body, ua), }); reply.send({ diff --git a/packages/api/src/routes/v4/data.ts b/packages/api/src/routes/v4/data.ts index 068dced..d7efbfd 100644 --- a/packages/api/src/routes/v4/data.ts +++ b/packages/api/src/routes/v4/data.ts @@ -1,38 +1,18 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import fetch from 'node-fetch'; +import environment from 'services/environment'; export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { server.get('/data/', async (_request, reply) => { try { - const databaseUrl = - 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main/database.json'; - const fetchOptions = { - headers: { 'Cache-Control': 'no-cache' }, - }; - const { rules, ...result } = await (await fetch(databaseUrl, fetchOptions)).json(); + const options = { headers: { 'Cache-Control': 'no-cache' } }; + const url = `${environment.github.files}/database.json`; + const { rules, ...result } = await (await fetch(url, options)).json(); reply.send({ data: { ...result, - rules: (rules as readonly string[]).map((urlFilter, index) => ({ - id: index + 1, - priority: 1, - action: { - type: 'block', - }, - condition: { - resourceTypes: [ - 'font', - 'image', - 'media', - 'object', - 'script', - 'stylesheet', - 'xmlhttprequest', - ], - urlFilter, - }, - })), + rules: rules.map(toDeclarativeNetRequestRule), }, success: true, }); @@ -46,3 +26,17 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done: done(); }; + +function toDeclarativeNetRequestRule(urlFilter: string, index: number) { + return { + action: { + type: 'block', + }, + condition: { + resourceTypes: ['font', 'image', 'media', 'object', 'script', 'stylesheet', 'xmlhttprequest'], + urlFilter, + }, + id: index + 1, + priority: 1, + }; +} diff --git a/packages/api/src/routes/v5/data.ts b/packages/api/src/routes/v5/data.ts new file mode 100644 index 0000000..326d8e9 --- /dev/null +++ b/packages/api/src/routes/v5/data.ts @@ -0,0 +1 @@ +export { default as default } from '../v4/data'; diff --git a/packages/api/src/routes/v4/issues.ts b/packages/api/src/routes/v5/issues.ts similarity index 100% rename from packages/api/src/routes/v4/issues.ts rename to packages/api/src/routes/v5/issues.ts diff --git a/packages/api/src/routes/v5/report.ts b/packages/api/src/routes/v5/report.ts new file mode 100644 index 0000000..5f2362c --- /dev/null +++ b/packages/api/src/routes/v5/report.ts @@ -0,0 +1,114 @@ +import { FastifyInstance, RouteShorthandOptions } from 'fastify'; +import environment from 'services/environment'; +import { octokit } from 'services/octokit'; +import { validatorCompiler } from 'services/validation'; +import { UAParser } from 'ua-parser-js'; +import * as yup from 'yup'; + +const PostReportBodySchema = yup.object().shape({ + reason: yup.string().min(10).max(1000).required(), + url: yup.string().max(1000).url().required(), + userAgent: yup.string().max(1000).optional(), + version: yup + .string() + .max(10) + .matches(/^\d+(\.\d+){0,3}$/) + .required(), +}); + +type PostReportBody = yup.InferType; + +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { + server.post<{ Body: PostReportBody }>( + '/report/', + { + schema: { + body: PostReportBodySchema, + }, + validatorCompiler, + }, + async (request, reply) => { + const { reason, url, userAgent, version } = request.body; + const ua = new UAParser(userAgent ?? '').getResult(); + const hostname = new URL(url).hostname.split('.').slice(-3).join('.').replace('www.', ''); + const existingIssues = await octokit.request('GET /search/issues', { + per_page: 50, + q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`, + }); + const existingIssue = existingIssues.data.items.find((issue) => hostname === issue.title); + + try { + if (existingIssue) { + if (existingIssue.labels.some((label) => label.name === 'wontfix')) { + reply.send({ + data: existingIssue.html_url, + errors: ['This issue has been marked as "wontfix" and will not be addressed.'], + success: false, + }); + return; + } + + if (existingIssue.state === 'open') { + reply.send({ + data: existingIssue.html_url, + errors: [ + 'This issue already exists. Please refer to the existing issue for updates.', + ], + success: false, + }); + return; + } + + await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { + issue_number: existingIssue.number, + labels: ['bug'], + owner: environment.github.owner, + repo: environment.github.repo, + state: 'open', + }); + + reply.send({ + data: existingIssue.html_url, + success: true, + }); + return; + } + + const response = await octokit.request('POST /repos/{owner}/{repo}/issues', { + assignees: [environment.github.owner], + body: [ + '## Issue information', + ...(ua.browser.name && ua.browser.version + ? ['#### 🖥️ Browser', `${ua.browser.name} (${ua.browser.version})`] + : []), + ...(ua.device.type && ua.device.vendor + ? ['#### 📱 Device', `${ua.device.vendor} (${ua.device.type})`] + : []), + '#### 📝 Reason', + reason, + '#### 🔗 URL', + url, + '#### 🏷️ Version', + version, + ].join('\n'), + labels: ['bug'], + owner: environment.github.owner, + repo: environment.github.repo, + title: hostname, + }); + + reply.send({ + data: response.data.html_url, + success: true, + }); + } catch (error) { + reply.send({ + errors: [error.message], + success: false, + }); + } + } + ); + + done(); +}; diff --git a/packages/api/src/routes/v5/version.ts b/packages/api/src/routes/v5/version.ts new file mode 100644 index 0000000..f6b7b51 --- /dev/null +++ b/packages/api/src/routes/v5/version.ts @@ -0,0 +1,27 @@ +import { FastifyInstance, RouteShorthandOptions } from 'fastify'; +import fetch from 'node-fetch'; +import environment from 'services/environment'; + +export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => { + server.get('/version/', async (_request, reply) => { + try { + const options = { headers: { 'Cache-Control': 'no-cache' } }; + const url = `${environment.github.files}/packages/browser-extension/src/manifest.json`; + const { version } = await (await fetch(url, options)).json(); + + reply.send({ + data: { + version, + }, + success: true, + }); + } catch (error) { + reply.send({ + errors: [error.message], + success: false, + }); + } + }); + + done(); +}; diff --git a/packages/api/src/services/environment.ts b/packages/api/src/services/environment.ts index 07ccce8..85e1bf8 100644 --- a/packages/api/src/services/environment.ts +++ b/packages/api/src/services/environment.ts @@ -1,5 +1,6 @@ export default { github: { + files: 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main', owner: 'wanhose', repo: 'cookie-dialog-monster', token: process.env.GITHUB_TOKEN ?? '',