Skip to content

[fix] enforce local SQLite host policy (STAR-102) - #21

Merged
vt128 merged 2 commits into
masterfrom
codex/sqlite-host-function-policy
Sep 23, 2026
Merged

vt128 merged 2 commits into
masterfrom
codex/sqlite-host-function-policy

Conversation

@vt128

@vt128 vt128 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

A host can now opt out of process-wide SQLite functions with NewModuleWithHostPolicy(HostPolicy{DisableCustomFunctions: true}). Registration is rejected before the global registry is touched, and every local connection uses an independent driver without registered functions. Built-in SQL functions and the ordinary database API remain available. The default constructors keep custom functions enabled.

The regression audit also reproduced two file-policy bypasses. connect_remote("file:...") now uses the same local connection path, including registration locking, host policy and PRAGMAs. Restricted modules freeze their configured database at construction and do not export set_database, so scripts cannot widen the allowlist through a setter or a later environment change.

Validation:

  • Recorded failing reproductions before enforcing the policy; added complete module/database/transaction/prepared export contracts and tests for registration order, multiple modules, connection-pool replacement, stored SQL, concurrency and real local HTTP requests.
  • Go 1.27.1 and offline Linux amd64 Go 1.20.14: build, race/count=2, vet and formatting passed. Floor statement coverage increased from 74.89% to 77.32%, above the unchanged 69% minimum.
  • Documentation contract passed: 29/29 builtins and 16/16 configuration accessors. go mod tidy left dependencies unchanged.
  • The CLI main module and examples passed baseline/upgrade build and race tests at their Go 1.25.8 floor with networking disabled.
  • Three-run connection benchmark: median 45.6 us before / 41.8 us after, with 108 allocations in both; no material regression observed.

Behavior changes are limited to the explicit host policy and closing the restricted-file bypasses. Real network libSQL endpoints retain their behavior. This does not isolate or budget UDFs that remain enabled: they still use the process-wide registry and a separate Starlark thread, and closing a connection does not unregister them. No dependency, Go floor or interpreter pin is changed.

Part of STAR-102; the remaining enabled-UDF budget/lifecycle work stays open.

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codacy-production

codacy-production Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 0 duplication

Metric Results
Complexity 6
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@vt128
vt128 merged commit 56739df into master Sep 23, 2026
12 checks passed
@vt128
vt128 deleted the codex/sqlite-host-function-policy branch September 23, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant