libdeno 0.3.8__tar.gz → 0.3.9__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 (204) hide show
  1. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/ci.yml +19 -0
  2. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/compatibility.yml +13 -1
  3. libdeno-0.3.9/AGENTS.md +42 -0
  4. {libdeno-0.3.8 → libdeno-0.3.9}/CHANGELOG.md +65 -0
  5. {libdeno-0.3.8 → libdeno-0.3.9}/Cargo.lock +3 -3
  6. {libdeno-0.3.8 → libdeno-0.3.9}/Cargo.toml +12 -1
  7. {libdeno-0.3.8 → libdeno-0.3.9}/PKG-INFO +2 -2
  8. {libdeno-0.3.8 → libdeno-0.3.9}/README-pypi.md +1 -1
  9. {libdeno-0.3.8 → libdeno-0.3.9}/README.md +1 -1
  10. {libdeno-0.3.8 → libdeno-0.3.9}/SECURITY.md +105 -0
  11. libdeno-0.3.9/build_support/snapshot_bundle/tests.rs +202 -0
  12. {libdeno-0.3.8 → libdeno-0.3.9}/build_support/snapshot_bundle.rs +36 -158
  13. libdeno-0.3.9/docs/api.md +1112 -0
  14. {libdeno-0.3.8 → libdeno-0.3.9}/docs/architecture.md +21 -2
  15. {libdeno-0.3.8 → libdeno-0.3.9}/docs/getting-started.md +23 -6
  16. {libdeno-0.3.8 → libdeno-0.3.9}/docs/musl.md +9 -1
  17. {libdeno-0.3.8 → libdeno-0.3.9}/docs/npm-support.md +35 -2
  18. {libdeno-0.3.8 → libdeno-0.3.9}/docs/permissions.md +74 -1
  19. {libdeno-0.3.8 → libdeno-0.3.9}/docs/prebuilt-snapshots.md +18 -8
  20. {libdeno-0.3.8 → libdeno-0.3.9}/docs/python.md +25 -2
  21. libdeno-0.3.9/examples/demo.rs +212 -0
  22. {libdeno-0.3.8 → libdeno-0.3.9}/examples/npm-plugin.md +19 -0
  23. {libdeno-0.3.8 → libdeno-0.3.9}/patches/deno-musl-0.267.0-0.197.0.patch +10 -0
  24. {libdeno-0.3.8 → libdeno-0.3.9}/pyproject.toml +1 -1
  25. {libdeno-0.3.8 → libdeno-0.3.9}/python/Cargo.lock +4 -4
  26. {libdeno-0.3.8 → libdeno-0.3.9}/python/Cargo.toml +2 -2
  27. {libdeno-0.3.8 → libdeno-0.3.9}/python/tests/test_api.py +58 -0
  28. {libdeno-0.3.8 → libdeno-0.3.9}/python/tests/test_runtime_state.py +14 -0
  29. libdeno-0.3.9/python/tests/test_rust_parity.py +90 -0
  30. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/fetch-snapshot.sh +3 -0
  31. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/test-fetch-snapshot.py +6 -0
  32. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/test-musl-patch.py +8 -0
  33. {libdeno-0.3.8 → libdeno-0.3.9}/src/deno_runtime_adapter.rs +7 -1
  34. {libdeno-0.3.8 → libdeno-0.3.9}/src/http/tests.rs +24 -2
  35. {libdeno-0.3.8 → libdeno-0.3.9}/src/http.rs +6 -8
  36. {libdeno-0.3.8 → libdeno-0.3.9}/src/lib.rs +100 -27
  37. {libdeno-0.3.8 → libdeno-0.3.9}/src/limits.rs +81 -2
  38. {libdeno-0.3.8 → libdeno-0.3.9}/src/module_loader.rs +8 -2
  39. {libdeno-0.3.8 → libdeno-0.3.9}/src/output.rs +14 -11
  40. {libdeno-0.3.8 → libdeno-0.3.9}/src/permissions.rs +67 -1
  41. {libdeno-0.3.8 → libdeno-0.3.9}/src/pipe_read.rs +86 -0
  42. {libdeno-0.3.8 → libdeno-0.3.9}/src/runtime.rs +31 -12
  43. {libdeno-0.3.8 → libdeno-0.3.9}/src/runtime_guards.rs +27 -2
  44. {libdeno-0.3.8 → libdeno-0.3.9}/src/services.rs +6 -1
  45. {libdeno-0.3.8 → libdeno-0.3.9}/src/subprocess.rs +82 -22
  46. {libdeno-0.3.8 → libdeno-0.3.9}/src/worker_factory.rs +3 -0
  47. libdeno-0.3.9/tests/analysis_cache.rs +141 -0
  48. libdeno-0.3.9/tests/args_contract.rs +125 -0
  49. {libdeno-0.3.8 → libdeno-0.3.9}/tests/async_api.rs +127 -0
  50. libdeno-0.3.9/tests/blocking_file_reads.rs +230 -0
  51. libdeno-0.3.9/tests/broker_install_admission.rs +118 -0
  52. libdeno-0.3.9/tests/capture_limits.rs +131 -0
  53. libdeno-0.3.9/tests/capture_parallelism.rs +152 -0
  54. {libdeno-0.3.8 → libdeno-0.3.9}/tests/concurrency.rs +2 -1
  55. libdeno-0.3.9/tests/concurrent_file_write.rs +125 -0
  56. libdeno-0.3.9/tests/control_env_vars.rs +301 -0
  57. libdeno-0.3.9/tests/cwd_resolution.rs +350 -0
  58. libdeno-0.3.9/tests/deadline_shapes.rs +159 -0
  59. libdeno-0.3.9/tests/entry_resolution.rs +208 -0
  60. libdeno-0.3.9/tests/env_cross_run.rs +142 -0
  61. libdeno-0.3.9/tests/env_knobs.rs +59 -0
  62. {libdeno-0.3.8 → libdeno-0.3.9}/tests/executor.rs +94 -13
  63. libdeno-0.3.9/tests/executor_backend_shapes.rs +107 -0
  64. libdeno-0.3.9/tests/executor_capture_limits.rs +114 -0
  65. libdeno-0.3.9/tests/exit_code_shapes.rs +61 -0
  66. libdeno-0.3.9/tests/features.rs +303 -0
  67. libdeno-0.3.9/tests/ffi_path_grants.rs +110 -0
  68. libdeno-0.3.9/tests/heap_cap_shapes.rs +125 -0
  69. libdeno-0.3.9/tests/hook_scope.rs +82 -0
  70. libdeno-0.3.9/tests/import_grant_defaults.rs +71 -0
  71. libdeno-0.3.9/tests/local_lockfile.rs +151 -0
  72. libdeno-0.3.9/tests/memory_source_disk_isolation.rs +86 -0
  73. libdeno-0.3.9/tests/module_identity.rs +162 -0
  74. {libdeno-0.3.8 → libdeno-0.3.9}/tests/module_loader_regressions.rs +47 -0
  75. libdeno-0.3.9/tests/module_modes.rs +264 -0
  76. libdeno-0.3.9/tests/nested_spawn_guard.rs +92 -0
  77. {libdeno-0.3.8 → libdeno-0.3.9}/tests/node_ipc.rs +5 -2
  78. {libdeno-0.3.8 → libdeno-0.3.9}/tests/npm_cache.rs +3 -3
  79. {libdeno-0.3.8 → libdeno-0.3.9}/tests/output_capture.rs +233 -0
  80. libdeno-0.3.9/tests/path_grant_boundaries.rs +123 -0
  81. {libdeno-0.3.8 → libdeno-0.3.9}/tests/permission_broker_require.rs +4 -0
  82. libdeno-0.3.9/tests/phase_diagnostics.rs +126 -0
  83. libdeno-0.3.9/tests/run_grant_boundaries.rs +206 -0
  84. libdeno-0.3.9/tests/run_parallelism.rs +119 -0
  85. {libdeno-0.3.8 → libdeno-0.3.9}/tests/runtime.rs +253 -13
  86. {libdeno-0.3.8 → libdeno-0.3.9}/tests/runtime_regressions.rs +18 -19
  87. libdeno-0.3.9/tests/script_spawned_process_leak.rs +106 -0
  88. {libdeno-0.3.8 → libdeno-0.3.9}/tests/smoke.rs +80 -1
  89. libdeno-0.3.9/tests/stack_overflow_recovery.rs +86 -0
  90. libdeno-0.3.9/tests/stdin_shapes.rs +88 -0
  91. libdeno-0.3.9/tests/subprocess_capture_concurrency.rs +187 -0
  92. libdeno-0.3.9/tests/subprocess_config_validation.rs +180 -0
  93. {libdeno-0.3.8 → libdeno-0.3.9}/tests/supervisor.rs +120 -2
  94. libdeno-0.3.9/tests/typescript_entries.rs +132 -0
  95. libdeno-0.3.9/tests/worker_deadline_stops.rs +133 -0
  96. libdeno-0.3.9/tests/worker_env_scope.rs +258 -0
  97. libdeno-0.3.9/tests/worker_errors.rs +110 -0
  98. libdeno-0.3.9/tests/worker_heap_cap.rs +87 -0
  99. libdeno-0.3.9/tests/worker_permission_escalation.rs +98 -0
  100. {libdeno-0.3.8 → libdeno-0.3.9}/tests/worker_preload_cancellation.rs +7 -2
  101. libdeno-0.3.9/tests/workspace_member_resolution.rs +112 -0
  102. libdeno-0.3.8/docs/api.md +0 -548
  103. libdeno-0.3.8/examples/demo.rs +0 -87
  104. libdeno-0.3.8/tests/analysis_cache.rs +0 -67
  105. libdeno-0.3.8/tests/features.rs +0 -83
  106. libdeno-0.3.8/tests/module_modes.rs +0 -86
  107. {libdeno-0.3.8 → libdeno-0.3.9}/.cargo/audit.toml +0 -0
  108. {libdeno-0.3.8 → libdeno-0.3.9}/.cargo/config.toml +0 -0
  109. {libdeno-0.3.8 → libdeno-0.3.9}/.github/dependabot.yml +0 -0
  110. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/audit-with-temporary-exceptions.py +0 -0
  111. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/check-version-sync.py +0 -0
  112. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/published-smoke.yml +0 -0
  113. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/python-pr.yml +0 -0
  114. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/python.yml +0 -0
  115. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/release.yml +0 -0
  116. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/security.yml +0 -0
  117. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/snapshot-reuse.yml +0 -0
  118. {libdeno-0.3.8 → libdeno-0.3.9}/.github/workflows/test_audit_temporary_exceptions.py +0 -0
  119. {libdeno-0.3.8 → libdeno-0.3.9}/.gitignore +0 -0
  120. {libdeno-0.3.8 → libdeno-0.3.9}/.ignore +0 -0
  121. {libdeno-0.3.8 → libdeno-0.3.9}/LICENSE +0 -0
  122. {libdeno-0.3.8 → libdeno-0.3.9}/README.zh-CN.md +0 -0
  123. {libdeno-0.3.8 → libdeno-0.3.9}/benches/baseline.rs +0 -0
  124. {libdeno-0.3.8 → libdeno-0.3.9}/build.rs +0 -0
  125. {libdeno-0.3.8 → libdeno-0.3.9}/build_support/snapshot_arch.rs +0 -0
  126. {libdeno-0.3.8 → libdeno-0.3.9}/build_support/snapshot_compat.rs +0 -0
  127. {libdeno-0.3.8 → libdeno-0.3.9}/build_support/snapshot_identity.rs +0 -0
  128. {libdeno-0.3.8 → libdeno-0.3.9}/build_support/snapshot_sources.rs +0 -0
  129. {libdeno-0.3.8 → libdeno-0.3.9}/docs/native-extensions.md +0 -0
  130. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/index.js +0 -0
  131. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/math.js +0 -0
  132. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/package-lock.json +0 -0
  133. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/package.json +0 -0
  134. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/pkg.json +0 -0
  135. {libdeno-0.3.8 → libdeno-0.3.9}/examples/demo-app/tschalk_test.ts +0 -0
  136. {libdeno-0.3.8 → libdeno-0.3.9}/examples/native_extension/init.js +0 -0
  137. {libdeno-0.3.8 → libdeno-0.3.9}/examples/native_extension/main.js +0 -0
  138. {libdeno-0.3.8 → libdeno-0.3.9}/examples/native_extension.rs +0 -0
  139. {libdeno-0.3.8 → libdeno-0.3.9}/libdeno/libdeno/__init__.py +0 -0
  140. {libdeno-0.3.8 → libdeno-0.3.9}/libdeno/libdeno/__init__.pyi +0 -0
  141. {libdeno-0.3.8 → libdeno-0.3.9}/libdeno/libdeno/py.typed +0 -0
  142. {libdeno-0.3.8 → libdeno-0.3.9}/python/fixture.js +0 -0
  143. {libdeno-0.3.8 → libdeno-0.3.9}/python/libdeno/__init__.py +0 -0
  144. {libdeno-0.3.8 → libdeno-0.3.9}/python/src/lib.rs +0 -0
  145. {libdeno-0.3.8 → libdeno-0.3.9}/python/src/options.rs +0 -0
  146. {libdeno-0.3.8 → libdeno-0.3.9}/python/src/output.rs +0 -0
  147. {libdeno-0.3.8 → libdeno-0.3.9}/python/src/runtime.rs +0 -0
  148. {libdeno-0.3.8 → libdeno-0.3.9}/python/src/source.rs +0 -0
  149. {libdeno-0.3.8 → libdeno-0.3.9}/python/tests/test_capture.py +0 -0
  150. {libdeno-0.3.8 → libdeno-0.3.9}/python/tests/test_option_validation.py +0 -0
  151. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/snapshot_compat.py +0 -0
  152. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/snapshot_compat_path_tests.py +0 -0
  153. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/snapshot_compat_publication_tests.py +0 -0
  154. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/test-snapshot-compat.py +0 -0
  155. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/test-snapshot-import.py +0 -0
  156. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/test-validate-sdist.py +0 -0
  157. {libdeno-0.3.8 → libdeno-0.3.9}/scripts/validate_sdist.py +0 -0
  158. {libdeno-0.3.8 → libdeno-0.3.9}/src/analysis_cache.rs +0 -0
  159. {libdeno-0.3.8 → libdeno-0.3.9}/src/bin/broker_host.rs +0 -0
  160. {libdeno-0.3.8 → libdeno-0.3.9}/src/bin/child_host.rs +0 -0
  161. {libdeno-0.3.8 → libdeno-0.3.9}/src/bin/dummy_host.rs +0 -0
  162. {libdeno-0.3.8 → libdeno-0.3.9}/src/bin/hook_host.rs +0 -0
  163. {libdeno-0.3.8 → libdeno-0.3.9}/src/budget.rs +0 -0
  164. {libdeno-0.3.8 → libdeno-0.3.9}/src/deno_resolver_adapter.rs +0 -0
  165. {libdeno-0.3.8 → libdeno-0.3.9}/src/executor.rs +0 -0
  166. {libdeno-0.3.8 → libdeno-0.3.9}/src/graph.rs +0 -0
  167. {libdeno-0.3.8 → libdeno-0.3.9}/src/node_loader.rs +0 -0
  168. {libdeno-0.3.8 → libdeno-0.3.9}/src/npm_cache.rs +0 -0
  169. {libdeno-0.3.8 → libdeno-0.3.9}/src/output/tests/capture_tests.rs +0 -0
  170. {libdeno-0.3.8 → libdeno-0.3.9}/src/permission_broker/tests.rs +0 -0
  171. {libdeno-0.3.8 → libdeno-0.3.9}/src/permission_broker.rs +0 -0
  172. {libdeno-0.3.8 → libdeno-0.3.9}/src/runtime_guards/init.js +0 -0
  173. {libdeno-0.3.8 → libdeno-0.3.9}/src/runtime_guards/require.rs +0 -0
  174. {libdeno-0.3.8 → libdeno-0.3.9}/src/runtime_guards/test_routes.js +0 -0
  175. {libdeno-0.3.8 → libdeno-0.3.9}/src/snapshot_identity.rs +0 -0
  176. {libdeno-0.3.8 → libdeno-0.3.9}/src/subprocess/tests/lifecycle_tests.rs +0 -0
  177. {libdeno-0.3.8 → libdeno-0.3.9}/src/supervisor/tests/read_tests.rs +0 -0
  178. {libdeno-0.3.8 → libdeno-0.3.9}/src/supervisor.rs +0 -0
  179. {libdeno-0.3.8 → libdeno-0.3.9}/src/thread_messaging/tests.rs +0 -0
  180. {libdeno-0.3.8 → libdeno-0.3.9}/src/thread_messaging.rs +0 -0
  181. {libdeno-0.3.8 → libdeno-0.3.9}/src/timing.rs +0 -0
  182. {libdeno-0.3.8 → libdeno-0.3.9}/src/token.rs +0 -0
  183. {libdeno-0.3.8 → libdeno-0.3.9}/src/worker_lifecycle.rs +0 -0
  184. {libdeno-0.3.8 → libdeno-0.3.9}/tests/blob_modules.rs +0 -0
  185. {libdeno-0.3.8 → libdeno-0.3.9}/tests/capture_windows.rs +0 -0
  186. {libdeno-0.3.8 → libdeno-0.3.9}/tests/cjs_analysis_modes.rs +0 -0
  187. {libdeno-0.3.8 → libdeno-0.3.9}/tests/common/mod.rs +0 -0
  188. {libdeno-0.3.8 → libdeno-0.3.9}/tests/fixtures/minimal_addon.c +0 -0
  189. {libdeno-0.3.8 → libdeno-0.3.9}/tests/fixtures/runtime-guard-localhost.crt +0 -0
  190. {libdeno-0.3.8 → libdeno-0.3.9}/tests/fixtures/runtime-guard-localhost.key +0 -0
  191. {libdeno-0.3.8 → libdeno-0.3.9}/tests/native_addon.rs +0 -0
  192. {libdeno-0.3.8 → libdeno-0.3.9}/tests/native_extension/init.js +0 -0
  193. {libdeno-0.3.8 → libdeno-0.3.9}/tests/native_extensions.rs +0 -0
  194. {libdeno-0.3.8 → libdeno-0.3.9}/tests/permission_broker_install.rs +0 -0
  195. {libdeno-0.3.8 → libdeno-0.3.9}/tests/permission_broker_require_probe/init.js +0 -0
  196. {libdeno-0.3.8 → libdeno-0.3.9}/tests/permission_install.rs +0 -0
  197. {libdeno-0.3.8 → libdeno-0.3.9}/tests/remote_lockfile.rs +0 -0
  198. {libdeno-0.3.8 → libdeno-0.3.9}/tests/resolver_regressions.rs +0 -0
  199. {libdeno-0.3.8 → libdeno-0.3.9}/tests/runtime_guards.rs +0 -0
  200. {libdeno-0.3.8 → libdeno-0.3.9}/tests/shared_array_buffer_transfer.rs +0 -0
  201. {libdeno-0.3.8 → libdeno-0.3.9}/tests/snapshot_architecture.rs +0 -0
  202. {libdeno-0.3.8 → libdeno-0.3.9}/tests/snapshot_bundle.rs +0 -0
  203. {libdeno-0.3.8 → libdeno-0.3.9}/tests/snapshot_sources.rs +0 -0
  204. {libdeno-0.3.8 → libdeno-0.3.9}/tests/thread_messaging.rs +0 -0
@@ -39,6 +39,19 @@ jobs:
39
39
  with:
40
40
  cache-on-failure: false
41
41
 
42
+ # Every test target statically links V8, so `--all-targets` leaves tens of
43
+ # GB of ~500 MB binaries in `target/`. The hosted image ships ~30 GB of
44
+ # SDKs this crate never touches; removing them is what makes the build
45
+ # fit. Without this the job dies mid-test with the runner losing its
46
+ # connection to the server, which reads like a network flake.
47
+ - name: Reclaim runner disk
48
+ run: |
49
+ df -h /
50
+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
51
+ /opt/hostedtoolcache/CodeQL /usr/local/share/boost
52
+ sudo docker image prune --all --force || true
53
+ df -h /
54
+
42
55
  - name: Fetch pinned crate sources
43
56
  run: cargo fetch --locked
44
57
 
@@ -73,7 +86,13 @@ jobs:
73
86
  - name: Test
74
87
  # --locked keeps CI in sync with the committed Cargo.lock (the release
75
88
  # publish is --locked too, so lockfile drift fails here, not at tag).
89
+ # Serializing most of the build keeps the linker from being run once per
90
+ # test binary at the same time: each one links V8 statically, and doing
91
+ # dozens concurrently on a 4-core runner ends in `ld terminated with
92
+ # signal 7 [Bus error]` rather than a test failure.
76
93
  run: cargo test --all-targets --locked
94
+ env:
95
+ CARGO_BUILD_JOBS: 2
77
96
 
78
97
  - name: Prepare execution-control feature test
79
98
  run: |
@@ -49,6 +49,15 @@ jobs:
49
49
 
50
50
  - name: Test
51
51
  run: cargo test --all-targets --locked
52
+ env:
53
+ CARGO_BUILD_JOBS: 2
54
+
55
+ # Every test target statically links V8, so one build leaves tens of GB of
56
+ # binaries in `target/`. Building a second feature variant on top of them
57
+ # exhausts the runner's disk — the linker fails with `write() failed,
58
+ # errno=28` instead of a test failing. `ci.yml` already cleans the same way.
59
+ - name: Prepare execution-control feature test
60
+ run: cargo clean -p libdeno
52
61
 
53
62
  - name: Test execution-control feature
54
63
  run: cargo test --all-targets --features execution-control,phase-diagnostics --locked
@@ -69,7 +78,10 @@ jobs:
69
78
 
70
79
  - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
71
80
  with:
72
- python-version: "3.9"
81
+ # Any 3.x runs this step; it greps manifests, it does not exercise the
82
+ # binding. 3.9 is no longer published for ubuntu-latest (26.04), and
83
+ # setup-python fails before the script runs.
84
+ python-version: "3.13"
73
85
 
