mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Enforce centralized SQLite connection creation (#35828)
## Why Direct SQLx constructors can bypass the shared SQLite configuration in `codex-state`. ## What changed - Deny SQLx pool, connection, and database creation methods through the workspace Clippy configuration for both Cargo and Bazel builds. - Exempt `codex-rs/state/src/sqlite.rs`, the centralized connection shim, from the lint. - Document that the deny list must be audited when upgrading SQLx. GitOrigin-RevId: e20d7e83095727ac446347157782175062a100fc
This commit is contained in:
committed by
copyberry
parent
155c3e299c
commit
50a7328f50
1
.bazelrc
1
.bazelrc
@@ -117,6 +117,7 @@ build:clippy --@rules_rust//rust/settings:clippy.toml=//codex-rs:clippy.toml
|
|||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=-Dwarnings
|
build:clippy --@rules_rust//rust/settings:clippy_flag=-Dwarnings
|
||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::await_holding_invalid_type
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::await_holding_invalid_type
|
||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::await_holding_lock
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::await_holding_lock
|
||||||
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::disallowed_methods
|
||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::expect_used
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::expect_used
|
||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::identity_op
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::identity_op
|
||||||
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::manual_clamp
|
build:clippy --@rules_rust//rust/settings:clippy_flag=--deny=clippy::manual_clamp
|
||||||
|
|||||||
@@ -409,6 +409,7 @@ symphonia = { version = "0.6.0", default-features = false, features = [
|
|||||||
"wav",
|
"wav",
|
||||||
] }
|
] }
|
||||||
socket2 = "0.6.1"
|
socket2 = "0.6.1"
|
||||||
|
# When bumping sqlx, audit the SQLite constructor deny list in clippy.toml.
|
||||||
sqlx = { version = "0.9.0", default-features = false, features = [
|
sqlx = { version = "0.9.0", default-features = false, features = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"json",
|
"json",
|
||||||
@@ -482,6 +483,7 @@ rust = {}
|
|||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
await_holding_invalid_type = "deny"
|
await_holding_invalid_type = "deny"
|
||||||
await_holding_lock = "deny"
|
await_holding_lock = "deny"
|
||||||
|
disallowed_methods = "deny"
|
||||||
expect_used = "deny"
|
expect_used = "deny"
|
||||||
identity_op = "deny"
|
identity_op = "deny"
|
||||||
manual_clamp = "deny"
|
manual_clamp = "deny"
|
||||||
|
|||||||
@@ -11,6 +11,20 @@ disallowed-methods = [
|
|||||||
{ path = "ratatui::style::Stylize::white", reason = "Avoid hardcoding white; prefer default fg or dim/bold. Exception: Disable this rule if rendering over a hardcoded ANSI background." },
|
{ path = "ratatui::style::Stylize::white", reason = "Avoid hardcoding white; prefer default fg or dim/bold. Exception: Disable this rule if rendering over a hardcoded ANSI background." },
|
||||||
{ path = "ratatui::style::Stylize::black", reason = "Avoid hardcoding black; prefer default fg or dim/bold. Exception: Disable this rule if rendering over a hardcoded ANSI background." },
|
{ path = "ratatui::style::Stylize::black", reason = "Avoid hardcoding black; prefer default fg or dim/bold. Exception: Disable this rule if rendering over a hardcoded ANSI background." },
|
||||||
{ path = "ratatui::style::Stylize::yellow", reason = "Avoid yellow; prefer other colors in `tui/styles.md`." },
|
{ path = "ratatui::style::Stylize::yellow", reason = "Avoid yellow; prefer other colors in `tui/styles.md`." },
|
||||||
|
# Audited against workspace sqlx 0.9.0. Revisit this SQLite escape-hatch list when bumping sqlx.
|
||||||
|
{ path = "sqlx::Pool::connect", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Pool::connect_with", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Pool::connect_lazy", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Pool::connect_lazy_with", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Pool::set_connect_options", reason = "Do not replace options on SQLite pools created by codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::pool::PoolOptions::connect", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::pool::PoolOptions::connect_with", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::pool::PoolOptions::connect_lazy", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::pool::PoolOptions::connect_lazy_with", reason = "Create SQLite pools through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Connection::connect", reason = "Create SQLite connections through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::Connection::connect_with", reason = "Create SQLite connections through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::ConnectOptions::connect", reason = "Create SQLite connections through codex-state's sqlite shim." },
|
||||||
|
{ path = "sqlx::migrate::MigrateDatabase::create_database", reason = "Create SQLite databases through codex-state's sqlite shim." },
|
||||||
]
|
]
|
||||||
|
|
||||||
# Increase the size threshold for result_large_err to accommodate
|
# Increase the size threshold for result_large_err to accommodate
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
//! Shared SQLite connection configuration.
|
//! Shared SQLite connection configuration.
|
||||||
|
|
||||||
|
#![expect(
|
||||||
|
clippy::disallowed_methods,
|
||||||
|
reason = "this is the centralized SQLite connection shim"
|
||||||
|
)]
|
||||||
|
|
||||||
use crate::DbTelemetry;
|
use crate::DbTelemetry;
|
||||||
use crate::migrations::repair_legacy_recency_migration_version;
|
use crate::migrations::repair_legacy_recency_migration_version;
|
||||||
use crate::runtime::RuntimeDbInitError;
|
use crate::runtime::RuntimeDbInitError;
|
||||||
|
|||||||
Reference in New Issue
Block a user