From b7152867a334a1fb2068cd5d9b7a6484afeef5c6 Mon Sep 17 00:00:00 2001 From: liqiang-fit2cloud Date: Wed, 5 Nov 2025 16:55:29 +0800 Subject: [PATCH] feat: add MAXKB_SANDBOX_PYTHON_BANNED_HOSTS env to ban host for sandbox in tools code. --- apps/common/utils/tool_code.py | 2 +- installer/Dockerfile | 2 +- sanbox_ban_host.c => installer/sanbox.c | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename sanbox_ban_host.c => installer/sanbox.c (100%) diff --git a/apps/common/utils/tool_code.py b/apps/common/utils/tool_code.py index d21d8a066..a33f6becb 100644 --- a/apps/common/utils/tool_code.py +++ b/apps/common/utils/tool_code.py @@ -197,7 +197,7 @@ exec({dedent(code)!a}) file.write(_code) os.system(f"chown {self.user}:root {exec_python_file}") kwargs = {'cwd': BASE_DIR} - kwargs['env'] = {'LD_PRELOAD': '/opt/maxkb-app/apps/sanbox_ban_host.so'} + kwargs['env'] = {'LD_PRELOAD': '/opt/maxkb-app/apps/sandbox.so'} subprocess_result = subprocess.run( ['su', '-s', python_directory, '-c', "exec(open('" + exec_python_file + "').read())", self.user], text=True, diff --git a/installer/Dockerfile b/installer/Dockerfile index 8e2d3b094..33c35ac10 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update && \ apt-get clean all && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/maxkb-app -RUN gcc -shared -fPIC -o /opt/maxkb-app/apps/sanbox_ban_host.so /opt/maxkb-app/installer/sanbox_ban_host.c -ldl && \ +RUN gcc -shared -fPIC -o /opt/maxkb-app/apps/sandbox.so /opt/maxkb-app/installer/sandbox.c -ldl && \ rm -rf /opt/maxkb-app/ui && \ pip install uv --break-system-packages && \ python -m uv pip install -r pyproject.toml && \ diff --git a/sanbox_ban_host.c b/installer/sanbox.c similarity index 100% rename from sanbox_ban_host.c rename to installer/sanbox.c