-
-
Notifications
You must be signed in to change notification settings - Fork 119
feat(go-server): add function allowlist #1150
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
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
849382d
feat(go-server): add function allowlist
derekperkins c094021
feat(go-server): expose function allowlist flag
derekperkins 8beb677
docs(go-server): document function allowlist
derekperkins aa374e6
test(go-server): cover allowlist transport gates
derekperkins a3bf41a
fix(go-server): tighten function allowlist validation
derekperkins ec98ac3
docs(go-server): clarify function allowlist boundaries
derekperkins bb6b781
fix(go-server): return nonzero on startup failures
derekperkins d5e9f39
fix(go-server): detect normalized qualified calls
derekperkins d468145
refactor(go-server): simplify allowlist validation
derekperkins 2665421
refactor(go-server): mirror blocklist validation
derekperkins 3c82868
refactor(go-server): share function list traversal
derekperkins 7c9b0b4
fix(go-server): count repeated function violations
derekperkins 83d240a
feat(go-server): add reviewed function inventories
derekperkins 8c58cc0
feat(go-server): default configured function allowlists
derekperkins ea4f038
feat(go-server): expose function allowlist defaults
derekperkins bf7521c
docs(go-server): document default function policy
derekperkins 7da5b64
docs(go-server): correct DuckDB prefix source link
derekperkins 16dd041
docs(go-server): document function inventory updates
derekperkins d21e711
fix(go-server): complete reviewed function defaults
derekperkins 4a85baa
refactor(go-server): extract function inventories
derekperkins 91a7675
feat(go-server): add core extension function sets
derekperkins 1ef7c94
docs(go-server): describe curated reader views
derekperkins 651b3b3
refactor(go-server): model core extension function sets
derekperkins 25f5b98
feat(go-server): classify core extension functions
derekperkins 7fd2701
feat(go-server): enable extension compute defaults
derekperkins 7752d6a
docs(go-server): document extension function groups
derekperkins e305128
refactor(go-server): split extension inventories by extension
derekperkins 656eb8e
refactor(go-server): simplify function allowlist CLI
derekperkins f61e183
docs(go-server): scope function inventory guidance
derekperkins ac2b996
docs(go-server): defer network prefix guidance
derekperkins 3db0eae
docs(go-server): simplify function policy guidance
derekperkins a79eedc
docs(go-server): clarify function policy operations
derekperkins eff3e77
fix(go-server): complete UI function inventory
derekperkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package main | ||
|
|
||
| import "strings" | ||
|
|
||
| type optionalCommaListFlag struct { | ||
| values []string | ||
| set bool | ||
| } | ||
|
|
||
| func (f *optionalCommaListFlag) Set(value string) error { | ||
| f.set = true | ||
| if value != "" { | ||
| f.values = append(f.values, strings.Split(value, ",")...) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (f *optionalCommaListFlag) String() string { | ||
| return strings.Join(f.values, ",") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestOptionalCommaListFlag(t *testing.T) { | ||
| var flag optionalCommaListFlag | ||
|
|
||
| assert.False(t, flag.set) | ||
| assert.Empty(t, flag.values) | ||
|
|
||
| require.NoError(t, flag.Set("md5,range")) | ||
| require.NoError(t, flag.Set("+")) | ||
| assert.True(t, flag.set) | ||
| assert.Equal(t, []string{"md5", "range", "+"}, flag.values) | ||
| assert.Equal(t, "md5,range,+", flag.String()) | ||
| } | ||
|
|
||
| func TestOptionalCommaListFlagPreservesExplicitEmpty(t *testing.T) { | ||
| var flag optionalCommaListFlag | ||
|
|
||
| require.NoError(t, flag.Set("")) | ||
| assert.True(t, flag.set) | ||
| assert.Empty(t, flag.values) | ||
| assert.Empty(t, flag.String()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/server/duckdb-server-go/pkg/functionset/AGENTS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Function allowlist inventories | ||
|
derekperkins marked this conversation as resolved.
|
||
|
|
||
| When changing the reviewed inventories in this package: | ||
|
|
||
| - Treat the DuckDB release bundled by the `duckdb-go` version in [go.mod](../../go.mod) as the source of truth. Inspect that tag's function registrations, parser rewrites, and macro bodies; use `duckdb_functions()` as a classification cross-check, not as a generated allowlist. | ||
| - Keep names lowercase, sorted, deduplicated, and grouped by the serialized `function_name`. Audit side effects, volatility, resource I/O, dynamic SQL or dispatch, and type or macro collisions. Leave uncertain names out. | ||
| - Update the catalog exemptions, reviewed macros, and collision allowlists in `functionset_test.go` only when the matching DuckDB source justifies the exception. Verify parser-generated operators and syntax helpers with `json_serialize_sql` and executable SQL because some have no catalog row. | ||
| - Keep `CoreExtensions` aligned with the bundled DuckDB release's core-extension roster, with an explicit inventory entry even when both groups are empty. Review external extensions against the exact revision pinned by DuckDB's descriptor; generated `extension_entries.hpp` data is not exhaustive. | ||
| - For initial inventories and DuckDB upgrades, verify installed extension revisions and diff `duckdb_functions()` before and after loading each available extension in a fresh database, including new overloads of existing names. Treat statically linked baseline entries, dependency-loaded names classified under another extension, and lazy catalog-scoped or proprietary registrations as source-audit exceptions, not catalog-equality failures. | ||
| - Keep each extension's source pin and `Compute`/`Elevated` arrays together in `<extension>.go`, using the DuckDB extension ID for the filename (for example, `unity_catalog.go`). | ||
| - Put reviewed local computation or embedded static data with no resource or state effects in `Compute`; it is enabled by `DefaultFunctions`. Put resource, mutation, dynamic dispatch, catalog/session inspection, current-time, and source-limited runtime-verified names in `Elevated`. Treat catalog volatility as elevated unless exact pinned source proves the function is pure by argument. Classify a shared name by its most capable overload because validation does not bind signatures. | ||
| - Update the pinned counts and classification table in [README.md](../../README.md) with the inventories. Document source-only or runtime-only limitations, especially MotherDuck's non-exhaustive proprietary runtime snapshot, and keep loading, autoloading, replacement scans, `ATTACH`, settings, and other non-function mechanisms outside the function-group claim. | ||
| - As a secondary compatibility check, compare the functions emitted by [Mosaic SQL](../../../../mosaic/sql/src/index.ts). Do not copy `aggregateNames` or exports wholesale: they can be stale or include unsafe macros and non-function syntax. | ||
12 changes: 12 additions & 0 deletions
12
packages/server/duckdb-server-go/pkg/functionset/autocomplete.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package functionset | ||
|
|
||
| // These inventories match DuckDB 1.5.5 at d8cdaa33fda8df955cc76ef58a280f68f4cd43fa. | ||
| var autocompleteComputeFunctions = [...]string{ | ||
| "check_peg_parser", | ||
| } | ||
|
|
||
| var autocompleteElevatedFunctions = [...]string{ | ||
| "disable_peg_parser", | ||
| "enable_peg_parser", | ||
| "sql_auto_complete", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package functionset | ||
|
|
||
| // Source: https://github.com/duckdb/duckdb-avro/tree/f9d590297485f0318f480372c70bdd852826e258 | ||
| var avroComputeFunctions = [...]string{} | ||
|
|
||
| var avroElevatedFunctions = [...]string{ | ||
| "read_avro", | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.