Skip to content

Commit

Permalink
audit docs from Basics section for manual updates (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhinnery authored Sep 15, 2023
1 parent 04b81bd commit 0fc462c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 43 deletions.
8 changes: 0 additions & 8 deletions runtime/manual/basics/_category_.json

This file was deleted.

2 changes: 1 addition & 1 deletion runtime/manual/basics/connecting_to_databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ console.log(`Started on http://localhost:3000`);
To make GraphQL client calls in Deno, import the
[graphql npm module](https://www.npmjs.com/package/graphql) with the
[esm CDN](https://esm.sh/). To learn more about using npm modules in Deno via
CDN read [here](../node/cdns.md)
CDN read [here](../node/cdns.md).

#### Make GraphQL client calls with the graphql npm module

Expand Down
18 changes: 5 additions & 13 deletions runtime/manual/basics/import_maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ written something similar in our `deno.json` configuration file:

## Example - Using deno_std's fmt module via `fmt/`

**deno.json**

```json
```json title="deno.json"
{
"imports": {
"fmt/": "https://deno.land/std@$STD_VERSION/fmt/"
}
}
```

**color.ts**

```ts, ignore
```ts title="color.ts"
import { red } from "fmt/colors.ts";

console.log(red("hello world"));
Expand All @@ -62,9 +58,7 @@ console.log(red("hello world"));

To use your project root for absolute imports:

**deno.json**

```jsonc
```json title="deno.json"
{
"imports": {
"/": "./",
Expand All @@ -73,9 +67,7 @@ To use your project root for absolute imports:
}
```

**main.ts**

```ts, ignore
```ts title="main.ts"
import { MyUtil } from "/util.ts";
```

Expand All @@ -95,7 +87,7 @@ scope in the import map that looks something like this:
```json
{
"imports": {
"https://deno.land/[email protected]/": "https://deno.land/std/"
"https://deno.land/[email protected]/": "https://deno.land/std@$STD_VERSION/"
},
"scopes": {
"https://deno.land/x/example/": {
Expand Down
20 changes: 16 additions & 4 deletions runtime/manual/basics/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Deno is secure by default. Therefore, unless you specifically enable it, a
program run with Deno has no file, network, or environment access. Access to
security sensitive functionality requires that permissions have been granted to
an executing script through command line flags, or a runtime permission prompt.
This is a major difference from Node, where dependencies are automatically
granting full access to everything, introducing hidden vulnerabilities in your
project.

## Run untrusted code with confidence

Since Deno provides no I/O access by default, it's useful for running untrusted
code and auditing third-party code. If you're building or extending a platform
that runs user generated code, you can use Deno for running third-party code
securely and host this code through
[Deno Subhosting](https://deno.com/subhosting) or any other cloud platform of
your choice.

For the following example `mod.ts` has been granted read-only access to the file
system. It cannot write to the file system, or perform any other security
Expand Down Expand Up @@ -100,7 +112,7 @@ This example restricts file system access by allowing read-only access to the
attempting to read a file in the `/etc` directory:

```shell
$ deno run --allow-read=/usr https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd
$ deno run --allow-read=/usr https://deno.land/std@0.198.0/examples/cat.ts /etc/passwd
error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag
$deno$/dispatch_json.ts:40:11
at DenoError ($deno$/errors.ts:20:5)
Expand All @@ -111,15 +123,15 @@ Try it out again with the correct permissions by allowing access to `/etc`
instead:

```shell
deno run --allow-read=/etc https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd
deno run --allow-read=/etc https://deno.land/std@0.198.0/examples/cat.ts /etc/passwd
```

You can further restrict some sub-paths to not be accessible, using
`--deny-read` flag:

```shell
deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd
deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/hosts
deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@0.198.0/examples/cat.ts /etc/passwd
deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@0.198.0/examples/cat.ts /etc/hosts
error: Uncaught PermissionDenied: read access to "/etc/hosts"...
```

Expand Down
15 changes: 7 additions & 8 deletions runtime/manual/getting_started/configuration_file.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
sidebar_position: 5
---

# Configuration File

Deno supports a configuration file that allows you to customize the built-in
Expand All @@ -13,11 +9,14 @@ Deno will automatically detect a `deno.json` or `deno.jsonc` configuration file
if it's in your current working directory or parent directories. The `--config`
flag can be used to specify a different configuration file.

> ⚠️ Before Deno v1.23 you needed to supply an explicit `--config` flag.
:::info Version notes

- Before Deno v1.23, you needed to supply an explicit `--config` flag.
- Starting with Deno v1.34, globs are supported in `include` and `exclude`
fields. You can use `*` to match any number of characters, `?` to match a
single character, and `**` to match any number of directories.

> ⚠️ Starting with Deno v1.34 globs are supported in `include` and `exclude`
> fields. You can use `*` to match any number of characters, `?` to match a
> single character, and `**` to match any number of directories.
:::

## `imports` and `scopes`

Expand Down
4 changes: 0 additions & 4 deletions runtime/manual/getting_started/installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
sidebar_position: 1
---

# Installation

Deno works on macOS, Linux, and Windows. Deno is a single binary executable. It
Expand Down
5 changes: 0 additions & 5 deletions runtime/manual/getting_started/setup_your_environment.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
sidebar_position: 2
---

# Set Up Your Environment

The Deno CLI contains a lot of the tools that are commonly needed for developing
Expand Down Expand Up @@ -80,7 +76,6 @@ of such a configuration:

```lua
local nvim_lsp = require('lspconfig')

nvim_lsp.denols.setup {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"),
Expand Down

0 comments on commit 0fc462c

Please sign in to comment.