-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added rehypeSanitize to improve preview xss issues #323
Conversation
Added rehypeSanitize to handle dangerous markdown Added options for rehypeKatex to ensure formula marking
Important Review skippedReview was skipped due to path filters Files ignored due to path filters (1)
You can disable this status message by setting the WalkthroughThe changes enhance the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- frontend/src/components/editor/Preview.tsx (2 hunks)
Additional comments not posted (1)
frontend/src/components/editor/Preview.tsx (1)
9-9
: Review the import of rehypeSanitize and defaultSchema.The import statement for
rehypeSanitize
anddefaultSchema
is correct and follows standard practices for importing modules in JavaScript/TypeScript.The import statement is correctly implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- frontend/package.json (1 hunks)
Additional comments not posted (1)
frontend/package.json (1)
74-74
: Approved addition ofrehype-sanitize
dependency.The addition of
"rehype-sanitize": "^6.0.0"
to the dependencies is aligned with the PR objectives to enhance security by preventing XSS vulnerabilities. This is a crucial step towards improving the safety of the application's content rendering.The code changes are approved.
Run the following script to verify if additional configurations are needed:
Verification successful
Integration of
rehype-sanitize
verified and approved.The
rehype-sanitize
package is correctly listed as a dependency infrontend/package.json
and is being used infrontend/src/components/editor/Preview.tsx
. This confirms that the integration is in place and aligns with the PR's security objectives. No additional configuration updates are required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for additional configurations or setups needed for `rehype-sanitize`. # Test: Search for configuration files that might need updates. Expect: List of files that might need updates. fd 'config|setup' --type f --exec grep -H 'rehype' {}Length of output: 55
Script:
#!/bin/bash # Description: Search for any usage of `rehype-sanitize` within the codebase to ensure it is correctly integrated. # Test: Search for any file that imports or uses `rehype-sanitize`. rg 'rehype-sanitize' --type js -A 5Length of output: 35
Script:
#!/bin/bash # Description: Search for any usage of `rehype-sanitize` across all file types to ensure it is correctly integrated. # Test: Search for any file that imports or uses `rehype-sanitize`. rg 'rehype-sanitize' -A 5Length of output: 901
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
* Added rehypeSanitize to improve preview xss issues Added rehypeSanitize to handle dangerous markdown Added options for rehypeKatex to ensure formula marking * Add the rehype-sanitize dependency * Add package-lock.json
Added rehypeSanitize to handle dangerous markdown
Added options for rehypeKatex to ensure formula marking
What this PR does / why we need it:
Prevents dangerous HTML from being rendered verbatim to prevent XSS attacks.
Added rehypeSanitize to integrate with existing rehypePlugins to solve the issue
Which issue(s) this PR fixes:
Fixes #320
Special notes for your reviewer:
Added an option to ensure rehypeKatex's expression of formulas.
In addition to the option, the order of rehypeSanitize and rehypeKatex is also important.
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes