diff --git a/README.md b/README.md index 710cf65..19faa5e 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,7 @@ This repository provides Colab notebooks that allow you to install and use Comfy * NOTE: Before submitting the PR after making changes, please check `Use local DB` and ensure that the extension list loads without any issues in the `Install custom nodes` dialog. Occasionally, missing or extra commas can lead to JSON syntax errors. * The remaining JSON will be updated through scripts in the future, so you don't need to worry about it. + ## Custom node support guide * Currently, the system operates by cloning the git repository and sequentially installing the dependencies listed in requirements.txt using pip, followed by invoking the install.py script. In the future, we plan to discuss and determine the specifications for supporting custom nodes. @@ -336,7 +337,12 @@ When you run the `scan.sh` script: * Currently, `vid2vid` is not being updated, causing compatibility issues. * If you encounter the error message `Overlapped Object has pending operation at deallocation on Comfyui Manager load` under Windows * Edit `config.ini` file: add `windows_selector_event_loop_policy = True` - +* How to disable unsecure features + * Edit `config.ini` file: add `disable_unsecure_features = True` + * If you disable unsecure features these features won't work + * install/uninstall/fix custom nodes + * restore/remove snapshot + * pip install ## TODO: Unconventional form of custom node list diff --git a/glob/manager_core.py b/glob/manager_core.py index d553ca5..81b4007 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -23,7 +23,7 @@ sys.path.append(glob_path) import cm_global from manager_util import * -version = [2, 30, 1] +version = [2, 31] version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '') comfyui_manager_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) @@ -204,7 +204,8 @@ def write_config(): 'double_click_policy': get_config()['double_click_policy'], 'windows_selector_event_loop_policy': get_config()['windows_selector_event_loop_policy'], 'model_download_by_agent': get_config()['model_download_by_agent'], - 'downgrade_blacklist': get_config()['downgrade_blacklist'] + 'downgrade_blacklist': get_config()['downgrade_blacklist'], + 'disable_unsecure_features': get_config()['disable_unsecure_features'], } with open(config_path, 'w') as configfile: config.write(configfile) @@ -230,6 +231,7 @@ def read_config(): 'windows_selector_event_loop_policy': default_conf['windows_selector_event_loop_policy'] if 'windows_selector_event_loop_policy' in default_conf else False, 'model_download_by_agent': default_conf['model_download_by_agent'] if 'model_download_by_agent' in default_conf else False, 'downgrade_blacklist': default_conf['downgrade_blacklist'] if 'downgrade_blacklist' in default_conf else '', + 'disable_unsecure_features': default_conf['disable_unsecure_features'] if 'disable_unsecure_features' in default_conf else False, } except Exception: @@ -246,7 +248,8 @@ def read_config(): 'double_click_policy': 'copy-all', 'windows_selector_event_loop_policy': False, 'model_download_by_agent': False, - 'downgrade_blacklist': '' + 'downgrade_blacklist': '', + 'disable_unsecure_features': False, } @@ -1186,3 +1189,7 @@ def unzip(model_path): os.remove(model_path) return True + + +def is_unsecure_features_disabled(): + return get_config()['disable_unsecure_features'] diff --git a/glob/manager_server.py b/glob/manager_server.py index c643ffe..7076d0c 100644 --- a/glob/manager_server.py +++ b/glob/manager_server.py @@ -551,6 +551,10 @@ async def get_snapshot_list(request): @PromptServer.instance.routes.get("/snapshot/remove") async def remove_snapshot(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the remove feature. Please contact the administrator.") + return web.Response(status=400) + try: target = request.rel_url.query["target"] @@ -565,6 +569,10 @@ async def remove_snapshot(request): @PromptServer.instance.routes.get("/snapshot/restore") async def remove_snapshot(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the restore feature. Please contact the administrator.") + return web.Response(status=400) + try: target = request.rel_url.query["target"] @@ -729,6 +737,10 @@ def copy_set_active(files, is_disable, js_path_name='.'): @PromptServer.instance.routes.post("/customnode/install") async def install_custom_node(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the installation of custom nodes. Please contact the administrator.") + return web.Response(status=400) + json_data = await request.json() install_type = json_data['install_type'] @@ -767,6 +779,10 @@ async def install_custom_node(request): @PromptServer.instance.routes.post("/customnode/fix") async def fix_custom_node(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the fix feature. Please contact the administrator.") + return web.Response(status=400) + json_data = await request.json() install_type = json_data['install_type'] @@ -797,6 +813,10 @@ async def fix_custom_node(request): @PromptServer.instance.routes.post("/customnode/install/git_url") async def install_custom_node_git_url(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the installation of custom nodes. Please contact the administrator.") + return web.Response(status=400) + url = await request.text() res = core.gitclone_install([url]) @@ -809,6 +829,10 @@ async def install_custom_node_git_url(request): @PromptServer.instance.routes.post("/customnode/install/pip") async def install_custom_node_git_url(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the installation of pip package. Please contact the administrator.") + return web.Response(status=400) + packages = await request.text() core.pip_install(packages.split(' ')) @@ -817,6 +841,10 @@ async def install_custom_node_git_url(request): @PromptServer.instance.routes.post("/customnode/uninstall") async def uninstall_custom_node(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the uninstallation of custom nodes. Please contact the administrator.") + return web.Response(status=400) + json_data = await request.json() install_type = json_data['install_type'] @@ -955,6 +983,10 @@ manager_terminal_hook = ManagerTerminalHook() @PromptServer.instance.routes.get("/manager/terminal") async def terminal_mode(request): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the terminal feature. Please contact the administrator.") + return web.Response(status=400) + if "mode" in request.rel_url.query: if request.rel_url.query['mode'] == 'true': sys.__comfyui_manager_terminal_hook.add_hook('cm', manager_terminal_hook) @@ -1078,6 +1110,10 @@ async def get_notice(request): @PromptServer.instance.routes.get("/manager/reboot") def restart(self): + if core.is_unsecure_features_disabled(): + print(f"ERROR: The unsecure feature is disabled, restricting the reboot feature. Please contact the administrator.") + return web.Response(status=400) + try: sys.stdout.close_log() except Exception as e: