pyddock 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyddock-0.2.4/.hypothesis/.gitignore +9 -0
- pyddock-0.2.4/.hypothesis/constants/106d94c8123c0256 +4 -0
- pyddock-0.2.4/.hypothesis/constants/1685e03b3aa38c02 +4 -0
- pyddock-0.2.4/.hypothesis/constants/1deca112ec6f2f3c +4 -0
- pyddock-0.2.4/.hypothesis/constants/2488a3a95c48acfb +4 -0
- pyddock-0.2.4/.hypothesis/constants/2a94d83a13979745 +4 -0
- pyddock-0.2.4/.hypothesis/constants/499f1d5a639a382a +4 -0
- pyddock-0.2.4/.hypothesis/constants/4ee6f24fa151b65d +4 -0
- pyddock-0.2.4/.hypothesis/constants/5b1b2189b70f5ef2 +4 -0
- pyddock-0.2.4/.hypothesis/constants/5d6f8b26b2137fe1 +4 -0
- pyddock-0.2.4/.hypothesis/constants/61f9b905d7da14e0 +4 -0
- pyddock-0.2.4/.hypothesis/constants/67a7f4ab2d372f23 +4 -0
- pyddock-0.2.4/.hypothesis/constants/6c6f5083ece3f86b +4 -0
- pyddock-0.2.4/.hypothesis/constants/827e18b40f235443 +4 -0
- pyddock-0.2.4/.hypothesis/constants/8401e4039d635fbc +4 -0
- pyddock-0.2.4/.hypothesis/constants/8490e7baefc8c8c3 +4 -0
- pyddock-0.2.4/.hypothesis/constants/a7c132b836381d0d +4 -0
- pyddock-0.2.4/.hypothesis/constants/b395547bc71e5c52 +4 -0
- pyddock-0.2.4/.hypothesis/constants/ca50661510a40488 +4 -0
- pyddock-0.2.4/.hypothesis/tmp/tmpl8oe65gb +0 -0
- pyddock-0.2.4/.hypothesis/tmp/tmpqwper0dp +0 -0
- pyddock-0.2.4/.hypothesis/unicode_data/15.1.0/charmap.json.gz +0 -0
- pyddock-0.2.4/.hypothesis/unicode_data/15.1.0/codec-utf-8.json.gz +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/PKG-INFO +1 -1
- {pyddock-0.2.3 → pyddock-0.2.4}/pyproject.toml +1 -1
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_subprocess_patch.py +89 -2
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/default_config.toml +22 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/.gitignore +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/LICENSE +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/README.md +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/publish-to-pypi.ps1 +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/__init__.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_base.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_enforcement.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_fs_enforcement.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_import_hook.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_prewarm.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_process_utils.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_proxies.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/_runtime.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/ast_validator.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/cli.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/config.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/executor.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/script_registry.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/server.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/shell_executor.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/__init__.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/fs_append.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/fs_delete.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/read_file.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/stat_file.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/tools/str_replace.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/src/pyddock/venv_manager.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/__init__.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_ast_properties.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_chmod_integration.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_config.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_deny_messages.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_executor.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_file_tools.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_filesystem_guards.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_proxy_properties.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_realistic.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_runtime.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_security_guards.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_server.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_shell_arg_paths.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_shell_executor.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_shell_properties.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_subprocess_enforcement.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_subprocess_properties.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_subst_trusted_path.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_venv_stamp.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/tests/test_workspace_imports.py +0 -0
- {pyddock-0.2.3 → pyddock-0.2.4}/uv.lock +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This .gitignore file was automatically created by Hypothesis. Hypothesis gitignores
|
|
2
|
+
# .hypothesis by default, because we generally recommend that .hypothesis not be checked
|
|
3
|
+
# into version control.
|
|
4
|
+
#
|
|
5
|
+
# If you *would* like to check .hypothesis into version control, you should delete this
|
|
6
|
+
# file. Hypothesis will not re-create this .gitignore unless .hypothesis is deleted (and
|
|
7
|
+
# if it does, that's a bug - please report it!)
|
|
8
|
+
|
|
9
|
+
*
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\config.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[30.0, 3600.0, '.', '.pyddock', '/', '\\', 'allow', 'arg_paths', 'ast', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'default_config.toml', 'deny', 'deny-agent', 'deny-all', 'deny_messages', 'execution', 'filesystem', 'guards', 'imports', 'max_timeout', 'mode', 'module_allow', 'module_deny', 'none', 'protected', 'pyddock', 'pyddock.toml', 'read-only', 'readable_paths', 'restrictions', 'shell', 'timeout', 'utf-8', 'workspace', 'writable_paths']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\shell_executor.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
['$', ', ', '-', '-ExecutionPolicy', '-File', '-NoProfile', '.', '.bat', '.ps1', '.py', '.pyddock', '.sh', '/', '//', '/c', ':', '=', 'Bypass', '\\', '\\.', '\\/', '\\\\', '^', 'allow', 'bash', 'cmd', 'deny', 'none', 'nt', 'output', 'powershell', 'pwsh', 'python', 'replace', 'stderr', 'tmp', 'utf-8', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\venv_manager.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[300, '-c', '-e', '-m', '.pyddock', 'Scripts', '_workspace_hashes', 'allowlist_hash', 'bin', 'install', 'installed.json', 'pip', 'pyproject.toml', 'python', 'python.exe', 'pyvenv.cfg', 'setup.cfg', 'setup.py', 'utf-8', 'venv', 'venv_created', 'win32', 'workspace', '||']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_subprocess_patch.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
['$', '(none configured)', ', ', '.', '.pyddock', '/', 'Popen', '\\.', '\\/', '\\\\', '^', '_SafePopen', 'allow', 'arg_paths', 'command', 'cwd', 'deny', 'imports', 'mode', 'none', 'os', 'shell', 'subprocess', 'subprocess.Popen', 'subprocess.run', 'tmp', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\server.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[', ', '--workspace', '.py', '.pyddock', 'Configured commands:', 'Restrictions:', '_', '__main__', 'allow', 'content', 'deny', 'end', 'end_line', 'fs_append', 'fs_delete', 'fs_readfile', 'fs_stat', 'fs_str_replace', 'newStr', 'oldStr', 'path', 'pyddock', 'pyddock serve', 'read_file', 'run_python', 'run_shell', 'start', 'start_line', 'stat_file', 'stdio', 'str_replace', 'tmp', 'utf-8', 'venv']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_fs_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[511, 3584, '$', '*', ', ', '.', '.pyddock', '/', '<frozen', 'Lib', 'Path.chmod', 'Path.chmod()', 'Path.lchmod', 'Path.lchmod()', 'Path.mkdir', 'Path.open', 'Path.read_bytes', 'Path.read_text', 'Path.rename', 'Path.replace', 'Path.rmdir', 'Path.touch', 'Path.unlink', 'Path.write_bytes', 'Path.write_text', '\\', '\\.', '\\/', '\\\\', '^', '_io.FileIO', '_io.open', 'a', 'a+', 'a+b', 'a+t', 'ab', 'ab+', 'allow', 'at', 'at+', 'builtins.open', 'command', 'deny', 'deny-agent', 'deny-all', 'disposition', 'filesystem', 'guards', 'imports', 'io.FileIO', 'io.open', 'lchmod', 'lib', 'link_to', 'mkdtemp', 'mkstemp', 'os', 'os.chmod()', 'pattern', 'r', 'r+', 'r+b', 'r+t', 'rb+', 'read', 'read-only', 'readable_paths', 'rt+', 'shell', 'tempdir', 'tempfile', 'tmp', 'w', 'w+', 'w+b', 'w+t', 'wax+', 'wb', 'wb+', 'workspace', 'writable_paths', 'write', 'wt', 'wt+', 'x', 'x+', 'x+b', 'x+t', 'xb', 'xb+', 'xt', 'xt+']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[', ', '.', '.pyddock', '<frozen', 'PathLike', '_', '__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_current_frames', '_getframe', '_pyddock_format_tb', 'allow', 'allowed', 'altsep', 'argv', 'ast', 'attrgetter', 'block_attributes', 'byteorder', 'class_allow', 'class_deny', 'cpu_count', 'curdir', 'deny', 'deny_messages', 'devnull', 'exc_info', 'exec_prefix', 'executable', 'exit', 'extsep', 'float_info', 'fspath', 'fstat', 'getattr', 'getcwd', 'getdefaultencoding', 'getenv', 'getlogin', 'getpid', 'getrecursionlimit', 'hash_info', 'import', 'imports', 'int_info', 'level', 'linesep', 'listdir', 'lstat', 'maxsize', 'message', 'meta_path', 'mode', 'module_allow', 'module_deny', 'name', 'os', 'os.path', 'pardir', 'path', 'path_hooks', 'path_importer_cache', 'pathsep', 'pattern', 'platform', 'prefix', 'restrictions', 'scandir', 'sep', 'stat', 'stderr', 'stdin', 'stdout', 'sys', 'threading', 'venv', 'version', 'version_info', 'walk', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_subprocess_patch.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
['$', '(none configured)', ', ', '.', '.pyddock', '/', 'Popen', '\\.', '\\/', '\\\\', '^', '_SafePopen', 'allow', 'arg_paths', 'command', 'deny', 'imports', 'mode', 'none', 'os', 'shell', 'subprocess', 'subprocess.Popen', 'subprocess.run', 'tmp', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_proxies.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[', ', '.', 'Lib', '_', '__', '__all__', '__dict__', '__doc__', '__file__', '__getattr__', '__getattribute__', '__loader__', '__module__', '__name__', '__package__', '__path__', '__reduce__', '__reduce_ex__', '__spec__', 'builtins', 'lib', 'os', 'site-packages']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_process_utils.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[65536, '/F', '/PID', '/T', ';', 'C:\\Windows', 'Environment', 'PATH', 'PYTHONIOENCODING', 'PYTHONPATH', 'Path', 'SYSTEMROOT', 'SystemRoot', 'VIRTUAL_ENV', 'VIRTUAL_ENV_PROMPT', 'absent', 'nt', 'output', 'present', 'replace', 'stderr', 'taskkill', 'utf-8', 'windir']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\executor.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
['.py', '__PYDDOCK_RESULT__', '_last_expr = None', '_pyddock_bootstrap_', 'allow', 'allowed', 'arg_paths', 'ast', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'deny', 'deny_messages', 'disposition', 'exec(_code)', 'execution', 'filesystem', 'guards', 'import ast as _ast', 'import sys', 'imports', 'message', 'mode', 'module_allow', 'module_deny', 'nt', 'output', 'pattern', 'readable_paths', 'replace', 'restrictions', 'shell', 'stderr', 'timeout', 'utf-8', 'w', 'workspace', 'writable_paths']
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyddock
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: MCP server that gives AI agents pre-approved Python, shell, and file I/O tools with declarative policy controls
|
|
5
5
|
Project-URL: Homepage, https://github.com/portablestew/pyddock
|
|
6
6
|
Project-URL: Repository, https://github.com/portablestew/pyddock
|
|
@@ -190,6 +190,74 @@ def apply_subprocess_patch(
|
|
|
190
190
|
|
|
191
191
|
return None
|
|
192
192
|
|
|
193
|
+
def _check_cwd(policy: dict, cwd: Any) -> str | None:
|
|
194
|
+
"""Validate cwd kwarg against the same rules as arg paths.
|
|
195
|
+
|
|
196
|
+
Applies the policy's arg_paths mode to the cwd directory:
|
|
197
|
+
- "none": no restriction
|
|
198
|
+
- "protected": block cwd inside protected directories
|
|
199
|
+
- "workspace": block cwd outside the workspace or inside protected dirs
|
|
200
|
+
|
|
201
|
+
Returns None if cwd is permitted, or an error message string if blocked.
|
|
202
|
+
"""
|
|
203
|
+
if cwd is None:
|
|
204
|
+
return None
|
|
205
|
+
|
|
206
|
+
arg_paths_mode = policy.get("arg_paths", "workspace")
|
|
207
|
+
if arg_paths_mode == "none":
|
|
208
|
+
return None
|
|
209
|
+
|
|
210
|
+
resolved = pathlib.Path(_real_os.path.abspath(str(cwd)))
|
|
211
|
+
|
|
212
|
+
# Check .pyddock/ (excluding .pyddock/tmp/)
|
|
213
|
+
try:
|
|
214
|
+
rel = resolved.relative_to(_pyddock_dir)
|
|
215
|
+
if not str(rel).startswith("tmp"):
|
|
216
|
+
return (
|
|
217
|
+
f"cwd '{cwd}' targets the protected .pyddock/ directory. "
|
|
218
|
+
f"Subprocess cwd cannot be set to .pyddock/ "
|
|
219
|
+
f"(self-modification protection)."
|
|
220
|
+
)
|
|
221
|
+
except ValueError:
|
|
222
|
+
pass
|
|
223
|
+
|
|
224
|
+
# Check workspace module directories
|
|
225
|
+
for mod_name, ws_dir in _ws_module_dirs:
|
|
226
|
+
try:
|
|
227
|
+
resolved.relative_to(ws_dir)
|
|
228
|
+
return (
|
|
229
|
+
f"cwd '{cwd}' targets workspace module directory "
|
|
230
|
+
f"'{mod_name}'. Subprocess cwd cannot be set to workspace "
|
|
231
|
+
f"module directories."
|
|
232
|
+
)
|
|
233
|
+
except ValueError:
|
|
234
|
+
continue
|
|
235
|
+
|
|
236
|
+
# Check shell script directories
|
|
237
|
+
for dir_label, script_dir in _shell_protected_dirs:
|
|
238
|
+
try:
|
|
239
|
+
resolved.relative_to(script_dir)
|
|
240
|
+
return (
|
|
241
|
+
f"cwd '{cwd}' targets a shell-executable script "
|
|
242
|
+
f"directory ({dir_label}). Subprocess cwd cannot be set "
|
|
243
|
+
f"to script directories (write-then-execute prevention)."
|
|
244
|
+
)
|
|
245
|
+
except ValueError:
|
|
246
|
+
continue
|
|
247
|
+
|
|
248
|
+
# "workspace" mode: block cwd outside the workspace
|
|
249
|
+
if arg_paths_mode == "workspace":
|
|
250
|
+
try:
|
|
251
|
+
resolved.relative_to(_ws_root_abs)
|
|
252
|
+
except ValueError:
|
|
253
|
+
return (
|
|
254
|
+
f"cwd '{cwd}' resolves to '{resolved}' which is outside "
|
|
255
|
+
f"the workspace. Subprocess cwd is restricted to the "
|
|
256
|
+
f"workspace directory (arg_paths = \"workspace\")."
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
return None
|
|
260
|
+
|
|
193
261
|
def _validated_run(cmd: Any, *args: Any, **kwargs: Any) -> Any:
|
|
194
262
|
"""subprocess.run replacement that validates against shell policies."""
|
|
195
263
|
# Reject shell=True
|
|
@@ -250,13 +318,23 @@ def apply_subprocess_patch(
|
|
|
250
318
|
if hint:
|
|
251
319
|
msg += f"\n[{hint}]"
|
|
252
320
|
raise PermissionError(msg)
|
|
321
|
+
# Check cwd against the same path rules
|
|
322
|
+
cwd_rejection = _check_cwd(policy, kwargs.get("cwd"))
|
|
323
|
+
if cwd_rejection is not None:
|
|
324
|
+
msg = f"PermissionError: {cwd_rejection}"
|
|
325
|
+
hint = _find_deny_hint(
|
|
326
|
+
f"{command} {' '.join(cmd_args)}", _deny_msgs_sp
|
|
327
|
+
)
|
|
328
|
+
if hint:
|
|
329
|
+
msg += f"\n[{hint}]"
|
|
330
|
+
raise PermissionError(msg)
|
|
253
331
|
# Apply interpreter mapping (same as run_shell) and execute
|
|
254
332
|
resolved = _resolve_cmd(command)
|
|
255
333
|
full_cmd = resolved + cmd_args
|
|
256
334
|
kwargs["shell"] = False
|
|
257
335
|
return _ORIGINALS["subprocess.run"](full_cmd, *args, **kwargs)
|
|
258
336
|
|
|
259
|
-
def _validate_command(cmd: Any, caller: str) -> tuple[list[str], list[str]]:
|
|
337
|
+
def _validate_command(cmd: Any, caller: str, cwd: Any = None) -> tuple[list[str], list[str]]:
|
|
260
338
|
"""Shared validation for run() and Popen(). Returns (resolved_cmd, cmd_args).
|
|
261
339
|
|
|
262
340
|
Raises PermissionError if the command is not permitted.
|
|
@@ -311,6 +389,15 @@ def apply_subprocess_patch(
|
|
|
311
389
|
if hint:
|
|
312
390
|
msg += f"\n[{hint}]"
|
|
313
391
|
raise PermissionError(msg)
|
|
392
|
+
cwd_rejection = _check_cwd(policy, cwd)
|
|
393
|
+
if cwd_rejection is not None:
|
|
394
|
+
msg = f"PermissionError: {cwd_rejection}"
|
|
395
|
+
hint = _find_deny_hint(
|
|
396
|
+
f"{command} {' '.join(cmd_args)}", _deny_msgs_sp
|
|
397
|
+
)
|
|
398
|
+
if hint:
|
|
399
|
+
msg += f"\n[{hint}]"
|
|
400
|
+
raise PermissionError(msg)
|
|
314
401
|
resolved = _resolve_cmd(command)
|
|
315
402
|
return resolved + cmd_args, cmd_args
|
|
316
403
|
|
|
@@ -328,7 +415,7 @@ def apply_subprocess_patch(
|
|
|
328
415
|
"Pass command as a list instead: "
|
|
329
416
|
f"subprocess.Popen(['{example_cmd}', 'arg1', 'arg2'])"
|
|
330
417
|
)
|
|
331
|
-
full_cmd, _ = _validate_command(cmd, "Popen")
|
|
418
|
+
full_cmd, _ = _validate_command(cmd, "Popen", cwd=kwargs.get("cwd"))
|
|
332
419
|
kwargs["shell"] = False
|
|
333
420
|
self._proc = _ORIGINALS["subprocess.Popen"](full_cmd, *args, **kwargs)
|
|
334
421
|
|
|
@@ -212,6 +212,27 @@ allow = [
|
|
|
212
212
|
"change.*",
|
|
213
213
|
]
|
|
214
214
|
|
|
215
|
+
[shell.docker]
|
|
216
|
+
# Compose-only policy: scoped to the workspace's docker-compose.yml.
|
|
217
|
+
# No bare run/exec (shell-escape vectors), no push/login/save/export.
|
|
218
|
+
mode = "deny"
|
|
219
|
+
allow = [
|
|
220
|
+
# Compose lifecycle
|
|
221
|
+
"compose up.*", "compose down.*", "compose build.*",
|
|
222
|
+
"compose ps.*", "compose logs.*", "compose exec.*",
|
|
223
|
+
"compose run.*", "compose stop.*", "compose restart.*",
|
|
224
|
+
"compose pull.*", "compose config.*", "compose top.*",
|
|
225
|
+
"compose images.*", "compose port.*", "compose version.*",
|
|
226
|
+
# Container/image inspection (read-only)
|
|
227
|
+
"ps.*", "inspect.*", "logs.*", "top.*", "stats.*", "port.*",
|
|
228
|
+
"images.*", "image ls.*", "image inspect.*", "image history.*",
|
|
229
|
+
# Volume & network inspection (read-only)
|
|
230
|
+
"volume ls.*", "volume inspect.*",
|
|
231
|
+
"network ls.*", "network inspect.*",
|
|
232
|
+
# System info (read-only)
|
|
233
|
+
"system df.*", "version.*", "info.*",
|
|
234
|
+
]
|
|
235
|
+
|
|
215
236
|
# Path-like command patterns trigger automatic write protection — run_python cannot
|
|
216
237
|
# write to directories matching these patterns, preventing write-then-execute escalation.
|
|
217
238
|
# Script interpreter mapping is automatic: .ps1→powershell, .py→python, .sh→bash, .bat→cmd /c.
|
|
@@ -246,4 +267,5 @@ allow = [
|
|
|
246
267
|
"^(bash|sh)(\\.exe)?$" = "Shell interpreters are not allowed. Write your logic directly in run_python, or use run_shell with an approved command."
|
|
247
268
|
"^(powershell|pwsh)(\\.exe)?$" = "PowerShell is not allowed. Write your logic directly in run_python, or use run_shell with an approved command."
|
|
248
269
|
"^python(\\.exe)?$" = "Python is restricted to the run_python sandbox. Use the available runtime features."
|
|
270
|
+
"^docker " = "Only `docker compose` and read-only inspection commands are allowed. Use compose for container lifecycle."
|
|
249
271
|
"^dateutil(\\.|$)" = "dateutil is not directly available. Use `datetime.fromisoformat()` for ISO 8601 parsing, or `datetime.strptime()` for custom formats."
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|