diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-09-26 02:50:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-26 01:50:54 +0000 |
| commit | 5504acea6751480f1425c88353ad5d36257bdce7 (patch) | |
| tree | fa02e6c546eae469aac894bfc71600ab4eccad28 /tests/testdata/run | |
| parent | 05415bb9de475aa8646985a545f30fe93136207e (diff) | |
feat: add `--allow-import` flag (#25469)
This replaces `--allow-net` for import permissions and makes the
security sandbox stricter by also checking permissions for statically
analyzable imports.
By default, this has a value of
`--allow-import=deno.land:443,jsr.io:443,esm.sh:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443`,
but that can be overridden by providing a different set of hosts.
Additionally, when no value is provided, import permissions are inferred
from the CLI arguments so the following works because
`fresh.deno.dev:443` will be added to the list of allowed imports:
```ts
deno run -A -r https://fresh.deno.dev
```
---------
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'tests/testdata/run')
6 files changed, 10 insertions, 7 deletions
diff --git a/tests/testdata/run/error_015_dynamic_import_permissions.js b/tests/testdata/run/error_015_dynamic_import_permissions.js index 47961cf63..bdf423b59 100644 --- a/tests/testdata/run/error_015_dynamic_import_permissions.js +++ b/tests/testdata/run/error_015_dynamic_import_permissions.js @@ -1,3 +1,3 @@ (async () => { - await import("" + "http://localhost:4545/subdir/mod4.js"); + await import("" + "http://example.com/subdir/mod4.js"); })(); diff --git a/tests/testdata/run/error_015_dynamic_import_permissions.out b/tests/testdata/run/error_015_dynamic_import_permissions.out index 87ce43e9c..15c26b425 100644 --- a/tests/testdata/run/error_015_dynamic_import_permissions.out +++ b/tests/testdata/run/error_015_dynamic_import_permissions.out @@ -1,4 +1,4 @@ -error: Uncaught (in promise) TypeError: Requires net access to "localhost:4545", run again with the --allow-net flag - await import("" + "http://localhost:4545/subdir/mod4.js"); +error: Uncaught (in promise) TypeError: Requires import access to "example.com:80", run again with the --allow-import flag + await import("" + "http://example.com/subdir/mod4.js"); ^ at async file://[WILDCARD]/error_015_dynamic_import_permissions.js:2:3 diff --git a/tests/testdata/run/lock_write_fetch/main.ts b/tests/testdata/run/lock_write_fetch/main.ts index 4ce631311..d8a50a9aa 100644 --- a/tests/testdata/run/lock_write_fetch/main.ts +++ b/tests/testdata/run/lock_write_fetch/main.ts @@ -9,6 +9,7 @@ const fetchProc = await new Deno.Command(Deno.execPath(), { stderr: "null", args: [ "cache", + "--allow-import", "--reload", "--lock=lock_write_fetch.json", "--cert=tls/RootCA.pem", @@ -23,6 +24,7 @@ const fetchCheckProc = await new Deno.Command(Deno.execPath(), { stderr: "null", args: [ "cache", + "--allow-import", "--lock=lock_write_fetch.json", "--cert=tls/RootCA.pem", "run/https_import.ts", @@ -38,6 +40,7 @@ const runProc = await new Deno.Command(Deno.execPath(), { stderr: "null", args: [ "run", + "--allow-import", "--lock=lock_write_fetch.json", "--allow-read", "--cert=tls/RootCA.pem", diff --git a/tests/testdata/run/type_directives_01.ts b/tests/testdata/run/type_directives_01.ts index 71305824c..2129d90b4 100644 --- a/tests/testdata/run/type_directives_01.ts +++ b/tests/testdata/run/type_directives_01.ts @@ -1,3 +1,3 @@ -import * as foo from "http://127.0.0.1:4545/xTypeScriptTypes.js"; +import * as foo from "http://localhost:4545/xTypeScriptTypes.js"; console.log(foo.foo); diff --git a/tests/testdata/run/type_directives_01.ts.out b/tests/testdata/run/type_directives_01.ts.out index 77ed3ae26..466218a96 100644 --- a/tests/testdata/run/type_directives_01.ts.out +++ b/tests/testdata/run/type_directives_01.ts.out @@ -1,3 +1,3 @@ [WILDCARD] -DEBUG TS - host.getSourceFile("http://127.0.0.1:4545/xTypeScriptTypes.d.ts", Latest) +DEBUG TS - host.getSourceFile("http://localhost:4545/xTypeScriptTypes.d.ts", Latest) [WILDCARD]
\ No newline at end of file diff --git a/tests/testdata/run/type_headers_deno_types.ts b/tests/testdata/run/type_headers_deno_types.ts index 9670f68cd..197ac1801 100644 --- a/tests/testdata/run/type_headers_deno_types.ts +++ b/tests/testdata/run/type_headers_deno_types.ts @@ -12,7 +12,7 @@ * header. */ -// @deno-types="http://127.0.0.1:4545/run/type_headers_deno_types.foo.d.ts" -import { foo } from "http://127.0.0.1:4545/run/type_headers_deno_types.foo.js"; +// @deno-types="http://localhost:4545/run/type_headers_deno_types.foo.d.ts" +import { foo } from "http://localhost:4545/run/type_headers_deno_types.foo.js"; foo("hello"); |
