Skip to content

Commit 1f4d6d1

Browse files
feat: add MAXKB_SANDBOX_PYTHON_BANNED_HOSTS env to ban host for sandbox in tools code.
1 parent f0be269 commit 1f4d6d1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/common/utils/tool_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def exec_code(self, code_str, keywords):
5454
path_to_exclude = ['/opt/py3/lib/python3.11/site-packages', '/opt/maxkb-app/apps']
5555
sys.path = [p for p in sys.path if p not in path_to_exclude]
5656
sys.path += {python_paths}
57+
os.environ['MAXKB_SANDBOX_PYTHON_BANNED_HOSTS'] = '{self.banned_hosts}'
5758
os.environ['LD_PRELOAD'] = '/opt/maxkb-app/sandbox/sandbox.so'
58-
os.environ['SANDBOX_BANNED_HOSTS'] = {self.banned_hosts}
5959
locals_v={'{}'}
6060
keywords={keywords}
6161
globals_v=globals()
@@ -162,8 +162,8 @@ def generate_mcp_server_code(self, code_str, params):
162162
path_to_exclude = ['/opt/py3/lib/python3.11/site-packages', '/opt/maxkb-app/apps']
163163
sys.path = [p for p in sys.path if p not in path_to_exclude]
164164
sys.path += {python_paths}
165+
os.environ['MAXKB_SANDBOX_PYTHON_BANNED_HOSTS'] = '{self.banned_hosts}'
165166
os.environ['LD_PRELOAD'] = '/opt/maxkb-app/sandbox/sandbox.so'
166-
os.environ['SANDBOX_BANNED_HOSTS'] = {self.banned_hosts}
167167
exec({dedent(code)!a})
168168
"""
169169

installer/sandbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <regex.h>
99
#include <unistd.h>
1010

11-
static const char *ENV_NAME = "SANDBOX_BANNED_HOSTS";
11+
static const char *ENV_NAME = "MAXKB_SANDBOX_PYTHON_BANNED_HOSTS";
1212

1313
static int match_env_patterns(const char *target, const char *env_val) {
1414
if (!target || !env_val || !*env_val) return 0;

0 commit comments

Comments
 (0)