Repository navigation
Description
The problem
A SQLite URL that carries a user, password, host or port is accepted without an error, and the extra parts are either dropped or read as part of the file name. SQLite has no network endpoint and no credentials, so these URLs are always a mistake: a copied PostgreSQL URL with the scheme changed, or a typo.
On master, sqlite://user:pw@host:5432/data.db goes through ConnectionInfo::parse (crates/dataprof-db/src/connection.rs), which keeps only database = "data.db", and SqliteConnector::connect rebuilds sqlite://data.db. The profiler opens data.db relative to the working directory, or profiles whatever file sits there, and the user, host and port vanish without a word.
Once #990 lands, connect passes a sqlite: URL to sqlx unchanged. sqlx strips the scheme and uses the rest as the file name, so the same URL asks SQLite for a file literally named user:pw@host:5432/data.db. That fails to open, but the error is about a missing file, not about the URL form.
What you'd like
SqliteConnector::newrejects a SQLite URL with a user, password or port withDatabaseConfigError, naming what it found (not the password) and the supported forms:sqlite:///absolute/path.db,sqlite://relative/path.db,sqlite::memory:, or a bare file path.- A unit test per rejected part, and one showing the supported forms still construct a connector.
A host on its own is not an error: in sqlite://relative/path.db the first segment parses as a host.
Where to start
SqliteConnector::new in crates/dataprof-db/src/connectors/sqlite.rs already has the parsed ConnectionInfo. The closed #897 had a version of this check:
if connection_info.scheme == "sqlite"
&& (connection_info.username.is_some()
|| connection_info.password.is_some()
|| connection_info.port.is_some())
{
return Err(DataProfilerError::DatabaseConfigError {
message: "SQLite URLs do not support credentials or ports".to_string(),
});
}Review on #897 asked for the message to name the rejected form and a supported example. Test with cargo test -p dataprof-db --features sqlite.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
fix(sqlite): reject SQLite URLs that contain a user, password, or port
fix(sqlite): reject SQLite URLs that contain a user, password, or port
fix(db): reject SQLite URLs specifying credentials or port numbers