Skip to content

feat(base64 cleaner): first iteration #3468

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

john-traas
Copy link
Contributor

@john-traas john-traas commented Feb 28, 2025

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:

  1. Add dimension limits, adding maximum width/height checks for images to prevent extremely large images from being processed.
  2. Improve error messages to make them more user-friendly for end users.
  3. Add progress callbacks for large images to show processing status (might not be needed as file size is limited).
  4. Consider format conversion for better performance, maybe converting all images to a consistent format like WebP.
  5. Add more security tests: Test with actual malicious SVGs and polyglot files.

I have not worked on the tests thoroughly yet.

Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3468/

@john-traas john-traas force-pushed the base64-sanitizer-poc branch 5 times, most recently from 97ca8f4 to 995b44c Compare March 3, 2025 08:56
Copy link

coderabbitai bot commented Mar 3, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in 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.

❤️ Share
🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere 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.

@john-traas john-traas force-pushed the base64-sanitizer-poc branch from 995b44c to 9dd6bf9 Compare March 3, 2025 08:59
@john-traas john-traas force-pushed the base64-sanitizer-poc branch from 9dd6bf9 to 3597cf6 Compare April 11, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant