pyddock 0.2.2__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.
Files changed (78) hide show
  1. pyddock-0.2.4/.hypothesis/.gitignore +9 -0
  2. pyddock-0.2.4/.hypothesis/constants/106d94c8123c0256 +4 -0
  3. pyddock-0.2.4/.hypothesis/constants/1685e03b3aa38c02 +4 -0
  4. pyddock-0.2.4/.hypothesis/constants/1deca112ec6f2f3c +4 -0
  5. pyddock-0.2.4/.hypothesis/constants/2488a3a95c48acfb +4 -0
  6. pyddock-0.2.4/.hypothesis/constants/2a94d83a13979745 +4 -0
  7. pyddock-0.2.4/.hypothesis/constants/499f1d5a639a382a +4 -0
  8. pyddock-0.2.4/.hypothesis/constants/4ee6f24fa151b65d +4 -0
  9. pyddock-0.2.4/.hypothesis/constants/5b1b2189b70f5ef2 +4 -0
  10. pyddock-0.2.4/.hypothesis/constants/5d6f8b26b2137fe1 +4 -0
  11. pyddock-0.2.4/.hypothesis/constants/61f9b905d7da14e0 +4 -0
  12. pyddock-0.2.4/.hypothesis/constants/67a7f4ab2d372f23 +4 -0
  13. pyddock-0.2.4/.hypothesis/constants/6c6f5083ece3f86b +4 -0
  14. pyddock-0.2.4/.hypothesis/constants/827e18b40f235443 +4 -0
  15. pyddock-0.2.4/.hypothesis/constants/8401e4039d635fbc +4 -0
  16. pyddock-0.2.4/.hypothesis/constants/8490e7baefc8c8c3 +4 -0
  17. pyddock-0.2.4/.hypothesis/constants/a7c132b836381d0d +4 -0
  18. pyddock-0.2.4/.hypothesis/constants/b395547bc71e5c52 +4 -0
  19. pyddock-0.2.4/.hypothesis/constants/ca50661510a40488 +4 -0
  20. pyddock-0.2.4/.hypothesis/tmp/tmpl8oe65gb +0 -0
  21. pyddock-0.2.4/.hypothesis/tmp/tmpqwper0dp +0 -0
  22. pyddock-0.2.4/.hypothesis/unicode_data/15.1.0/charmap.json.gz +0 -0
  23. pyddock-0.2.4/.hypothesis/unicode_data/15.1.0/codec-utf-8.json.gz +0 -0
  24. {pyddock-0.2.2 → pyddock-0.2.4}/PKG-INFO +1 -1
  25. {pyddock-0.2.2 → pyddock-0.2.4}/publish-to-pypi.ps1 +5 -1
  26. {pyddock-0.2.2 → pyddock-0.2.4}/pyproject.toml +1 -1
  27. pyddock-0.2.4/src/pyddock/_base.py +45 -0
  28. pyddock-0.2.4/src/pyddock/_enforcement.py +584 -0
  29. pyddock-0.2.4/src/pyddock/_fs_enforcement.py +589 -0
  30. pyddock-0.2.4/src/pyddock/_import_hook.py +161 -0
  31. pyddock-0.2.4/src/pyddock/_prewarm.py +69 -0
  32. pyddock-0.2.4/src/pyddock/_process_utils.py +199 -0
  33. pyddock-0.2.4/src/pyddock/_proxies.py +526 -0
  34. pyddock-0.2.4/src/pyddock/_runtime.py +39 -0
  35. pyddock-0.2.4/src/pyddock/_subprocess_patch.py +517 -0
  36. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/default_config.toml +26 -3
  37. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_proxy_properties.py +6 -6
  38. {pyddock-0.2.2 → pyddock-0.2.4}/uv.lock +1 -1
  39. pyddock-0.2.2/src/pyddock/_process_utils.py +0 -88
  40. pyddock-0.2.2/src/pyddock/_runtime.py +0 -2124
  41. {pyddock-0.2.2 → pyddock-0.2.4}/.gitignore +0 -0
  42. {pyddock-0.2.2 → pyddock-0.2.4}/LICENSE +0 -0
  43. {pyddock-0.2.2 → pyddock-0.2.4}/README.md +0 -0
  44. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/__init__.py +0 -0
  45. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/ast_validator.py +0 -0
  46. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/cli.py +0 -0
  47. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/config.py +0 -0
  48. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/executor.py +0 -0
  49. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/script_registry.py +0 -0
  50. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/server.py +0 -0
  51. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/shell_executor.py +0 -0
  52. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/__init__.py +0 -0
  53. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/fs_append.py +0 -0
  54. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/fs_delete.py +0 -0
  55. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/read_file.py +0 -0
  56. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/stat_file.py +0 -0
  57. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/tools/str_replace.py +0 -0
  58. {pyddock-0.2.2 → pyddock-0.2.4}/src/pyddock/venv_manager.py +0 -0
  59. {pyddock-0.2.2 → pyddock-0.2.4}/tests/__init__.py +0 -0
  60. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_ast_properties.py +0 -0
  61. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_chmod_integration.py +0 -0
  62. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_config.py +0 -0
  63. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_deny_messages.py +0 -0
  64. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_executor.py +0 -0
  65. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_file_tools.py +0 -0
  66. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_filesystem_guards.py +0 -0
  67. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_realistic.py +0 -0
  68. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_runtime.py +0 -0
  69. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_security_guards.py +0 -0
  70. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_server.py +0 -0
  71. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_shell_arg_paths.py +0 -0
  72. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_shell_executor.py +0 -0
  73. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_shell_properties.py +0 -0
  74. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_subprocess_enforcement.py +0 -0
  75. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_subprocess_properties.py +0 -0
  76. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_subst_trusted_path.py +0 -0
  77. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_venv_stamp.py +0 -0
  78. {pyddock-0.2.2 → pyddock-0.2.4}/tests/test_workspace_imports.py +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\_runtime.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ []
