pyddock 0.3.6__tar.gz → 0.4.0__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.4.0/.hypothesis/constants/0527dc28646c9360 +4 -0
- pyddock-0.4.0/.hypothesis/constants/30ee1be194c33a1d +4 -0
- pyddock-0.4.0/.hypothesis/constants/453881856851f311 +4 -0
- pyddock-0.4.0/.hypothesis/constants/5f020be48d90847d +4 -0
- pyddock-0.4.0/.hypothesis/constants/6627988645b1286c +4 -0
- pyddock-0.4.0/.hypothesis/constants/671fefe2f5d9935c +4 -0
- pyddock-0.4.0/.hypothesis/constants/805cbcbb07e3332d +4 -0
- pyddock-0.4.0/.hypothesis/constants/93108f7a5abfd484 +4 -0
- pyddock-0.4.0/.hypothesis/constants/d115f833e13f93f9 +4 -0
- pyddock-0.4.0/.hypothesis/constants/df249c25d70870dc +4 -0
- pyddock-0.4.0/.hypothesis/constants/e2c54b7949469c07 +4 -0
- pyddock-0.4.0/.hypothesis/constants/e78de40070f52f91 +4 -0
- pyddock-0.4.0/.hypothesis/constants/e8cd7befaa4dd723 +4 -0
- pyddock-0.4.0/.hypothesis/unicode_data/16.0.0/charmap.json.gz +0 -0
- pyddock-0.4.0/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/PKG-INFO +8 -7
- {pyddock-0.3.6 → pyddock-0.4.0}/README.md +4 -1
- {pyddock-0.3.6 → pyddock-0.4.0}/pyproject.toml +4 -6
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_audit_enforcement.py +5 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_subprocess_patch.py +21 -14
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/config.py +32 -34
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/default_config.toml +1 -1
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/executor.py +1 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/server.py +16 -5
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/shell_executor.py +209 -78
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/venv_manager.py +129 -3
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_config.py +95 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_jailbreak_regression.py +1 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_shell_arg_paths.py +4 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_shell_executor.py +151 -9
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_subst_trusted_path.py +2 -0
- pyddock-0.4.0/tests/test_venv_recreation.py +278 -0
- pyddock-0.4.0/uv.lock +657 -0
- pyddock-0.3.6/uv.lock +0 -769
- {pyddock-0.3.6 → pyddock-0.4.0}/.gitignore +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/.gitignore +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/106d94c8123c0256 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/1685e03b3aa38c02 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/1deca112ec6f2f3c +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/2488a3a95c48acfb +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/2a94d83a13979745 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/499f1d5a639a382a +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/4ee6f24fa151b65d +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/5b1b2189b70f5ef2 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/5d6f8b26b2137fe1 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/61f9b905d7da14e0 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/67a7f4ab2d372f23 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/6c6f5083ece3f86b +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/827e18b40f235443 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/8401e4039d635fbc +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/8490e7baefc8c8c3 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/a7c132b836381d0d +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/b395547bc71e5c52 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/constants/ca50661510a40488 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/tmp/tmpl8oe65gb +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/tmp/tmpqwper0dp +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/unicode_data/15.1.0/charmap.json.gz +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/.hypothesis/unicode_data/15.1.0/codec-utf-8.json.gz +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/LICENSE +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/publish-to-pypi.ps1 +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/__init__.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_base.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_enforcement.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_fs_enforcement.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_import_hook.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_prewarm.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_process_utils.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_proxies.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/_runtime.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/ast_validator.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/cli.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/script_registry.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/__init__.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/fs_append.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/fs_delete.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/fs_find.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/fs_grep.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/read_file.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/stat_file.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/src/pyddock/tools/str_replace.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/__init__.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/_config_helpers.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_ast_properties.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_attr_reflection_hardening.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_audit_hook_backstop.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_chmod_integration.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_deny_always_wins.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_deny_messages.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_env_policy.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_executor.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_file_tools.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_filesystem_guards.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_proxy_properties.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_realistic.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_runtime.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_sandbox_escape_hardening.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_security_guards.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_server.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_shell_properties.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_subprocess_enforcement.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_subprocess_properties.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_trusted_prefixes_uv_cache.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_venv_stamp.py +0 -0
- {pyddock-0.3.6 → pyddock-0.4.0}/tests/test_workspace_imports.py +0 -0
|
@@ -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', '/', '[env]', '\\', 'agent-deny', 'allow', 'arg_paths', 'ast', 'audit', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'default', 'default_config.toml', 'deny', 'deny-agent', 'deny-all', 'deny_messages', 'env', 'execution', 'filesystem', 'fs', 'fs-write', 'fs-write-pair', 'guards', 'imports', 'inert', 'max_timeout', 'mode', 'module_allow', 'module_deny', 'network', 'none', 'observe', 'protected', 'pyddock', 'pyddock.toml', 'read-only', 'readable_paths', 'restrictions', 'shell', 'snapshot', 'timeout', 'utf-8', 'workspace', 'writable_paths']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_audit_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[200, 300, 384, ' | ', '"', '*', '/', '<frozen', '<frozen importlib', '<unsummarizable>', 'AGENT', 'IMPORT', 'OTHER', 'O_APPEND', 'O_CREAT', 'O_RDWR', 'O_TRUNC', 'O_WRONLY', 'TRUSTED', '\\', 'agent-deny', 'allow', 'arg_paths', 'caller', 'command', 'decision', 'deny', 'detail', 'errors', 'event', 'fs', 'fs-write', 'fs-write-pair', 'fspath', 'import-exempt', 'mode', 'network', 'observe', 'open', 'os.system', 'pid', 'reentry', 'replace', 'shell', 'socket.', 'subprocess.Popen', 'surrogateescape', 't', 'utf-8', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\server.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[', ', '--debug', '--workspace', '.py', '.pyddock', 'Configured commands:', 'Restrictions:', '_', '__main__', 'allow', 'content', 'context_lines', 'deny', 'end', 'end_line', 'exclude_regex', 'file_glob', 'file_regex', 'fs_append', 'fs_delete', 'fs_find', 'fs_grep', 'fs_readfile', 'fs_stat', 'fs_str_replace', 'grep_regex', 'max_results', 'max_results_per_file', 'newStr', 'oldStr', 'path', 'pyddock', 'pyddock serve', 'read_file', 'run_python', 'run_shell', 'start', 'start_line', 'stat_file', 'stdio', 'store_true', 'str_replace', 'tmp', 'utf-8', 'venv']
|
|
@@ -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', '\\', '\\.', '\\/', '\\\\', '^', 'bash', 'cmd', 'command', 'default', 'deny', 'deny pattern', 'env', 'inert', 'items', 'no argument patterns', 'none', 'nt', 'output', 'powershell', 'pwsh', 'python', 'replace', 'snapshot', 'stderr', 'surrogateescape', 'tmp', 'utf-8', 'workspace']
|
|
@@ -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', 'fromlist', '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', 'urandom', '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)', ', ', 'Popen', '^', '_SafePopen', 'allow', 'arg_paths', 'command', 'cwd', 'deny', 'deny pattern', 'env', 'imports', 'mode', 'no argument patterns', 'os', 'shell', 'subprocess', 'subprocess.Popen', 'subprocess.run', 'surrogateescape', 'utf-8', '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__', '_initializing', 'builtins', 'lib', 'os', 'site-packages', 'venv site-packages', 'venv symlink target']
|
|
@@ -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', 'audit', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'default', 'deny', 'deny_messages', 'disposition', 'env', 'exec(_code, _ns)', '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']
|
|
@@ -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\_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+', 'audit', 'audit.jsonl', 'builtins.open', 'command', 'deny', 'deny-agent', 'deny-all', 'disposition', 'env', 'filesystem', 'guards', 'imports', 'io.FileIO', 'io.open', 'lchmod', 'lib', 'link_to', 'mkdtemp', 'mkstemp', 'nt', 'nul', 'nul.', '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\venv_manager.py
|
|
2
|
+
# hypothesis_version: 6.152.7
|
|
3
|
+
|
|
4
|
+
[300, '-c', '-e', '-m', '.pyddock', 'Scripts', '_is_gil_enabled', '_workspace_hashes', 'allowlist_hash', 'bin', 'freethreaded', 'gil', 'install', 'installed.json', 'interpreter_id', 'pip', 'pyproject.toml', 'python', 'python.exe', 'pyvenv.cfg', 'setup.cfg', 'setup.py', 'utf-8', 'venv', 'venv_created', 'win32', 'workspace', '||']
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyddock
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
@@ -13,13 +13,11 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
17
|
Classifier: Topic :: Security
|
|
20
18
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
-
Requires-Python: >=3.
|
|
22
|
-
Requires-Dist: mcp
|
|
19
|
+
Requires-Python: >=3.14
|
|
20
|
+
Requires-Dist: mcp<3,>=2
|
|
23
21
|
Description-Content-Type: text/markdown
|
|
24
22
|
|
|
25
23
|
# pyddock
|
|
@@ -79,10 +77,13 @@ The last expression in your snippet is captured as RESULT (like a Jupyter cell)
|
|
|
79
77
|
| `command` | string | Executable name or script path (must match a shell policy) |
|
|
80
78
|
| `args` | string[] | Arguments passed directly to the command (no shell interpretation) |
|
|
81
79
|
| `timeout` | number | Seconds (default: 30) |
|
|
80
|
+
| `cwd` | string | Working directory, relative to the workspace root (default: the workspace root) |
|
|
82
81
|
|
|
83
82
|
Commands are executed directly — no shell interpretation, pipes, redirects, chaining, or variable expansion. Only commands matching a `[shell.*]` policy in your config are permitted. The tool is only registered when at least one `[shell.*]` section exists in the config.
|
|
84
83
|
|
|
85
|
-
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c.
|
|
84
|
+
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c. A script or path-like command is resolved relative to the workspace root, never to `cwd`, so `cwd` cannot change which file executes.
|
|
85
|
+
|
|
86
|
+
`cwd` is subject to the command's `arg_paths` policy — normally it must be an existing directory inside the workspace and outside protected directories. Relative path arguments are resolved by the command against `cwd`, and are path-checked against both `cwd` and the workspace root.
|
|
86
87
|
|
|
87
88
|
## Output format
|
|
88
89
|
|
|
@@ -55,10 +55,13 @@ The last expression in your snippet is captured as RESULT (like a Jupyter cell)
|
|
|
55
55
|
| `command` | string | Executable name or script path (must match a shell policy) |
|
|
56
56
|
| `args` | string[] | Arguments passed directly to the command (no shell interpretation) |
|
|
57
57
|
| `timeout` | number | Seconds (default: 30) |
|
|
58
|
+
| `cwd` | string | Working directory, relative to the workspace root (default: the workspace root) |
|
|
58
59
|
|
|
59
60
|
Commands are executed directly — no shell interpretation, pipes, redirects, chaining, or variable expansion. Only commands matching a `[shell.*]` policy in your config are permitted. The tool is only registered when at least one `[shell.*]` section exists in the config.
|
|
60
61
|
|
|
61
|
-
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c.
|
|
62
|
+
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c. A script or path-like command is resolved relative to the workspace root, never to `cwd`, so `cwd` cannot change which file executes.
|
|
63
|
+
|
|
64
|
+
`cwd` is subject to the command's `arg_paths` policy — normally it must be an existing directory inside the workspace and outside protected directories. Relative path arguments are resolved by the command against `cwd`, and are path-checked against both `cwd` and the workspace root.
|
|
62
65
|
|
|
63
66
|
## Output format
|
|
64
67
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyddock"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "MCP server that gives AI agents pre-approved Python, shell, and file I/O tools with declarative policy controls"
|
|
5
|
-
requires-python = ">=3.
|
|
5
|
+
requires-python = ">=3.14"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
authors = [
|
|
@@ -14,14 +14,12 @@ classifiers = [
|
|
|
14
14
|
"Intended Audience :: Developers",
|
|
15
15
|
"License :: OSI Approved :: MIT License",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
|
-
"Programming Language :: Python :: 3.
|
|
18
|
-
"Programming Language :: Python :: 3.12",
|
|
19
|
-
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
20
18
|
"Topic :: Software Development :: Libraries",
|
|
21
19
|
"Topic :: Security",
|
|
22
20
|
]
|
|
23
21
|
dependencies = [
|
|
24
|
-
"mcp>=
|
|
22
|
+
"mcp>=2,<3",
|
|
25
23
|
]
|
|
26
24
|
|
|
27
25
|
[project.urls]
|
|
@@ -65,6 +65,7 @@ from typing import Any, Callable
|
|
|
65
65
|
from pyddock._base import SNIPPET_FILENAME
|
|
66
66
|
from pyddock.shell_executor import (
|
|
67
67
|
assert_env_locks,
|
|
68
|
+
coerce_cwd,
|
|
68
69
|
evaluate_arg_paths,
|
|
69
70
|
evaluate_arg_policy,
|
|
70
71
|
evaluate_cwd,
|
|
@@ -239,6 +240,10 @@ def evaluate_spawn_command(
|
|
|
239
240
|
workspace_root=ws_path,
|
|
240
241
|
workspace_module_dirs=ws_mods,
|
|
241
242
|
shell_command_patterns=patterns,
|
|
243
|
+
# A relative arg is resolved by the child against its own cwd, so a
|
|
244
|
+
# cwd-bearing spawn must be scanned against that base too — matching
|
|
245
|
+
# the subprocess proxy.
|
|
246
|
+
resolve_base=coerce_cwd(cwd),
|
|
242
247
|
)
|
|
243
248
|
if path_reason is not None:
|
|
244
249
|
raise PermissionError(
|
|
@@ -14,6 +14,7 @@ from typing import Any
|
|
|
14
14
|
from pyddock._base import _ORIGINALS, _find_deny_hint
|
|
15
15
|
from pyddock._process_utils import make_child_env
|
|
16
16
|
from pyddock.shell_executor import (
|
|
17
|
+
coerce_cwd,
|
|
17
18
|
evaluate_arg_paths,
|
|
18
19
|
evaluate_arg_policy,
|
|
19
20
|
evaluate_cwd,
|
|
@@ -121,11 +122,18 @@ def apply_subprocess_patch(
|
|
|
121
122
|
_looks_like_path_rt = looks_like_path
|
|
122
123
|
_extract_path_candidates_rt = extract_path_candidates
|
|
123
124
|
|
|
124
|
-
def _check_arg_paths(
|
|
125
|
+
def _check_arg_paths(
|
|
126
|
+
policy: dict, cmd_args: list[str], cwd: Any = None
|
|
127
|
+
) -> str | None:
|
|
125
128
|
"""Scan args for path-like values and validate against arg_paths policy.
|
|
126
129
|
|
|
127
130
|
Thin wrapper over the shared evaluate_arg_paths() so subprocess.run stays
|
|
128
131
|
in lockstep with run_shell (ShellExecutor) and the audit shell disposition.
|
|
132
|
+
|
|
133
|
+
`cwd` is forwarded as the resolution base: a relative arg is resolved by
|
|
134
|
+
the child against ITS cwd, so scanning only against the workspace root
|
|
135
|
+
would let a cwd-bearing spawn reach a protected directory through an arg
|
|
136
|
+
that looks harmless when anchored at the root.
|
|
129
137
|
"""
|
|
130
138
|
return evaluate_arg_paths(
|
|
131
139
|
cmd_args,
|
|
@@ -135,6 +143,7 @@ def apply_subprocess_patch(
|
|
|
135
143
|
shell_command_patterns=[
|
|
136
144
|
p.get("command", "") for p in shell_policies.values()
|
|
137
145
|
],
|
|
146
|
+
resolve_base=coerce_cwd(cwd),
|
|
138
147
|
)
|
|
139
148
|
|
|
140
149
|
def _check_cwd(policy: dict, cwd: Any) -> str | None:
|
|
@@ -169,13 +178,8 @@ def apply_subprocess_patch(
|
|
|
169
178
|
"""
|
|
170
179
|
deny_patterns, env_default = resolve_env_policy(_env_base, policy)
|
|
171
180
|
resolve_bases: list[pathlib.Path] = [_ws_root]
|
|
172
|
-
|
|
173
|
-
if
|
|
174
|
-
cwd_str = (
|
|
175
|
-
cwd.decode("utf-8", "surrogateescape")
|
|
176
|
-
if isinstance(cwd, (bytes, bytearray))
|
|
177
|
-
else str(cwd)
|
|
178
|
-
)
|
|
181
|
+
cwd_str = coerce_cwd(kwargs.get("cwd"))
|
|
182
|
+
if cwd_str is not None:
|
|
179
183
|
# `_ws_root / cwd_str` yields cwd_str unchanged when it is absolute,
|
|
180
184
|
# and resolves it against the workspace when relative — matching how
|
|
181
185
|
# the child process resolves its own cwd.
|
|
@@ -238,8 +242,9 @@ def apply_subprocess_patch(
|
|
|
238
242
|
if hint:
|
|
239
243
|
msg += f"\n[{hint}]"
|
|
240
244
|
raise PermissionError(msg)
|
|
241
|
-
# Check arg paths against protected directories
|
|
242
|
-
|
|
245
|
+
# Check arg paths against protected directories, resolving relative args
|
|
246
|
+
# against the spawn's cwd as well as the workspace root.
|
|
247
|
+
path_rejection = _check_arg_paths(policy, cmd_args, kwargs.get("cwd"))
|
|
243
248
|
if path_rejection is not None:
|
|
244
249
|
msg = f"PermissionError: {path_rejection}"
|
|
245
250
|
hint = _find_deny_hint(
|
|
@@ -258,8 +263,10 @@ def apply_subprocess_patch(
|
|
|
258
263
|
if hint:
|
|
259
264
|
msg += f"\n[{hint}]"
|
|
260
265
|
raise PermissionError(msg)
|
|
261
|
-
# Apply interpreter mapping (same as run_shell) and execute
|
|
262
|
-
|
|
266
|
+
# Apply interpreter mapping (same as run_shell) and execute. The
|
|
267
|
+
# workspace root anchors a path-like command so an agent-supplied cwd
|
|
268
|
+
# cannot re-target which script file actually runs.
|
|
269
|
+
resolved = _resolve_cmd(command, _ws_root)
|
|
263
270
|
full_cmd = resolved + cmd_args
|
|
264
271
|
_apply_env_policy(policy, kwargs)
|
|
265
272
|
kwargs["shell"] = False
|
|
@@ -311,7 +318,7 @@ def apply_subprocess_patch(
|
|
|
311
318
|
if hint:
|
|
312
319
|
msg += f"\n[{hint}]"
|
|
313
320
|
raise PermissionError(msg)
|
|
314
|
-
path_rejection = _check_arg_paths(policy, cmd_args)
|
|
321
|
+
path_rejection = _check_arg_paths(policy, cmd_args, cwd)
|
|
315
322
|
if path_rejection is not None:
|
|
316
323
|
msg = f"PermissionError: {path_rejection}"
|
|
317
324
|
hint = _find_deny_hint(
|
|
@@ -329,7 +336,7 @@ def apply_subprocess_patch(
|
|
|
329
336
|
if hint:
|
|
330
337
|
msg += f"\n[{hint}]"
|
|
331
338
|
raise PermissionError(msg)
|
|
332
|
-
resolved = _resolve_cmd(command)
|
|
339
|
+
resolved = _resolve_cmd(command, _ws_root)
|
|
333
340
|
return resolved + cmd_args, cmd_args, policy
|
|
334
341
|
|
|
335
342
|
class _SafePopen:
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Resolution order:
|
|
4
4
|
1. Base config: .pyddock/pyddock.toml in the workspace (CWD), or default_config.toml bundled with the package
|
|
5
|
-
2.
|
|
5
|
+
2. Global overlay (optional): ~/.pyddock/pyddock.override.toml — deep-merged on top of the base
|
|
6
|
+
3. Workspace overlay (optional): .pyddock/pyddock.override.toml — deep-merged on top (wins last)
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
from __future__ import annotations
|
|
@@ -492,6 +493,18 @@ def _parse_audit(data: dict) -> AuditConfig:
|
|
|
492
493
|
return AuditConfig(rules=rules)
|
|
493
494
|
|
|
494
495
|
|
|
496
|
+
def _load_toml(path: Path) -> dict:
|
|
497
|
+
"""Read and parse a TOML file, raising ConfigError on failure."""
|
|
498
|
+
try:
|
|
499
|
+
raw_bytes = path.read_bytes()
|
|
500
|
+
except OSError as e:
|
|
501
|
+
raise ConfigError(f"Cannot read config file {path}: {e}") from e
|
|
502
|
+
try:
|
|
503
|
+
return tomllib.loads(raw_bytes.decode("utf-8"))
|
|
504
|
+
except tomllib.TOMLDecodeError as e:
|
|
505
|
+
raise ConfigError(f"Invalid TOML in {path}: {e}") from e
|
|
506
|
+
|
|
507
|
+
|
|
495
508
|
def _deep_merge(base: dict, overlay: dict) -> dict:
|
|
496
509
|
"""Recursively merge *overlay* on top of *base* (neither is mutated).
|
|
497
510
|
|
|
@@ -596,8 +609,11 @@ def load_config(workspace: Path | None = None) -> PyddockConfig:
|
|
|
596
609
|
"""Load and parse the pyddock configuration.
|
|
597
610
|
|
|
598
611
|
Resolves the base config (workspace pyddock.toml or bundled default), then
|
|
599
|
-
|
|
600
|
-
|
|
612
|
+
applies optional overlay files in order:
|
|
613
|
+
1. ~/.pyddock/pyddock.override.toml (global user override)
|
|
614
|
+
2. .pyddock/pyddock.override.toml (workspace override, wins last)
|
|
615
|
+
|
|
616
|
+
Each overlay is deep-merged on top of the accumulated config before parsing.
|
|
601
617
|
|
|
602
618
|
Args:
|
|
603
619
|
workspace: The workspace root directory. Defaults to CWD.
|
|
@@ -612,42 +628,24 @@ def load_config(workspace: Path | None = None) -> PyddockConfig:
|
|
|
612
628
|
workspace = Path.cwd()
|
|
613
629
|
|
|
614
630
|
config_path = resolve_config_path(workspace)
|
|
615
|
-
|
|
616
|
-
try:
|
|
617
|
-
raw_bytes = config_path.read_bytes()
|
|
618
|
-
except OSError as e:
|
|
619
|
-
raise ConfigError(f"Cannot read config file {config_path}: {e}") from e
|
|
620
|
-
|
|
621
|
-
try:
|
|
622
|
-
data = tomllib.loads(raw_bytes.decode("utf-8"))
|
|
623
|
-
except tomllib.TOMLDecodeError as e:
|
|
624
|
-
raise ConfigError(
|
|
625
|
-
f"Invalid TOML in {config_path}: {e}"
|
|
626
|
-
) from e
|
|
627
|
-
|
|
631
|
+
data = _load_toml(config_path)
|
|
628
632
|
logger.debug("Loaded base config from %s", config_path)
|
|
629
633
|
|
|
630
|
-
#
|
|
634
|
+
# Global user override
|
|
635
|
+
global_override = Path.home() / ".pyddock" / "pyddock.override.toml"
|
|
636
|
+
if global_override.is_file():
|
|
637
|
+
data = _deep_merge(data, _load_toml(global_override))
|
|
638
|
+
logger.debug("Applied global override from %s", global_override)
|
|
639
|
+
else:
|
|
640
|
+
logger.debug("No global override found (checked %s)", global_override)
|
|
641
|
+
|
|
642
|
+
# Workspace override (wins last)
|
|
631
643
|
override_path = workspace / ".pyddock" / "pyddock.override.toml"
|
|
632
644
|
if override_path.is_file():
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
except OSError as e:
|
|
636
|
-
raise ConfigError(
|
|
637
|
-
f"Cannot read override config file {override_path}: {e}"
|
|
638
|
-
) from e
|
|
639
|
-
|
|
640
|
-
try:
|
|
641
|
-
override_data = tomllib.loads(override_bytes.decode("utf-8"))
|
|
642
|
-
except tomllib.TOMLDecodeError as e:
|
|
643
|
-
raise ConfigError(
|
|
644
|
-
f"Invalid TOML in {override_path}: {e}"
|
|
645
|
-
) from e
|
|
646
|
-
|
|
647
|
-
data = _deep_merge(data, override_data)
|
|
648
|
-
logger.debug("Applied overlay from %s", override_path)
|
|
645
|
+
data = _deep_merge(data, _load_toml(override_path))
|
|
646
|
+
logger.debug("Applied workspace override from %s", override_path)
|
|
649
647
|
else:
|
|
650
|
-
logger.debug("No
|
|
648
|
+
logger.debug("No workspace override found (checked %s)", override_path)
|
|
651
649
|
|
|
652
650
|
try:
|
|
653
651
|
return _parse_config(data)
|
|
@@ -64,7 +64,7 @@ tempfile = true
|
|
|
64
64
|
cryptography = true # No I/O of its own; all file access goes through Python builtins
|
|
65
65
|
git = "GitPython" # [shell.git] policy enforced at the git.cmd.Git.execute chokepoint
|
|
66
66
|
polars = true
|
|
67
|
-
P4 = "p4python" # Restricted to non-submit operations
|
|
67
|
+
#P4 = "p4python" # Restricted to non-submit operations
|
|
68
68
|
|
|
69
69
|
# Filesystem scoping for run_python.
|
|
70
70
|
# Paths are relative to the workspace root (the --workspace directory or CWD).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""MCP server entry point for pyddock.
|
|
2
2
|
|
|
3
|
-
Exposes the `run_python` tool via the MCP protocol using
|
|
3
|
+
Exposes the `run_python` tool via the MCP protocol using MCPServer.
|
|
4
4
|
Orchestrates the full pipeline: validate → install → execute → return.
|
|
5
5
|
"""
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ import asyncio
|
|
|
10
10
|
import logging
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
|
|
13
|
-
from mcp.server.
|
|
13
|
+
from mcp.server.mcpserver import MCPServer
|
|
14
14
|
|
|
15
15
|
from pyddock.ast_validator import ASTValidator
|
|
16
16
|
from pyddock.config import PyddockConfig, load_config
|
|
@@ -72,6 +72,8 @@ def _build_shell_tool_description(config: PyddockConfig) -> str:
|
|
|
72
72
|
"",
|
|
73
73
|
"Script files get automatic interpreter mapping: .ps1→powershell, .py→python, .sh→bash, .bat→cmd /c.",
|
|
74
74
|
"",
|
|
75
|
+
"Pass 'cwd' to set the working directory (relative to the workspace root; defaults to it).",
|
|
76
|
+
"",
|
|
75
77
|
"Shell policies only gate the initial command — child processes spawned by an allowed script are not restricted. "
|
|
76
78
|
"For example, a build script can internally invoke compilers, tools, or other executables freely.",
|
|
77
79
|
"",
|
|
@@ -101,7 +103,7 @@ def _build_shell_tool_description(config: PyddockConfig) -> str:
|
|
|
101
103
|
return "\n".join(parts)
|
|
102
104
|
|
|
103
105
|
|
|
104
|
-
def create_server(workspace: Path | None = None, debug: bool = False) ->
|
|
106
|
+
def create_server(workspace: Path | None = None, debug: bool = False) -> MCPServer:
|
|
105
107
|
"""Create and configure the pyddock MCP server.
|
|
106
108
|
|
|
107
109
|
Loads config, creates venv, installs allowed packages, and registers
|
|
@@ -112,7 +114,7 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
112
114
|
debug: Enable the audit-trail debug log (.pyddock/tmp/audit.jsonl).
|
|
113
115
|
|
|
114
116
|
Returns:
|
|
115
|
-
Configured
|
|
117
|
+
Configured MCPServer server instance.
|
|
116
118
|
"""
|
|
117
119
|
if workspace is None:
|
|
118
120
|
workspace = Path.cwd()
|
|
@@ -141,7 +143,7 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
141
143
|
executor = SubprocessExecutor(config, venv_manager, debug=debug)
|
|
142
144
|
|
|
143
145
|
# Create MCP server
|
|
144
|
-
mcp =
|
|
146
|
+
mcp = MCPServer("pyddock")
|
|
145
147
|
|
|
146
148
|
tool_description = _build_tool_description(config)
|
|
147
149
|
|
|
@@ -214,6 +216,7 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
214
216
|
command: str | None = None,
|
|
215
217
|
args: list[str] | None = None,
|
|
216
218
|
timeout: float | None = None,
|
|
219
|
+
cwd: str | None = None,
|
|
217
220
|
) -> str:
|
|
218
221
|
"""Execute a pre-approved shell command.
|
|
219
222
|
|
|
@@ -221,6 +224,8 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
221
224
|
command: Executable name or script path (must match a shell policy).
|
|
222
225
|
args: Arguments passed directly to the command.
|
|
223
226
|
timeout: Execution timeout in seconds.
|
|
227
|
+
cwd: Working directory, relative to the workspace root.
|
|
228
|
+
Defaults to the workspace root.
|
|
224
229
|
|
|
225
230
|
Returns:
|
|
226
231
|
Human-readable text with stdout, stderr, and exit code.
|
|
@@ -235,6 +240,11 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
235
240
|
if timeout is not None and timeout <= 0:
|
|
236
241
|
return _shell_error_output(f"Timeout must be positive, got: {timeout}")
|
|
237
242
|
|
|
243
|
+
# Normalize an explicitly-blank cwd to None (workspace root) rather
|
|
244
|
+
# than letting "" reach the path checks as a bogus candidate.
|
|
245
|
+
if cwd is not None and cwd.strip() == "":
|
|
246
|
+
cwd = None
|
|
247
|
+
|
|
238
248
|
# Enforce max_timeout
|
|
239
249
|
effective_timeout = timeout if timeout is not None else config.execution.timeout
|
|
240
250
|
if effective_timeout > config.execution.max_timeout:
|
|
@@ -250,6 +260,7 @@ def create_server(workspace: Path | None = None, debug: bool = False) -> FastMCP
|
|
|
250
260
|
command,
|
|
251
261
|
args,
|
|
252
262
|
effective_timeout,
|
|
263
|
+
cwd,
|
|
253
264
|
)
|
|
254
265
|
|
|
255
266
|
return _shell_output_to_text(result)
|