Skip to content

Commit 6e39df4

Browse files
refactor: rename MAXKB_SANDBOX_PYTHON_ALLOW_HOSTS_REGEXES to MAXKB_SANDBOX_PYTHON_ALLOW_HOST_REGEXES
1 parent 6ac1078 commit 6e39df4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

apps/common/utils/tool_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, sandbox=False):
2828
if self.sandbox:
2929
os.system(f"chown -R {self.user}:root {self.sandbox_path}")
3030
self.banned_keywords = CONFIG.get("SANDBOX_PYTHON_BANNED_KEYWORDS", 'nothing_is_banned').split(',');
31-
self.allow_hosts_regexes = CONFIG.get("SANDBOX_PYTHON_ALLOW_HOSTS_REGEXES", '');
31+
self.allow_host_regexes = CONFIG.get("SANDBOX_PYTHON_ALLOW_HOST_REGEXES", '');
3232

3333
def _createdir(self):
3434
old_mask = os.umask(0o077)
@@ -183,7 +183,7 @@ def get_tool_mcp_config(self, code, params):
183183
'cwd': self.sandbox_path,
184184
'env': {
185185
'LD_PRELOAD': '/opt/maxkb-app/sandbox/sandbox.so',
186-
'SANDBOX_ALLOW_HOSTS_REGEXES': self.allow_hosts_regexes,
186+
'SANDBOX_ALLOW_HOST_REGEXES': self.allow_host_regexes,
187187
},
188188
'transport': 'stdio',
189189
}
@@ -203,7 +203,7 @@ def _exec_sandbox(self, _code, _id):
203203
kwargs = {'cwd': BASE_DIR}
204204
kwargs['env'] = {
205205
'LD_PRELOAD': '/opt/maxkb-app/sandbox/sandbox.so',
206-
'SANDBOX_ALLOW_HOSTS_REGEXES': self.allow_hosts_regexes,
206+
'SANDBOX_ALLOW_HOST_REGEXES': self.allow_host_regexes,
207207
}
208208
subprocess_result = subprocess.run(
209209
['su', '-s', python_directory, '-c', "exec(open('" + exec_python_file + "').read())", self.user],

installer/Dockerfile-base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ENV PATH=/opt/py3/bin:$PATH \
4747
MAXKB_SANDBOX=1 \
4848
MAXKB_SANDBOX_PYTHON_PACKAGE_PATHS="/opt/py3/lib/python3.11/site-packages,/opt/maxkb-app/sandbox/python-packages,/opt/maxkb/python-packages" \
4949
MAXKB_SANDBOX_PYTHON_BANNED_KEYWORDS="subprocess.,system(,exec(,execve(,pty.,eval(,compile(,shutil.,input(,__import__" \
50-
MAXKB_SANDBOX_PYTHON_ALLOW_HOSTS_REGEXES=".*,!=127\.0\.0\.1,!=localhost,!=maxkb,!=pgsql,!=redis" \
50+
MAXKB_SANDBOX_PYTHON_ALLOW_HOST_REGEXES=".*,!=127\.0\.0\.1,!=localhost,!=maxkb,!=pgsql,!=redis" \
5151
MAXKB_ADMIN_PATH=/admin
5252

5353
EXPOSE 6379

installer/sandbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int is_allowed_by_env(const char *target, const char *env_val) {
6565

6666
/** 检查逻辑封装 */
6767
static int check_host(const char *host) {
68-
const char *env = getenv("SANDBOX_ALLOW_HOSTS_REGEXES");
68+
const char *env = getenv("SANDBOX_ALLOW_HOST_REGEXES");
6969
return is_allowed_by_env(host, env);
7070
}
7171

0 commit comments

Comments
 (0)