pyddock 0.3.1__tar.gz → 0.3.2__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 (85) hide show
  1. {pyddock-0.3.1 → pyddock-0.3.2}/PKG-INFO +1 -1
  2. {pyddock-0.3.1 → pyddock-0.3.2}/pyproject.toml +1 -1
  3. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_base.py +8 -0
  4. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/default_config.toml +2 -0
  5. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/shell_executor.py +19 -1
  6. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_jailbreak_regression.py +68 -0
  7. {pyddock-0.3.1 → pyddock-0.3.2}/uv.lock +1 -1
  8. {pyddock-0.3.1 → pyddock-0.3.2}/.gitignore +0 -0
  9. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/.gitignore +0 -0
  10. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/106d94c8123c0256 +0 -0
  11. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/1685e03b3aa38c02 +0 -0
  12. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/1deca112ec6f2f3c +0 -0
  13. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/2488a3a95c48acfb +0 -0
  14. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/2a94d83a13979745 +0 -0
  15. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/499f1d5a639a382a +0 -0
  16. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/4ee6f24fa151b65d +0 -0
  17. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/5b1b2189b70f5ef2 +0 -0
  18. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/5d6f8b26b2137fe1 +0 -0
  19. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/61f9b905d7da14e0 +0 -0
  20. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/67a7f4ab2d372f23 +0 -0
  21. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/6c6f5083ece3f86b +0 -0
  22. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/827e18b40f235443 +0 -0
  23. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/8401e4039d635fbc +0 -0
  24. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/8490e7baefc8c8c3 +0 -0
  25. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/a7c132b836381d0d +0 -0
  26. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/b395547bc71e5c52 +0 -0
  27. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/constants/ca50661510a40488 +0 -0
  28. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/tmp/tmpl8oe65gb +0 -0
  29. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/tmp/tmpqwper0dp +0 -0
  30. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/unicode_data/15.1.0/charmap.json.gz +0 -0
  31. {pyddock-0.3.1 → pyddock-0.3.2}/.hypothesis/unicode_data/15.1.0/codec-utf-8.json.gz +0 -0
  32. {pyddock-0.3.1 → pyddock-0.3.2}/LICENSE +0 -0
  33. {pyddock-0.3.1 → pyddock-0.3.2}/README.md +0 -0
  34. {pyddock-0.3.1 → pyddock-0.3.2}/publish-to-pypi.ps1 +0 -0
  35. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/__init__.py +0 -0
  36. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_audit_enforcement.py +0 -0
  37. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_enforcement.py +0 -0
  38. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_fs_enforcement.py +0 -0
  39. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_import_hook.py +0 -0
  40. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_prewarm.py +0 -0
  41. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_process_utils.py +0 -0
  42. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_proxies.py +0 -0
  43. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_runtime.py +0 -0
  44. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/_subprocess_patch.py +0 -0
  45. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/ast_validator.py +0 -0
  46. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/cli.py +0 -0
  47. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/config.py +0 -0
  48. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/executor.py +0 -0
  49. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/script_registry.py +0 -0
  50. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/server.py +0 -0
  51. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/__init__.py +0 -0
  52. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/fs_append.py +0 -0
  53. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/fs_delete.py +0 -0
  54. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/read_file.py +0 -0
  55. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/stat_file.py +0 -0
  56. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/tools/str_replace.py +0 -0
  57. {pyddock-0.3.1 → pyddock-0.3.2}/src/pyddock/venv_manager.py +0 -0
  58. {pyddock-0.3.1 → pyddock-0.3.2}/tests/__init__.py +0 -0
  59. {pyddock-0.3.1 → pyddock-0.3.2}/tests/_config_helpers.py +0 -0
  60. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_ast_properties.py +0 -0
  61. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_attr_reflection_hardening.py +0 -0
  62. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_audit_hook_backstop.py +0 -0
  63. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_chmod_integration.py +0 -0
  64. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_config.py +0 -0
  65. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_deny_always_wins.py +0 -0
  66. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_deny_messages.py +0 -0
  67. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_env_policy.py +0 -0
  68. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_executor.py +0 -0
  69. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_file_tools.py +0 -0
  70. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_filesystem_guards.py +0 -0
  71. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_proxy_properties.py +0 -0
  72. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_realistic.py +0 -0
  73. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_runtime.py +0 -0
  74. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_sandbox_escape_hardening.py +0 -0
  75. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_security_guards.py +0 -0
  76. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_server.py +0 -0
  77. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_shell_arg_paths.py +0 -0
  78. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_shell_executor.py +0 -0
  79. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_shell_properties.py +0 -0
  80. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_subprocess_enforcement.py +0 -0
  81. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_subprocess_properties.py +0 -0
  82. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_subst_trusted_path.py +0 -0
  83. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_trusted_prefixes_uv_cache.py +0 -0
  84. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_venv_stamp.py +0 -0
  85. {pyddock-0.3.1 → pyddock-0.3.2}/tests/test_workspace_imports.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyddock
3
- Version: 0.3.1
3
+ Version: 0.3.2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyddock"
3
- version = "0.3.1"
3
+ version = "0.3.2"
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"
@@ -52,6 +52,14 @@ def has_ntfs_stream(path: Any) -> bool:
52
52
  component (``C:\\...`` or the drive-relative ``C:rest``). A ``:`` anywhere else
53
53
  is a stream reference. Returns False on non-Windows, where ``:`` is an
54
54
  ordinary, legal filename character.
55
+
56
+ NOTE: this primitive is deliberately strict and makes NO exception for
57
+ URL-looking strings (``https://...``). It guards real filesystem operations
58
+ (``open``/``Path.write_*``), where the argument is always a local path and a
59
+ ``scheme:`` prefix would still carry a stream-bearing ``:``. The one place a
60
+ URL is a legitimate value — a shell CLI argument — filters URLs out *before*
61
+ they reach this check (see ``_looks_like_path`` in shell_executor), so URLs
62
+ never get here in the first place.
55
63
  """
56
64
  if _os_name != "nt":
57
65
  return False
@@ -90,6 +90,8 @@ readable_paths = ["*"]
90
90
  '/\.ssh/' = "deny-agent" # SSH keys — paramiko/GitPython may need access
91
91
  '/\.aws/credentials$' = "deny-agent" # AWS credentials — boto3 needs access
92
92
  '/\.aws/sso/cache/' = "deny-agent" # AWS SSO tokens — boto3 needs access
93
+ '/\.aws/login/cache/' = "deny-agent" # AWS SSO/OIDC login token cache — boto3 needs access
94
+ '/\.aws/cli/cache/' = "deny-agent" # AWS assume-role credential cache — boto3 needs access
93
95
  '/\.docker/config\.json$' = "deny-agent" # Docker registry auth — docker SDK may need access
94
96
  '/\.kube/config$' = "deny-agent" # Kubernetes credentials — k8s client may need access
95
97
  '/\.gnupg/' = "deny-all" # GPG private keys — no library reader in sandbox
@@ -21,6 +21,13 @@ from pyddock._process_utils import get_startupinfo, kill_and_drain, make_child_e
21
21
  import shutil
22
22
 
23
23
 
24
+ # A scheme://… URI prefix (http://, https://, ssh://, ftp://, …). Used to keep
25
+ # URLs from being treated as local filesystem path candidates in shell args.
26
+ # Matches RFC-3986 scheme syntax: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
27
+ # followed by "://".
28
+ _URL_SCHEME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*://")
29
+
30
+
24
31
  def _abspath(p: Path) -> Path:
25
32
  """Canonicalize a path for shell-arg containment checks.
26
33
 
@@ -39,8 +46,19 @@ def _looks_like_path(arg: str) -> bool:
39
46
  Returns True if the arg contains path separators, starts with '.',
40
47
  or starts with a drive letter (Windows). Excludes UNC-style paths
41
48
  (//server/...) and Perforce depot paths (//depot/...) which are not
42
- local filesystem targets.
49
+ local filesystem targets, and ``scheme://...`` URLs (http, https, ssh,
50
+ ftp, ...), which are likewise not local paths.
51
+
52
+ The URL exclusion is also what keeps a URL argument from reaching
53
+ `has_ntfs_stream`: a URL's ``scheme:`` prefix (and any ``host:port``)
54
+ carries colons that the strict stream check would otherwise reject as an
55
+ NTFS alternate-data-stream reference (false positive). Filtering URLs out
56
+ here — rather than relaxing `has_ntfs_stream` itself — keeps that primitive
57
+ strict for the real filesystem operations that depend on it.
43
58
  """
59
+ # Exclude scheme://... URLs (http, https, ssh, ftp, ...) — not local paths.
60
+ if _URL_SCHEME_RE.match(arg):
61
+ return False
44
62
  # Exclude //... paths (UNC paths, Perforce depot paths)
45
63
  if arg.startswith("//"):
46
64
  return False
@@ -144,6 +144,74 @@ class TestHasNtfsStream:
144
144
  assert has_ntfs_stream("C:relative\\file") is False
145
145
  assert has_ntfs_stream("C:\\abs\\file") is False
146
146
 
147
+ @pytest.mark.skipif(sys.platform != "win32", reason="NTFS ADS is Windows-only")
148
+ def test_primitive_stays_strict_for_url_disguised_stream(self) -> None:
149
+ # has_ntfs_stream is a low-level filesystem primitive: it must NOT make
150
+ # an exception for URL-looking strings. A scheme:// prefix slapped onto a
151
+ # stream-bearing path (e.g. open("https://.pyddock:pwned", "w")) resolves
152
+ # to an in-workspace lexical path and would otherwise slip past the
153
+ # writable_paths containment check. The primitive must still reject it;
154
+ # URL filtering belongs to the shell-arg layer (_looks_like_path), not
155
+ # here. See the matching regression in TestUrlArgsNotPathCandidates.
156
+ assert has_ntfs_stream("https://.pyddock:pwned") is True
157
+ assert has_ntfs_stream("http://host/file.txt:stream") is True
158
+
159
+
160
+ class TestUrlArgsNotPathCandidates:
161
+ """URLs passed as shell CLI arguments must not be treated as local paths.
162
+
163
+ Regression: a URL argument (e.g. `-Url https://host/a/b`) tripped the
164
+ NTFS-stream check because the scheme's `:` (and any `host:port`) looked like
165
+ an alternate-data-stream reference. URLs are filtered out at the
166
+ `_looks_like_path` layer so they never reach the stream check, while the
167
+ primitive itself stays strict for real filesystem paths.
168
+ """
169
+
170
+ @pytest.mark.parametrize(
171
+ "url",
172
+ [
173
+ "https://api.example.com/projects/abc/designs/xyz",
174
+ "http://example.com/path",
175
+ "https://host:8443/path", # host:port colon
176
+ "ssh://git@github.com/org/repo.git",
177
+ "ftp://files.example.com/data.txt",
178
+ ],
179
+ )
180
+ def test_urls_are_not_path_candidates(self, url: str) -> None:
181
+ from pyddock.shell_executor import _extract_path_candidates, _looks_like_path
182
+
183
+ assert _looks_like_path(url) is False, url
184
+ assert _extract_path_candidates(url) == [], url
185
+
186
+ def test_url_arg_passes_arg_path_scan(self, tmp_path: Path) -> None:
187
+ # A URL argument must not be rejected by the arg-path scanner in either
188
+ # "protected" or "workspace" mode.
189
+ for mode in ("protected", "workspace"):
190
+ reason = evaluate_arg_paths(
191
+ ["-Url", "https://api.example.com/projects/abc/designs/xyz", "-Raw"],
192
+ arg_paths=mode,
193
+ workspace_root=tmp_path,
194
+ workspace_module_dirs={},
195
+ shell_command_patterns=[],
196
+ )
197
+ assert reason is None, (mode, reason)
198
+
199
+ def test_stream_in_flag_value_still_blocked(self, tmp_path: Path) -> None:
200
+ # The URL exclusion must NOT weaken the output-flag stream attack: a
201
+ # value that is a stream-bearing path (not a scheme://) is still scanned.
202
+ reason = evaluate_arg_paths(
203
+ ["-o=.pyddock:pwned"],
204
+ arg_paths="protected",
205
+ workspace_root=tmp_path,
206
+ workspace_module_dirs={},
207
+ shell_command_patterns=[],
208
+ )
209
+ if sys.platform == "win32":
210
+ assert reason is not None and "alternate data stream" in reason
211
+ else:
212
+ # NTFS ADS is Windows-only; on POSIX ':' is a legal filename char.
213
+ assert reason is None or "alternate data stream" not in reason
214
+
147
215
 
148
216
  class TestAdsWriteBlockedEndToEnd:
149
217
  @pytest.mark.skipif(sys.platform != "win32", reason="NTFS ADS is Windows-only")
@@ -480,7 +480,7 @@ wheels = [
480
480
 
481
481
  [[package]]
482
482
  name = "pyddock"
483
- version = "0.3.1"
483
+ version = "0.3.2"
484
484
  source = { editable = "." }
485
485
  dependencies = [
486
486
  { name = "mcp" },
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