@@ -0,0 +1,4 @@
1
+ # file: C:\Dev\github\pyddock\src\pyddock\_import_hook.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ [', ', '.', '<frozen', '<frozen importlib']
@@ -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\__init__.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ ['0.0.0', 'pyddock']
@@ -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\script_registry.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ [', ', '.py', '__init__.py', 'pyddock', 'tools', 'utf-8', 'workspace_root']
@@ -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\_prewarm.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ ['%Y', '2000', '_strptime', 'ascii', 'codecs → encodings.*', 'cp1252', 'idna', 'latin-1', 'utf-16-le', 'utf-8']
@@ -0,0 +1,4 @@
1
+ # file: C:\Dev\github\pyddock\src\pyddock\_base.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ ['<snippet>']
@@ -0,0 +1,4 @@
1
+ # file: C:\Dev\github\pyddock\src\pyddock\ast_validator.py
2
+ # hypothesis_version: 6.152.7
3
+
4
+ [', ', '.', 'blocked_attribute', 'blocked_call', 'blocked_import', 'syntax_error']
@@ -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']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyddock
3
- Version: 0.2.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
@@ -16,8 +16,12 @@ Write-Host "> uvx twine upload --repository testpypi dist/*"
16
16
  uvx twine upload --repository testpypi dist/*
17
17
  if ($LASTEXITCODE -ne 0) { throw "testpypi upload failed" }
18
18
 
19
+ # Hint for testing
20
+ Write-Host "`nTo test from testpypi:"
21
+ Write-Host " uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pyddock"
22
+
19
23
  # Pause for confirmation
20
- $response = Read-Host "`nUploaded to testpypi. Type 'y' to upload to pypi (else abort)"
24
+ $response = Read-Host "`nType 'y' to upload to pypi (anything else aborts)"
21
25
  if ($response -ne 'y') { Write-Host "Aborted."; exit 0 }
22
26
 
23
27
  # Upload to pypi
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyddock"
3
- version = "0.2.2"
3
+ version = "0.2.4"
4
4
  description = "MCP server that gives AI agents pre-approved Python, shell, and file I/O tools with declarative policy controls"
5
5
  requires-python = ">=3.11"
6
6
  license = "MIT"
@@ -0,0 +1,45 @@
1
+ """Shared constants and utilities for pyddock runtime enforcement.
2
+
3
+ This is the leaf module in the dependency graph — it has NO imports from
4
+ other pyddock modules. All other _runtime split modules import from here.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import re
10
+ import sys
11
+ from typing import Any
12
+
13
+ # Filename used for compile() when executing agent snippets.
14
+ # Defined here so the sandbox subprocess doesn't need to import the
15
+ # pyddock package (which would trigger importlib.metadata).
16
+ SNIPPET_FILENAME = "<snippet>"
17
+
18
+ # Resolved at module load time (before the import hook activates).
19
+ # Used by _caller_is_trusted to skip pyddock's own frames.
20
+ import os as _os_for_path
21
+ _PYDDOCK_DIR = _os_for_path.path.dirname(_os_for_path.path.abspath(__file__))
22
+ # Cache path helpers for _caller_is_trusted (avoids repeated attribute lookups).
23
+ _normcase = _os_for_path.path.normcase
24
+ _realpath = _os_for_path.path.realpath
25
+ del _os_for_path
26
+
27
+ # Module-level dict for storing original (unpatched) function references.
28
+ # Security-critical wrappers look up originals here instead of capturing them
29
+ # in closure cells. This prevents agent code from extracting originals via
30
+ # function.__closure__[N].cell_contents or descriptor-protocol introspection.
31
+ # Since pyddock._* modules are not importable by agent code, this dict is inaccessible.
32
+ _ORIGINALS: dict[str, Any] = {}
33
+
34
+
35
+ def _find_deny_hint(attempted: str, deny_messages: list[tuple[re.Pattern[str], str]]) -> str | None:
36
+ """Return the first matching deny hint for the attempted action, or None.
37
+
38
+ This is the subprocess-side equivalent of config.find_deny_hint().
39
+ It operates on pre-compiled (pattern, message) tuples reconstructed
40
+ from the serialized config dict.
41
+ """
42
+ for pattern, message in deny_messages:
43
+ if pattern.search(attempted):
44
+ return message
45
+ return None