Skip to content

Commit a30a89c

Browse files
docs: add DuckDB restricted execution policies and new connection settings (#306)
Document filesystemPolicy/networkPolicy sandbox options for DuckDB, BigQuery serviceAccountKey inline option, and new Snowflake schema sampling settings (schemaSampleRowLimit, schemaSampleFullScanMaxBytes, privateKey). Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c276faa commit a30a89c

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

src/documentation/setup/config.malloynb

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,53 @@ malloy-config-local.json
6969
| `additionalExtensions` | string | Comma-separated DuckDB extensions to load (e.g. `"spatial,fts"`). Built-in: json, httpfs, icu |
7070
| `readOnly` | boolean | Open database read-only |
7171
| `setupSQL` | text | Connection setup SQL ([see below](#setup-sql)) |
72+
| `filesystemPolicy` | string | `"open"` (default) or `"sandboxed"`. See [restricted execution](#restricted-execution) |
73+
| `networkPolicy` | string | `"open"` (default) or `"closed"`. See [restricted execution](#restricted-execution) |
74+
| `allowedDirectories` | json | Array of directories DuckDB may read/write |
75+
| `enableExternalAccess` | boolean | DuckDB's `enable_external_access` setting |
76+
| `lockConfiguration` | boolean | Lock DuckDB config after setup |
77+
| `autoloadKnownExtensions` | boolean | DuckDB `autoload_known_extensions` |
78+
| `autoinstallKnownExtensions` | boolean | DuckDB `autoinstall_known_extensions` |
79+
| `allowCommunityExtensions` | boolean | DuckDB `allow_community_extensions` |
80+
| `allowUnsignedExtensions` | boolean | DuckDB `allow_unsigned_extensions` |
81+
| `tempFileEncryption` | boolean | DuckDB `temp_file_encryption` |
82+
| `threads` | number | DuckDB `threads` |
83+
| `memoryLimit` | string | DuckDB `memory_limit` (e.g. `"1GB"`) |
84+
| `tempDirectory` | string | DuckDB `temp_directory` |
85+
| `extensionDirectory` | string | DuckDB `extension_directory` |
86+
87+
#### Restricted execution
88+
89+
For untrusted code, Malloy offers two policy knobs:
90+
91+
- `filesystemPolicy: "sandboxed"` — confines DuckDB to `allowedDirectories` (defaults to `workingDirectory`), keeps `tempDirectory` inside it, locks configuration, encrypts temp files, isolates secrets. POSIX only.
92+
- `networkPolicy: "closed"` — forces `enableExternalAccess=false`, blocks `httpfs` and `INSTALL`, rejects remote `databasePath` and `motherDuckToken`.
93+
94+
The reviewed strict recipe uses both; each axis can also stand alone when an external boundary covers the other.
95+
96+
```json
97+
{
98+
"connections": {
99+
"duckdb": {
100+
"is": "duckdb",
101+
"databasePath": "data/app.duckdb",
102+
"workingDirectory": {"config": "rootDirectory"},
103+
"filesystemPolicy": "sandboxed",
104+
"networkPolicy": "closed"
105+
}
106+
}
107+
}
108+
```
109+
110+
Policies set a floor, not a ceiling. `allowedDirectories` and `tempDirectory` can be set explicitly to customize the sandbox. Other policy-controlled settings accept matching values but reject weaker ones — connection creation fails closed. `setupSQL`, `additionalExtensions`, `motherDuckToken`, and remote `databasePath` are incompatible with a restricted policy; to use any of them, drop the policy and configure DuckDB directly. Policies do not set resource limits — configure `threads`, `memoryLimit`, timeouts, and host quotas separately.
72111

73112
### `bigquery` — Google BigQuery
74113

75114
| Parameter | Type | Description |
76115
|---|---|---|
77116
| `projectId` | string | GCP project ID |
78117
| `serviceAccountKeyPath` | file | Path to service account JSON key |
118+
| `serviceAccountKey` | json | Service account key as a JSON object (alternative to file path) |
79119
| `location` | string | Dataset location |
80120
| `maximumBytesBilled` | string | Byte billing cap |
81121
| `timeoutMs` | string | Query timeout in ms |
@@ -132,9 +172,12 @@ Authentication: provide either `token` or the `oauthClientId` + `oauthClientSecr
132172
| `database` | string | Database. Default: `{env: "SNOWFLAKE_DATABASE"}` |
133173
| `schema` | string | Schema. Default: `{env: "SNOWFLAKE_SCHEMA"}` |
134174
| `privateKeyPath` | file | Path to private key (.pem/.key) |
175+
| `privateKey` | password | Private key PEM string (alternative to file path) |
135176
| `privateKeyPass` | password | Private key passphrase |
136177
| `timeoutMs` | number | Query timeout in ms |
137-
| `schemaSampleTimeoutMs` | number | Timeout for the query that samples variant columns to detect their schema (default 15000) |
178+
| `schemaSampleTimeoutMs` | number | Variant schema sample timeout in ms (default 15000) |
179+
| `schemaSampleRowLimit` | number | Row limit for variant schema sample (default 1000) |
180+
| `schemaSampleFullScanMaxBytes` | number | Tables at or below this byte size are full-scanned instead of sampled |
138181
| `setupSQL` | text | Connection setup SQL ([see below](#setup-sql)) |
139182

140183
Snowflake also supports TOML configuration at `~/.snowflake/connections.toml`. See [Snowflake connection configuration](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file) for details.

0 commit comments

Comments
 (0)