deno
ca368e28 - fix(core): restrict extension loaders to internal modules (#36013)

Commit
125 days ago
fix(core): restrict extension loaders to internal modules (#36013) `createLazyLoader` and `loadExtScript` are capabilities used by internal extension modules to defer loading code. They need to remain available on the full core imported through `ext:core/mod.js`, but that full core was also copied into `Deno[Deno.internal].core`, which is reachable from user code. This fixes the capability boundary without breaking compatibility for existing internal-core consumers: - expose a frozen, null-prototype copy of the existing core surface through `Deno[Deno.internal].core`, omitting only `createLazyLoader` and `loadExtScript` - preserve resource helpers such as `read`, `readAll`, and `close` - keep the full core, including extension loaders, available to actual extension modules through `ext:core/mod.js` - reject direct lazy ESM loads unless the specifier was registered as lazy, before considering cached modules - add regressions for the user-visible loader boundary, retained resource helpers, and non-lazy cached modules Tests: - `./tools/format.js` - `CARGO_INCREMENTAL=0 CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0 RUSTC_WRAPPER= ./tools/lint.js` - `CARGO_INCREMENTAL=0 CARGO_PROFILE_DEV_DEBUG=0 RUSTC_WRAPPER= cargo build --bin deno` - `cargo test -p deno_core test_lazy_loaded_esm --lib -- --nocapture` (6 passed) - `DENO_DIR=/tmp/deno2-ops-unit-cache ./target/debug/deno test -A --config tests/config/deno.json tests/unit/ops_test.ts` (2 passed) - `DENO_DIR=/tmp/deno2-streams-unit-cache ./target/debug/deno test -A --config tests/config/deno.json tests/unit/streams_test.ts` (64 passed) - `cargo test specs::repl::json -- --nocapture` - `cargo test specs::run::unref_stdin -- --nocapture` - runtime surface check confirms `read`, `readAll`, and `close` remain functions while both loaders are absent and the wrapper is frozen - runtime smoke coverage for lazy `node:buffer` loading and Web Locks
Author
Parents
Loading