-
Notifications
You must be signed in to change notification settings - Fork 0
Update deps #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Update deps #99
Conversation
* missing : tables, nested list styles, checklists
* faker v10 is not compatible with jest : https://v10.fakerjs.dev/guide/upgrading.html#incompatibility-with-jest
| return html | ||
| .replaceAll('class=""', '') | ||
| .replaceAll(/(?<=<[^>]+)(?<!\w|")\s+(?=[^>]*>)|(?<=<[^>]*(?:\w|"))\s+(?=>)/g, ''); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<script
This string may still contain
<script
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 16 days ago
The recommended fix is to ensure that the output HTML is properly sanitized. The best and safest method is to use a well-tested library for HTML sanitization, such as sanitize-html. This library will reliably strip all dangerous tags and attributes (such as <script>, <style>, on* event handlers, etc.), and keep only safe markup.
Steps:
- Import the
sanitize-htmllibrary at the top. - In the
generateHTMLfunction, after the string manipulations, pass the result throughsanitizeHtmlbefore returning. - You only need to edit the
generateHTMLmethod and add the import. - No changes to the rest of the code are needed, and no behavior is altered except ensuring HTML is now safe.
-
Copy modified line R2 -
Copy modified lines R130-R134
| @@ -1,4 +1,5 @@ | ||
| import { Module } from '@nestjs/common'; | ||
| import sanitizeHtml from 'sanitize-html'; | ||
| import { TextNode, ParagraphNode } from 'lexical'; | ||
| import { createHeadlessEditor } from '@lexical/headless'; | ||
| import { $generateHtmlFromNodes } from '@lexical/html'; | ||
| @@ -126,8 +127,10 @@ | ||
| editor.setEditorState(editor.parseEditorState(parsed)); | ||
| editor.read(() => (html = $generateHtmlFromNodes(editor))); | ||
| }); | ||
| return html | ||
| .replaceAll('class=""', '') | ||
| .replaceAll(/(?<=<[^>]+)(?<!\w|")\s+(?=[^>]*>)|(?<=<[^>]*(?:\w|"))\s+(?=>)/g, ''); | ||
| return sanitizeHtml( | ||
| html | ||
| .replaceAll('class=""', '') | ||
| .replaceAll(/(?<=<[^>]+)(?<!\w|")\s+(?=[^>]*>)|(?<=<[^>]*(?:\w|"))\s+(?=>)/g, '') | ||
| ); | ||
| } | ||
| } |
-
Copy modified lines R75-R76
| @@ -72,7 +72,8 @@ | ||
| "prisma": "^6.19.0", | ||
| "reflect-metadata": "^0.2.2", | ||
| "rxjs": "^7.8.2", | ||
| "sharp": "^0.34.5" | ||
| "sharp": "^0.34.5", | ||
| "sanitize-html": "^2.17.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@faker-js/faker": "^9.9.0", |
| Package | Version | Security advisories |
| sanitize-html (npm) | 2.17.0 | None |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #99 +/- ##
==========================================
- Coverage 83.19% 79.29% -3.91%
==========================================
Files 140 119 -21
Lines 2398 2347 -51
Branches 470 387 -83
==========================================
- Hits 1995 1861 -134
+ Misses 398 372 -26
- Partials 5 114 +109 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Mise à jour des dépendances de l'api (basé sur
feat/lexical-generator)Faker v10 n'est pas compatible avec jest, il existe un workaround qui consiste à utiliser babel... Mais c'est un peu lourd pour les test, non ? Si on décide d'utiliser babel parce que jest ne supporte les packages pure-esm, on pourra réintroduire les tests unitaires de lexical (cf. #97)