74
86
  - name: Check Python minimum and release metadata
75
87
  shell: bash
@@ -0,0 +1,42 @@
1
+ # Development workflow
2
+
3
+ - Create and switch to a `feat/<xxx-feat-name>` branch before starting development work.
4
+ - Use a descriptive, kebab-case feature name.
5
+ - Push changes to the feature branch and open a GitHub Pull Request.
6
+ - Merge into the default branch only through a reviewed Pull Request after required CI checks pass.
7
+ - Do not commit or push development changes directly to the default branch.
8
+ - Preserve existing uncommitted changes when switching branches; never discard them to satisfy this workflow.
9
+ - Do not commit without being asked. Before any commit, the full CI gate must pass locally.
10
+
11
+ # Constraints
12
+
13
+ - Code, comments, and commit messages are English only. User-facing docs may be
14
+ Chinese (`README.zh-CN.md`).
15
+ - Keep every source file under 500 lines. Generated files (lockfiles, snapshot
16
+ tables) are exempt.
17
+ - Edit in small batches: roughly 500-2000 characters per change, not one giant
18
+ rewrite. Sub-agents get the same rule, repeated in their brief.
19
+ - Do not run the full test suite or reformat after every change. Batch that at
20
+ the end, or test a single file at a time.
21
+ - Never change system configuration or install global packages without explicit
22
+ consent.
23
+ - Clean up scratch directories and temp artifacts after a large piece of work.
24
+
25
+ # Research and design
26
+
27
+ - Verify upstream behavior in its source, not only in docs or search results.
28
+ This crate is pinned to specific Deno/V8 revisions; the source in the registry
29
+ checkout is the authority.
30
+ - Check what already exists before adding anything. Prefer reusing or copying a
31
+ proven upstream implementation over inventing one, then reduce it to the
32
+ smallest thing that works.
33
+ - Stay critical of your own evidence. A passing test proves what it asserts, not
34
+ what you assumed.
35
+
36
+ # Writing
37
+
38
+ - Docs should be dense and readable. Skip defensive framing ("this is not X, nor
39
+ Y"); state what it is and why. Examples are fine for hard concepts.
40
+ - Explain without project shorthand. Assume a mid-level engineer who has never
41
+ seen this codebase, and name things plainly instead of compressing them into
42
+ internal labels.
@@ -5,6 +5,71 @@ breaking changes are highlighted per release with migration notes.
5
5
 
6
6
  [keep a changelog]: https://keepachangelog.com/en/1.1.0/
7
7
 
8
+ ## 0.3.9
9
+
10
+ ### Changed
11
+
12
+ - In-process runs refuse `Deno.chdir()` with `NotSupported`. The script's
13
+ `chdir` changed the **host** process's working directory, redirecting the
14
+ host's own relative paths and corrupting concurrent runs.
15
+ `LibdenoOptions.cwd` is a resolution base only, as the docs always said. Use
16
+ `run_in_subprocess` when a script needs its own working directory.
17
+ - `--allow-env` no longer covers libdeno's control variables:
18
+ `LIBDENO_HOST_EXE`, `LIBDENO_CHILD_MODE`, `LIBDENO_CHILD_TOKEN`, the
19
+ supervisor trio, `LIBDENO_ANALYSIS_CACHE_ENTRIES`,
20
+ `LIBDENO_MAX_TARBALL_DECOMPRESSED_BYTES`, `DENO_DIR`, `DENO_NO_PACKAGE_JSON`,
21
+ `JSR_URL`, and the npm registry variables. Reading, writing, or deleting one
22
+ is denied even when it is named in the grant. Before, a script could set
23
+ `LIBDENO_HOST_EXE` and pick the binary the next `run_in_subprocess` executed.
24
+ - An explicit `LibdenoOptions.cwd` must resolve to a directory; anything else is
25
+ `LibdenoError::Configuration`. It used to fall back to the raw path, so the
26
+ script ran with the host cwd while its permission grants pointed at the
27
+ missing directory.
28
+ - `prompt: true` with stderr capture is rejected when the options are validated.
29
+ The prompter requires stderr to be a terminal and capture replaces it with a
30
+ pipe, so every ungranted check failed closed as `NotCapable` and no prompt was
31
+ shown. This covers `capture_stderr: true` and `run_in_subprocess_with_output`,
32
+ which always pipes stderr.
33
+ - The subprocess parent validates the options before spawning: permission flags,
34
+ heap cap, deadline, and the prompt/capture pair. A child that rejected its own
35
+ configuration printed to stderr and exited 1, so the parent returned
36
+ `Ok(exit_code: 1)` — indistinguishable from the script exiting 1 on purpose. A
37
+ zero `execution_deadline` is now rejected before the child starts, as
38
+ in-process runs already did.
39
+
40
+ ### Fixed
41
+
42
+ - `max_heap_bytes` terminates the script instead of aborting the host process.
43
+ V8 calls `FatalProcessOutOfMemory` when the old generation fills, which an
44
+ embedder cannot catch; every isolate, main and Web Worker, now gets a
45
+ near-heap-limit callback that requests termination first, so the run fails
46
+ with a termination error and the process survives.
47
+ - `LibdenoRuntime::new` keeps the directory spelling the caller passed.
48
+ Canonicalizing it made the resolver stack, the entry `file:` URL, and literal
49
+ path grants disagree on macOS (`/var/...` vs `/private/var/...`), which broke
50
+ workspace-member resolution and denied scoped read grants for the entry the
51
+ caller named.
52
+ - A dynamic import is read-checked against the unresolved path, matching the
53
+ static loader. Canonicalizing first made a symlinked dependency load
54
+ statically and be denied at runtime.
55
+ - Script-spawned processes do not outlive the run: `ChildResource::drop` sends
56
+ SIGKILL unless the script called `unref()` or spawned with `detached: true`.
57
+ `docs/api.md` said otherwise. The old test agreed because `ps -o stat=`
58
+ reports `Z` for a killed-but-unreaped process.
59
+ - A deadline stops Web Workers with the run (`workers.close()` and wait); the
60
+ docs claimed the opposite.
61
+ - The subprocess exit-code claim is now platform-correct: a POSIX wait status
62
+ keeps the low 8 bits (`Deno.exit(300)` reads back as `44`), while a Windows
63
+ process exit code is the full 32-bit value. In-process `RunOutput::exit_code`
64
+ keeps the requested value on both.
65
+ - The capture-incomplete error names its usual cause, a detached child holding
66
+ the pipe open, and suggests `stdout: "null"` or a log file.
67
+
68
+ ### Security
69
+
70
+ - `libz-sys` 1.1.29 → 1.1.31 in both lockfiles, clearing RUSTSEC-2026-0418 (the
71
+ build script leaked environment variables into the build directory).
72
+
8
73
  ## 0.3.8
9
74
 
10
75
  ### Added
@@ -4835,7 +4835,7 @@ dependencies = [
4835
4835
 
4836
4836
  [[package]]
4837
4837
  name = "libdeno"
4838
- version = "0.3.8"
4838
+ version = "0.3.9"
4839
4839
  dependencies = [
4840
4840
  "anyhow",
4841
4841
  "async-trait",
@@ -4963,9 +4963,9 @@ dependencies = [
4963
4963
 
4964
4964
  [[package]]
4965
4965
  name = "libz-sys"
4966
- version = "1.1.29"
4966
+ version = "1.1.31"
4967
4967
  source = "registry+https://github.com/rust-lang/crates.io-index"
4968
- checksum = "85bc9657773828b90eeb625adff10eeac83cc21bbfd8e23a03eaa8a33c9e28d9"
4968
+ checksum = "ff20308ecabd635a2dc1dd5834a86c462cca20efba1d5d3ddab1f8aea3455cb2"
4969
4969
  dependencies = [
4970
4970
  "cc",
4971
4971
  "pkg-config",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "libdeno"
3
- version = "0.3.8"
3
+ version = "0.3.9"
4
4
  edition = "2021"
5
5
  # Workflow toolchain actions are authoritative for compatibility: stable CI
6
6
  # plus an explicit MSRV 1.95.0 check. No rust-toolchain.toml is checked in;
@@ -135,6 +135,17 @@ snapshot-import = []
135
135
  [package.metadata.docs.rs]
136
136
  no-default-features = true
137
137
 
138
+ # Every integration test statically links V8, so one test binary is ~450 MB and
139
+ # `--all-targets` does not fit a CI runner's disk at full debug info: measured
140
+ # 39 GB with line tables against 144 GB without. Line tables keep panic
141
+ # backtraces readable while dropping variable and type information, which is
142
+ # most of the size. Override on a specific failing test for full detail:
143
+ # CARGO_PROFILE_TEST_DEBUG=2 cargo test --test <name>
144
+ #
145
+ # Only the test profile is relaxed; `cargo build` keeps full debug info.
146
+ [profile.test]
147
+ debug = "line-tables-only"
148
+
138
149
  [profile.release]
139
150
  debug = false
140
151
  # Release profile for this workspace's own builds (the demo example and CI
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libdeno
3
- Version: 0.3.8
3
+ Version: 0.3.9
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -24,7 +24,7 @@ Project-URL: Repository, https://github.com/agentsyaml/libdeno
24
24
 
25
25
  # libdeno Python API
26
26
 
27
- The Python distribution and Rust crate are versioned at `0.3.8`. The Python
27
+ The Python distribution and Rust crate are versioned at `0.3.9`. The Python
28
28
  API is alpha and provides synchronous access to the runtime:
29
29
 
30
30
  ```python
@@ -1,6 +1,6 @@
1
1
  # libdeno Python API
2
2
 
3
- The Python distribution and Rust crate are versioned at `0.3.8`. The Python
3
+ The Python distribution and Rust crate are versioned at `0.3.9`. The Python
4
4
  API is alpha and provides synchronous access to the runtime:
5
5
 
6
6
  ```python
@@ -140,7 +140,7 @@ Linux x86_64/aarch64, macOS x86_64/arm64, and Windows x64. See the
140
140
  |---|---|
141
141
  | `LibdenoOptions.permissions` | Explicit `--allow-*` capabilities. An empty list is a configuration error unless `allow_all_permissions` or `prompt` is enabled. |
142
142
  | `LibdenoOptions.args` / `cwd` | Script arguments and the base directory for resolving entries and imports. In-process scripts observe the host process's current directory. |
143
- | `LibdenoOptions.features` | Overrides the default unstable API set (`kv`, `cron`, `ffi`, `webgpu`, `worker-options`). |
143
+ | `LibdenoOptions.features` | Overrides the default unstable API set (`kv`, `cron`, `ffi`, `webgpu`, `worker-options`). In Deno 2.9.x only `kv` and `cron` still gate anything among those defaults, and `ffi` / `webgpu` are stable so the list does not restrict them; `net` and `raw-imports` gate their namespaces but are not in the default set, so they only matter when you add them. |
144
144
  | `LibdenoError` | Errors for entry resolution, permissions, configuration, runtime execution, I/O, or deadlines. See the [API reference](docs/api.md) for variants. |
145
145
 
146
146
  Remote module imports require `--allow-import`; file imports require
@@ -39,6 +39,96 @@ labels and `cause` fields do not identify permission denials. The Python API
39
39
  uses this classification when mapping `Runtime` / `Core` errors to
40
40
  `DenoPermissionError`.
41
41
 
42
+ ### Path grants follow names, not inodes
43
+
44
+ `--allow-read` / `--allow-write` check the path a script names. Lexical escapes
45
+ are rejected: `..` and absolute paths outside a granted root fail with
46
+ `NotCapable`. Links are not resolved, so a grant on a directory also covers any
47
+ symbolic link inside it and any hard link to an outside file: the script can
48
+ read or overwrite the link target, and writing through a symlinked directory
49
+ creates files outside the granted root. Verified against Deno CLI 2.9.8, which
50
+ behaves identically; this is Deno's permission model, not a libdeno divergence.
51
+ `tests/path_grant_boundaries.rs` pins it.
52
+
53
+ The same rule governs `--allow-ffi=<path>`: a grant on a directory covers a
54
+ symbolic or hard link inside it, so `Deno.dlopen` loads a library that lives
55
+ outside the granted root. Measured with `--allow-ffi=<dir>` and a link to
56
+ `/opt/homebrew/Cellar/libuv/1.53.0/lib/libuv.1.0.0.dylib`: the direct path was
57
+ denied, the link inside the directory opened. Deno CLI 2.9.8 matches.
58
+
59
+ The consequence for a host: a path grant is only as tight as the filesystem
60
+ under that path. Do not grant write access to a directory that untrusted code
61
+ can populate with links, and treat a grant on a shared or world-writable
62
+ directory as a grant on whatever those links point at. For FFI this matters
63
+ more than for reads: loading a library is arbitrary native code in the host
64
+ process, so scope `--allow-ffi` to files the script cannot replace.
65
+
66
+ ## Environment is not a capability
67
+
68
+ `--allow-env` grants the script read and write access to the host process
69
+ environment. That surface is larger than it looks: libdeno reads the host
70
+ environment to decide *how* a run executes, so any variable it trusts is
71
+ effectively a capability the script can grant itself.
72
+
73
+ libdeno therefore keeps these names off that surface, even under a bare
74
+ `--allow-env`:
75
+
76
+ - `LIBDENO_HOST_EXE` — selects the binary a subprocess run executes.
77
+ - `LIBDENO_CHILD_MODE`, `LIBDENO_CHILD_TOKEN`, `LIBDENO_SUPERVISOR_MODE`,
78
+ `LIBDENO_SUPERVISOR_ENDPOINT`, `LIBDENO_SUPERVISOR_TOKEN` — authenticate a
79
+ run request.
80
+ - `LIBDENO_ANALYSIS_CACHE_ENTRIES`, `LIBDENO_MAX_TARBALL_DECOMPRESSED_BYTES` —
81
+ process-global resource knobs.
82
+ - `DENO_DIR`, `DENO_NO_PACKAGE_JSON`, `JSR_URL`, `NPM_CONFIG_REGISTRY`,
83
+ `NPM_CONFIG_REPLACE_REGISTRY_HOST` (and lowercase aliases) — resolver inputs
84
+ re-read on every run.
85
+
86
+ The escalation this prevents: a script sets `LIBDENO_HOST_EXE` to a binary it
87
+ wrote, and the host's next `run_in_subprocess` executes that binary — arbitrary
88
+ code with no `--allow-run`, outside every permission check. `DENO_DIR` and the
89
+ registry variables are the same shape one step removed: point them at a
90
+ location the script controls and a *later*, more privileged run fetches and
91
+ trusts the script's modules.
92
+ `-A` / `allow_all_permissions` bypasses the deny list along with every other
93
+ permission, so it remains a trusted-code-only setting.
94
+
95
+ A host that needs one of these values set must set it itself, from trusted
96
+ startup code, rather than let the script do it.
97
+
98
+ The deny list also holds inside a web worker, and `Deno.env.set` there writes
99
+ the same process environment the main thread sees. A worker created without an
100
+ explicit permission set inherits the run's `--allow-env` and can therefore
101
+ rewrite `PATH` or `HOME` for the rest of the process; a worker created with an
102
+ explicit set (`deno: { permissions: { read: [...] } }`) loses the capability and
103
+ its write is refused. See `tests/worker_env_scope.rs`.
104
+
105
+ ### Residual risk: `HOME` and `PATH`
106
+
107
+ Two variables cannot go on that list, because scripts legitimately read them
108
+ and the upstream permission model cannot deny writes while allowing reads. Both
109
+ are still host-process state that a script can rewrite, and both steer later
110
+ runs:
111
+
112
+ - `HOME` selects which `$HOME/.npmrc` the resolver reads. A script that points
113
+ it at a directory it controls changes the registry (and any credentials) a
114
+ later `npm:` resolution uses.
115
+ - `PATH` selects which binary an allowed `--allow-run` name resolves to. A
116
+ script that prepends a directory it controls makes a later run's
117
+ `Deno.Command("git")` execute its own `git`, even though the grant was
118
+ `--allow-run=git`.
119
+
120
+ Both were reproduced against this tree and pinned by `tests/env_cross_run.rs`:
121
+ one run rewrites `PATH`, then a later in-process run holding only
122
+ `--allow-run=git` executes the script's own `git`. The same test shows a
123
+ subprocess run leaves the host environment untouched, which is the mitigation
124
+ below in its simplest form. They are documented rather than denied:
125
+ blocking them would break ordinary scripts that read `HOME` or `PATH`, which is
126
+ most of them. The mitigation is architectural, not per-variable — do not run
127
+ untrusted code in the same process as a more privileged run. Give each trust
128
+ level its own process, or restart the host between trust domains. A host that
129
+ needs a specific value can also set it itself from trusted startup code and
130
+ avoid granting `--allow-env` at all.
131
+
42
132
  ## Known Upstream-Tracked Advisories
43
133
 
44
134
  The existing entries are ignored in `.cargo/audit.toml` because only the
@@ -111,6 +201,14 @@ explicit `deno.permissions` shares the parent's live permission container, so
111
201
  parent revocations apply inside it; a Worker created with explicit permission
112
202
  arguments gets a forked copy that later parent changes do not affect.
113
203
 
204
+ The explicit set can narrow the parent's grants, never widen them. Asking for
205
+ more than the parent holds fails the run rather than silently clamping:
206
+ `read: true` under a parent `--allow-read=<one directory>` produces
207
+ `NotCapable: Can't escalate parent thread permissions`, and the worker never
208
+ starts. Pass the same descriptor the parent holds (or a narrower one) — a bare
209
+ `true` means "everywhere", which the parent did not grant. A worker that omits
210
+ `deno.permissions` inherits and is unaffected.
211
+
114
212
  `max_heap_bytes` requests a best-effort V8 old-generation heap limit (minimum
115
213
  8 MiB) for the main worker and Web Workers. It does not cap total V8/native/host
116
214
  memory, RSS, CPU, or child-process memory. `execution_deadline` can interrupt
@@ -128,6 +226,13 @@ platforms and can run alongside other calls. Its cap limits retained output,
128
226
  not child resources or descendants. The execution-control supervisor retains
129
227
  64 KiB per stream by default and accepts explicit limits up to 96 KiB.
130
228
 
229
+ The pipe readers are budgeted process-wide: 64 slots, two per capture, so at
230
+ most 32 captures are in flight. A 33rd simultaneous capture fails immediately
231
+ with an `Io` error whose kind is `WouldBlock` — it is not queued, and a host
232
+ that treats every `Io` as fatal will see backpressure as a failure. The budget
233
+ is released as runs finish. A host that needs more concurrency uses
234
+ `run_in_subprocess`, which takes no pipe readers.
235
+
131
236
  HTTP module bodies and npm metadata have a 256 MiB cap on bytes returned by
132
237
  reqwest after transport decoding. Explicit npm `.tgz` responses have a 1 GiB
133
238
  cap on the returned (still compressed) body. For gzip tarballs, an `ISIZE`
@@ -0,0 +1,202 @@
1
+ use super::*;
2
+
3
+ fn identity() -> Identity {
4
+ Identity {
5
+ libdeno: "0.3.6".into(),
6
+ target: "aarch64-apple-darwin".into(),
7
+ v8: "14.2.1".into(),
8
+ typescript: "6.0.3".into(),
9
+ deno_core: "0.412.0".into(),
10
+ deno_runtime: "0.267.0".into(),
11
+ }
12
+ }
13
+
14
+ #[test]
15
+ fn manifest_roundtrip() {
16
+ let manifest = describe(&identity(), b"snapshot", b"table");
17
+ assert_eq!(parse(&render(&manifest)).unwrap(), manifest);
18
+ }
19
+
20
+ #[test]
21
+ fn verify_accepts_a_matching_bundle() {
22
+ let manifest = describe(&identity(), b"snapshot", b"table");
23
+ verify(&manifest, &identity(), b"snapshot", b"table").unwrap();
24
+ }
25
+
26
+ #[test]
27
+ fn verify_names_the_mismatched_field() {
28
+ let manifest = describe(&identity(), b"snapshot", b"table");
29
+ let mut other = identity();
30
+ other.target = "x86_64-pc-windows-msvc".into();
31
+ let error = verify(&manifest, &other, b"snapshot", b"table").unwrap_err();
32
+ assert!(error.contains("target"), "{error}");
33
+ assert!(error.contains("aarch64-apple-darwin"), "{error}");
34
+ }
35
+
36
+ #[test]
37
+ fn verify_rejects_a_truncated_snapshot() {
38
+ let manifest = describe(&identity(), b"snapshot", b"table");
39
+ let error = verify(&manifest, &identity(), b"snapsho", b"table").unwrap_err();
40
+ assert!(error.contains("snapshot does not match"), "{error}");
41
+ }
42
+
43
+ #[test]
44
+ fn parse_rejects_unknown_keys() {
45
+ let text = render(&describe(&identity(), b"", b"")).replace(
46
+ &format!("format={FORMAT}"),
47
+ &format!("format={FORMAT}\nextra=1"),
48
+ );
49
+ assert!(parse(&text).unwrap_err().contains("extra"));
50
+ }
51
+
52
+ #[test]
53
+ fn rejects_legacy_format_with_regeneration_instruction() {
54
+ let text = render(&describe(&identity(), b"", b"")).replace(FORMAT, "libdeno-snapshot-1");
55
+ assert!(parse(&text).unwrap_err().contains("regenerate"));
56
+ }
57
+
58
+ #[test]
59
+ fn residual_integrity_roundtrip_and_failures() {
60
+ let dir = std::env::temp_dir().join(format!("libdeno-residual-test-{}", std::process::id()));
61
+ let _ = std::fs::remove_dir_all(&dir);
62
+ std::fs::create_dir_all(&dir).unwrap();
63
+ let table = "include_str!(\"residual.js\")";
64
+ std::fs::write(dir.join("residual.js"), b"abc").unwrap();
65
+ let mut manifest = describe(&identity(), b"snapshot", table.as_bytes());
66
+ manifest.residuals = describe_residuals(table, &dir).unwrap();
67
+ let parsed = parse(&render(&manifest)).unwrap();
68
+ verify_residuals(&parsed, table, &dir).unwrap();
69
+ std::fs::write(dir.join("residual.js"), b"abd").unwrap();
70
+ assert!(verify_residuals(&parsed, table, &dir)
71
+ .unwrap_err()
72
+ .contains("does not match"));
73
+ std::fs::remove_file(dir.join("residual.js")).unwrap();
74
+ assert!(verify_residuals(&parsed, table, &dir)
75
+ .unwrap_err()
76
+ .contains("missing"));
77
+ std::fs::remove_dir_all(dir).unwrap();
78
+ }
79
+
80
+ #[test]
81
+ fn copied_residuals_are_checked_against_the_manifest() {
82
+ let root = std::env::temp_dir().join(format!(
83
+ "libdeno-copy-residual-{}-{}",
84
+ std::process::id(),
85
+ std::time::SystemTime::now()
86
+ .duration_since(std::time::UNIX_EPOCH)
87
+ .unwrap()
88
+ .as_nanos()
89
+ ));
90
+ let source = root.join("source");
91
+ let output = root.join("out");
92
+ std::fs::create_dir_all(&source).unwrap();
93
+ std::fs::create_dir_all(&output).unwrap();
94
+ let table = "include_str!(\"residual.js\")";
95
+ std::fs::write(source.join("residual.js"), b"abc").unwrap();
96
+ let mut manifest = describe(&identity(), b"snapshot", table.as_bytes());
97
+ manifest.residuals = describe_residuals(table, &source).unwrap();
98
+ verify_residuals(&manifest, table, &source).unwrap();
99
+ copy_verified_residuals(&manifest, table, &source, &output).unwrap();
100
+ assert_eq!(std::fs::read(output.join("residual.js")).unwrap(), b"abc");
101
+
102
+ std::fs::write(source.join("residual.js"), b"abd").unwrap();
103
+ let error = copy_verified_residuals(&manifest, table, &source, &output).unwrap_err();
104
+ assert!(
105
+ error.contains("residual source residual.js does not match"),
106
+ "{error}"
107
+ );
108
+ assert_eq!(std::fs::read(output.join("residual.js")).unwrap(), b"abd");
109
+
110
+ std::fs::remove_file(source.join("residual.js")).unwrap();
111
+ let error = copy_verified_residuals(&manifest, table, &source, &output).unwrap_err();
112
+ assert!(
113
+ error.contains("does not contain the residual source residual.js"),
114
+ "{error}"
115
+ );
116
+ std::fs::remove_dir_all(root).unwrap();
117
+ }
118
+
119
+ #[test]
120
+ fn table_sources_lists_included_files() {
121
+ let table = "pub static A: &[(&str, &str)] = &[\n (\"a\", include_str!(concat!(env!(\"OUT_DIR\"), \"/a_b.js\"))),\n];\n";
122
+ assert_eq!(table_sources(table), vec!["a_b.js"]);
123
+ }
124
+
125
+ #[test]
126
+ fn residual_names_cannot_escape_the_bundle_directory() {
127
+ // The manifest is caller-supplied input and both verify and copy do
128
+ // `dir.join(name)`. Without this check a crafted name reads arbitrary
129
+ // files and copies them into OUT_DIR.
130
+ for bad in [
131
+ "../outside.txt",
132
+ "a/../../outside.txt",
133
+ "/etc/passwd",
134
+ "\\windows\\system32\\x",
135
+ "C:/windows/x",
136
+ "./relative.js",
137
+ "a//b.js",
138
+ "",
139
+ ] {
140
+ assert!(
141
+ validate_residual_name(bad).is_err(),
142
+ "{bad:?} should be rejected"
143
+ );
144
+ }
145
+ for good in ["a_b.js", "residual_sources/file.js", "nested/dir/x.ts"] {
146
+ assert!(
147
+ validate_residual_name(good).is_ok(),
148
+ "{good:?} should be accepted"
149
+ );
150
+ }
151
+ }
152
+
153
+ #[test]
154
+ fn verify_rejects_a_traversing_residual_name() {
155
+ // Both the table and the manifest are attacker-controlled in a bundle;
156
+ // a matching pair must still be refused before any file is read.
157
+ let name = "../outside.txt";
158
+ let table = format!(
159
+ "pub static A: &[(&str, &str)] = &[\n (\"a\", include_str!(concat!(env!(\"OUT_DIR\"), \"/{name}\"))),\n];\n"
160
+ );
161
+ let mut manifest = describe(&identity(), b"snapshot", b"table");
162
+ manifest.residuals = vec![Residual {
163
+ name: name.into(),
164
+ bytes: 0,
165
+ hash: "0".repeat(16),
166
+ }];
167
+ let dir = std::env::temp_dir();
168
+ let error = verify_residuals(&manifest, &table, &dir).unwrap_err();
169
+ assert!(error.contains("not a plain relative path"), "{error}");
170
+ }
171
+
172
+ #[test]
173
+ fn table_paths_use_forward_slashes() {
174
+ assert_eq!(
175
+ table_path(Path::new("residual_sources/file.js")),
176
+ "/residual_sources/file.js"
177
+ );
178
+ // Windows separators must not reach the generated literal, where they
179
+ // would be escaped to `\\` and read back verbatim by table_sources.
180
+ let windows = table_path(Path::new(r"residual_sources\file.js"));
181
+ assert_eq!(windows, "/residual_sources/file.js");
182
+ assert!(!windows.contains('\\'), "{windows}");
183
+ assert_eq!(table_path(Path::new(r"a\b\c.js")), "/a/b/c.js");
184
+ }
185
+
186
+ #[test]
187
+ fn missing_sources_reports_only_absent_files() {
188
+ let dir = std::env::temp_dir().join(format!(
189
+ "libdeno-bundle-test-{}-{}",
190
+ std::process::id(),
191
+ std::time::SystemTime::now()
192
+ .duration_since(std::time::UNIX_EPOCH)
193
+ .unwrap()
194
+ .as_nanos()
195
+ ));
196
+ std::fs::create_dir_all(&dir).unwrap();
197
+ std::fs::write(dir.join("present.js"), b"x").unwrap();
198
+ let table = "(\"a\", include_str!(concat!(env!(\"OUT_DIR\"), \"/present.js\"))),\n\
199
+ (\"b\", include_str!(concat!(env!(\"OUT_DIR\"), \"/absent.js\"))),\n";
200
+ assert_eq!(missing_sources(table, &dir), vec!["absent.js"]);
201
+ std::fs::remove_dir_all(&dir).unwrap();
202
+ }