open-webui
open-webui copied to clipboard
feat: Adds the ability to disable Code Execution
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
- [X] Target branch: Please verify that the pull request targets the
devbranch. - [X] Description: Provide a concise description of the changes made in this pull request.
- [ ] Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
- [ ] Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
- [ ] Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [X] Testing: Have you written and run sufficient tests for validating the changes?
- [X] Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [X] Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
- BREAKING CHANGE: Significant changes that may affect compatibility
- build: Changes that affect the build system or external dependencies
- ci: Changes to our continuous integration processes or workflows
- chore: Refactor, cleanup, or other non-functional code changes
- docs: Documentation update or addition
- feat: Introduces a new feature or enhancement to the codebase
- fix: Bug fix or error correction
- i18n: Internationalization or localization changes
- perf: Performance improvement
- refactor: Code restructuring for better maintainability, readability, or scalability
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
- test: Adding missing tests or correcting existing tests
- WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
I needed the ability to disable Code Execution, purely due to the fact that I know the people I provide this interface to will try and break it with a "write me some code that uses 100% of the CPU and fills up the disk with empty data".
This is purely visual - it doesn't change anything on the backend (as in it doesn't remove or disable Pyodide).
Added
- Added the a toggle switch in the Code Execution Admin Settings page to disable the Run button on Code Blocks within the chat view.
- Added the relevant configuration variables to support the feature.
Changed
N/A
Deprecated
N/A
Removed
N/A
Fixed
N/A
Security
N/A
Breaking Changes
N/A
Screenshots or Videos
Disabling the option hides any Code Execution options and hides the Run button on Code Blocks:
Enabling it shows the settings and the Run button:
Forgive me, but I don't understand Svelte or TypeScript very well. Also I always have issues with Git, hence all the dumb commits :P
This would fulfill a feature request that I have made in the Open WebUI Discord server. Even if this doesn't get merged, I still owe my thanks to you for taking the time to create a PR for this and hacking away at the code to make it happen!
P.S: Your branch has conflicts that must be resolved, although, it can be cleanly merged.
Conflicts are cos you literally released a new version 0.5.19 while I was coding this :P
It relates to the collapsible CodeBlocks. I'm pretty sure they're able to be cleanly merged, but I don't really know what I'm doing regarding the process to resolve them :(
OK, I think I did it.
Rationale for adding this option when pyodide is already sandboxed from the frontend?
I gave that in the description.
@recrudesce yes but pyodide runs on their browser not on the server?
Added with 5e78a5c510c959625120445aaebd279d1731efc2!
@recrudesce yes but pyodide runs on their browser not on the server?
Enabling code execution in Open WebUI allows for arbitrary code execution, which can introduce severe security risks. This is applicable to both the Code Execution Engine and Code Interpreter Engine when configured to utilize a Jupyter/JupyterLabs Notebook. This means that the Run button could be used to execute Python code blocks using a Jupyter/JupyterLabs Notebook, which for me, runs in a Docker container (should be isolated enough from my PC, but you never know what people may attempt to execute).
Added with 5e78a5c!
Looks like you also quickly fixed the "how on earth do i get the damn config setting" problem I had :P I knew it was $config.something.code_execution.enable but I couldn't work out what the something was !