From 34b9fb635f1b559a04597d93244372727a31f0e4 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 4 Jul 2023 17:48:48 +0100 Subject: [PATCH 1/4] feat: add dependency: dompurify To sanitize markdown in torrent description. --- package-lock.json | 22 ++++++++++++++++++++++ package.json | 2 ++ project-words.txt | 1 + 3 files changed, 25 insertions(+) diff --git a/package-lock.json b/package-lock.json index c8128eb8..02dc0887 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "dependencies": { "@heroicons/vue": "^2.0.18", "daisyui": "^3.1.7", + "dompurify": "^3.0.4", "marked": "^5.1.0", "notiwind-ts": "^2.0.2", "torrust-index-api-lib": "^0.2.0", @@ -18,6 +19,7 @@ "@nuxtjs/eslint-config-typescript": "^12.0.0", "@nuxtjs/tailwindcss": "^6.8.0", "@tailwindcss/typography": "^0.5.9", + "@types/dompurify": "^3.0.2", "@types/marked": "^5.0.0", "@types/node": "^20.3.2", "@typescript-eslint/eslint-plugin": "^5.60.0", @@ -2826,6 +2828,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@types/dompurify": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.2.tgz", + "integrity": "sha512-YBL4ziFebbbfQfH5mlC+QTJsvh0oJUrWbmxKMyEdL7emlHJqGR2Qb34TEFKj+VCayBvjKy3xczMFNhugThUsfQ==", + "dev": true, + "dependencies": { + "@types/trusted-types": "*" + } + }, "node_modules/@types/eslint": { "version": "8.40.2", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.40.2.tgz", @@ -2922,6 +2933,12 @@ "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==", "dev": true }, + "node_modules/@types/trusted-types": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.3.tgz", + "integrity": "sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==", + "dev": true + }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -6512,6 +6529,11 @@ "url": "https://github.com/fb55/domhandler?sponsor=1" } }, + "node_modules/dompurify": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.4.tgz", + "integrity": "sha512-ae0mA+Qiqp6C29pqZX3fQgK+F91+F7wobM/v8DRzDqJdZJELXiFUx4PP4pK/mzUS0xkiSEx3Ncd9gr69jg3YsQ==" + }, "node_modules/domutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", diff --git a/package.json b/package.json index a88fb3f5..b9636041 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@nuxtjs/eslint-config-typescript": "^12.0.0", "@nuxtjs/tailwindcss": "^6.8.0", "@tailwindcss/typography": "^0.5.9", + "@types/dompurify": "^3.0.2", "@types/marked": "^5.0.0", "@types/node": "^20.3.2", "@typescript-eslint/eslint-plugin": "^5.60.0", @@ -32,6 +33,7 @@ "dependencies": { "@heroicons/vue": "^2.0.18", "daisyui": "^3.1.7", + "dompurify": "^3.0.4", "marked": "^5.1.0", "notiwind-ts": "^2.0.2", "torrust-index-api-lib": "^0.2.0", diff --git a/project-words.txt b/project-words.txt index 1a1ceb01..7bfebf84 100644 --- a/project-words.txt +++ b/project-words.txt @@ -1,4 +1,5 @@ composables +dompurify heroicons notiwind Nuxt From 914373693ef724058388d323d6d7d8959006cc90 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 4 Jul 2023 18:11:44 +0100 Subject: [PATCH 2/4] feat: sanitize torrent description in markdown - Purify HTML to avoid potencial XSS attacks. - Remove external URLS to protect users' privacy. --- components/Markdown.vue | 114 +++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/components/Markdown.vue b/components/Markdown.vue index 7ceeb81d..7156d48a 100644 --- a/components/Markdown.vue +++ b/components/Markdown.vue @@ -6,6 +6,7 @@