feat(base64 cleaner): first iteration
I'm exploring the possibility of having a pipeline to sanitize base64 data.
This implementation includes several security measures:
-
- MIME type validation: Only allows specific image types (JPEG, PNG, GIF, SVG, WebP)
-
- File size limits: Prevents DoS attacks with large files (5MB maximum)
-
- SVG sanitization: Removes potentially malicious scripts and event handlers using DOMPurify
-
- Base64 validation: Ensures the data is actually valid base64 format
-
- URL validation: Only allows HTTP/HTTPS protocols for remote image fetching
-
- Timeout for URL fetching: Prevents hanging on slow resources (10 second limit)
-
- Event handler blocking: Explicitly blocks all event handlers in SVGs (onclick, onload, etc.)
-
- Content hashing: Provides hash generation for caching and integrity verification
This is an initial draft. Further considerations are:
- Add dimension limits, adding maximum width/height checks for images to prevent extremely large images from being processed.
- Improve error messages to make them more user-friendly for end users.
- Add progress callbacks for large images to show processing status (might not be needed as file size is limited).
- Consider format conversion for better performance, maybe converting all images to a consistent format like WebP.
- Add more security tests: Test with actual malicious SVGs and polyglot files.
I have not worked on the tests thoroughly yet.
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3468/
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
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 using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai planto trigger planning for file edits and PR creation. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Closing as this can only really be done server side