Skip to content

Add -safe mode to shell which disables external access, and remove SQLite UDFs from the shell #14509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 23, 2024

Conversation

Mytherin
Copy link
Collaborator

This PR adds the -safe parameter to the shell. When the CLI is launched with this parameter, the CLI is prevented from accessing external files other than the database file that it was initially connected to and prevented from interacting with the host file system. This has the following effects:

  • .cd, .excel, .log, .import, .open, .output, .once, .read, .sh and .system are disabled
  • Auto-complete no longer scans the file system for files to suggest as auto-complete targets
  • The shell-only function getenv is disabled
  • enable_external_access is set to false, which in turn disables commands like ATTACH of an on-disk file, COPY ... to read to/write from files

SQLite UDFs

In a continuous effort to clean-up the shell this PR also removes support for several (undocumented) SQLite UDFs that were provided only in the shell:

  • edit, writefile, readfile, lsmode and sha3

@Mytherin Mytherin added the Needs Documentation Use for issues or PRs that require changes in the documentation label Oct 23, 2024
@Mytherin Mytherin merged commit cbea70a into duckdb:feature Oct 23, 2024
41 of 42 checks passed
Mytherin added a commit that referenced this pull request Dec 1, 2024
See #14509, but as a dot command:

```sql
.safe_mode
ATTACH 'external_db.db';
-- Permission Error:
-- Cannot access file "external_db.db" - file system operations are disabled by configuration
```

This is useful because it allows us to do some initial setup (if
desired) before enabling safe mode:

```sql
ATTACH 'permitted_db.db';
.safe_mode
-- we cannot attach new databases, but we can access permitted_db
```
@Mytherin Mytherin deleted the safemode branch December 8, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation Use for issues or PRs that require changes in the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant