Skip to content

Canary 07032024 #29

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

Merged
merged 4 commits into from
Mar 8, 2024
Merged

Canary 07032024 #29

merged 4 commits into from
Mar 8, 2024

Conversation

soranoo
Copy link
Owner

@soranoo soranoo commented Mar 8, 2024

Added Support to Alphabetic Simplify #26

Fixed #27

Fixed #25 & Replaced Jest with Vitest

[#] Renamed the old "simplify" mode to "simplify-seedable"
[+] Added alphabetic simplify mode as "simplify"

Summary by CodeRabbit

  • New Features

    • Introduced a new obfuscation mode, "simplify-seedable", for class name generation.
    • Added a function to obfuscate HTML class names using a robust HTML parser, supporting selective obfuscation within marked subtrees.
  • Bug Fixes

    • Improved recognition of CSS action selectors for more accurate class extraction.
  • Refactor

    • Unified and simplified HTML obfuscation logic for better maintainability.
    • Enhanced string simplification and key encoding utilities.
  • Documentation

    • Updated documentation to include the new obfuscation mode and clarify configuration options.
  • Tests

    • Migrated test framework to Vitest and expanded test coverage for new and existing features.
  • Chores

    • Updated dependencies and scripts to support the new test framework and features.

soranoo added 4 commits March 7, 2024 02:35
[#] Renamed the old "simplify" mode to "simplify-seedable"
[+] Added alphabetic simplify mode as "simplify"
Copy link

vercel bot commented Mar 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
next-css-obfuscator ✅ Ready (Inspect) Visit Preview Mar 8, 2024 0:53am

@soranoo soranoo merged commit 374ba8c into main Mar 8, 2024
@soranoo soranoo deleted the canary-07032024 branch March 8, 2024 00:54
@soranoo soranoo restored the canary-07032024 branch March 8, 2024 10:22
@soranoo soranoo deleted the canary-07032024 branch March 12, 2024 14:02
Copy link

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

coderabbitai bot commented Apr 25, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a new obfuscation mode, "simplify-seedable", across the codebase, documentation, and configuration types. The obfuscation logic in the CSS handler is refactored to support this mode and to change the "simplify" mode to use a global counter for class name generation. Test files are migrated from Jest to Vitest, with corresponding dependency updates. The HTML handler gains a new function, obfuscateHtmlClassNames, utilizing htmlparser2 for more robust class name obfuscation, and the previous HTML extraction functions are deprecated. Utility functions for string simplification and key encoding/decoding are added and improved, while test coverage is expanded.

Changes

Files/Group Change Summary
README.md, src/types.ts, src/config.ts Added "simplify-seedable" obfuscation mode to documentation, types, and default config. Clarified generatorSeed applicability.
package.json Switched testing framework from Jest to Vitest; updated scripts and dependencies; incremented version to 2.2.11; added htmlparser2.
src/handlers/css.ts Added "simplify-seedable" mode in class name generation; changed "simplify" mode to use global counter; updated action selector regex to include >; refactored class extraction to use external key utilities.
src/handlers/html.ts Added obfuscateHtmlClassNames using htmlparser2 for scoped HTML class obfuscation; marked previous extraction functions as deprecated; updated exports.
src/utils.ts Unified HTML obfuscation logic; improved HTML entity handling; added/renamed string simplification and key encoding/decoding utilities; updated exports.
src/utils.test.ts Updated and expanded tests for string simplification; added tests for new/renamed functions; improved test structure.
src/handlers/html.test.ts Added comprehensive tests for obfuscateHtmlClassNames; preserved and commented old tests as deprecated.
src/handlers/css.test.ts, src/handlers/js-ast.test.ts, src/handlers/js.test.ts Migrated test imports to use Vitest; minor selector and function name adjustments in CSS tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HTMLHandler
    participant htmlparser2
    participant SelectorConversionMap

    User->>HTMLHandler: call obfuscateHtmlClassNames(html, selectorConversion, markerClass)
    HTMLHandler->>htmlparser2: parse html
    htmlparser2-->>HTMLHandler: emit tags and text
    HTMLHandler->>SelectorConversionMap: lookup class obfuscation
    HTMLHandler->>htmlparser2: reconstruct HTML with obfuscated classes
    HTMLHandler-->>User: return { html: obfuscatedHtml, usedKeys }
Loading
sequenceDiagram
    participant CSSHandler
    participant Utils

    CSSHandler->>Utils: createNewClassName(className, mode, ...)
    alt mode == "random"
        Utils-->>CSSHandler: generate random class name
    else mode == "simplify"
        Utils-->>CSSHandler: generate class name using global counter
    else mode == "simplify-seedable"
        Utils-->>CSSHandler: generate class name using seed and className
    end
    CSSHandler-->>Caller: return obfuscated class name
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Correct action pseudo-class selector matching for selectors with three : (e.g., first:*:hover:rotate-180) (#27)
Prevent detection/obfuscation of dark and light in [data-theme] attributes as class names (#25)

Poem

🐇
A new mode hops in, "simplify-seedable" shines,
With Vitest for tests and robust HTML lines.
No more class confusion, selectors now right,
Pseudo-classes and data-themes hop out of sight.
Keys wrapped in base64, obfuscation anew—
This bunny’s delighted, the code’s fresh as dew!
🌱✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1921b7 and d599859.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • README.md (6 hunks)
  • package.json (2 hunks)
  • src/config.ts (1 hunks)
  • src/handlers/css.test.ts (3 hunks)
  • src/handlers/css.ts (3 hunks)
  • src/handlers/html.test.ts (1 hunks)
  • src/handlers/html.ts (1 hunks)
  • src/handlers/js-ast.test.ts (1 hunks)
  • src/handlers/js.test.ts (1 hunks)
  • src/types.ts (1 hunks)
  • src/utils.test.ts (7 hunks)
  • src/utils.ts (9 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

🎉 This PR is included in version 3.0.0-beta.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant