feat: Integrate SandboxJS for secure user JS execution#31
feat: Integrate SandboxJS for secure user JS execution#31
Conversation
…n projects - Added `@nyariv/sandboxjs` (v0.8.33) directly as a bundled library under `public/libs/sandboxjs/sandbox.min.js`. - Implemented `SandboxHtmlProcessor` utility to isolate and secure inline scripts and `on*` event handlers across all iDevice and custom headers. - Integrated `SandboxHtmlProcessor` within `IdeviceRenderer` and `PageRenderer` so that any user-injected `<script>` or event handler logic gets automatically executed under the SandboxJS runtime during HTML5 and SCORM exports, as well as previews. - Ensures cross-compatibility across preview (browser) and offline (Node/esbuild) mode by leveraging `DOMParser` where available or using a regex-based fallback in node. Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…n projects - Added `@nyariv/sandboxjs` (v0.8.33) directly as a bundled library under `public/libs/sandboxjs/sandbox.min.js`. - Implemented `SandboxHtmlProcessor` utility to isolate and secure inline scripts and `on*` event handlers across all iDevice and custom headers. - Integrated `SandboxHtmlProcessor` within `IdeviceRenderer` and `PageRenderer` so that any user-injected `<script>` or event handler logic gets automatically executed under the SandboxJS runtime during HTML5 and SCORM exports, as well as previews. - Ensures cross-compatibility across preview (browser) and offline (Node/esbuild) mode by leveraging `DOMParser` where available or using a regex-based fallback in node. Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
|
Evaluated and integrated
SandboxJSto safely support JavaScript inside.elpxprojects.Changes:
sandbox.min.jsandsandbox.min.js.maptopublic/libs/sandboxjs/.SandboxHtmlProcessorthat isolates user-injected JavaScript. It detects inline<script>tags withoutsrcattributes and inlineon*event handlers inside HTML.try/catchand executes it within thenew Sandbox().compile()()boundary. Default safe globals and standard DOM-access likewindow,document, and timeouts are explicitly allowed so custom user-scripts still work, but safely.IdeviceRenderer.ts(wrapping userhtmlContent) andPageRenderer.ts(wrappingextraHeadContentandextraHeadScripts).SandboxHtmlProcessor.spec.ts) and ran tests in node vs browser build environments, implementing a Regex fallback to prevent esbuild issues whenJSDOMcannot be natively bundled.This correctly fulfills the requirement to secure user-added JS across the standard iDevices text boxes and the project header/footer injections!
PR created automatically by Jules for task 13348126296206032348 started by @erseco