Repository navigation
fix(postgres,pgx): error instead of panicking on unquoted MigrationsTable - #1455
xianyu-sheng wants to merge 1 commit into
Conversation
f9b6bf0 to
7da4e3a
Compare
|
For reference, the panic is reachable without the Go API too. The URL guard only fires when if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || ...) {
return nil, fmt.Errorf("x-migrations-table must be quoted ...")
}So this URL reaches the panic (the table then defaults to Same for |
7da4e3a to
07e0e44
Compare
…able When MigrationsTableQuoted is enabled and MigrationsTable contains no double quotes (including when it is left empty and defaults to schema_migrations), the quote matcher returns no matches and result[len(result)-1] panics with an out-of-range index. Return a configuration error instead, matching the existing too many dot characters path. Add regression tests for the postgres, pgx and pgx/v5 drivers.
07e0e44 to
5084604
Compare
|
CI status update: The failures seen in earlier runs of the same job are all in packages unrelated to this change:
Both packages passed in run 1 and Would a maintainer mind re-running the |
|
CI summary across the last few runs on this branch:
So both test jobs have passed at least once on this exact commit, and the failures are always in packages this PR does not touch. Could a maintainer re-run the failed |
fix(postgres,pgx): error instead of panicking on unquoted MigrationsTable
Problem
When
MigrationsTableQuotedis enabled, the PostgreSQL drivers extract thequoted identifiers with:
If
MigrationsTablecontains no double quotes — including when it is leftempty and defaults to
schema_migrations—resultis empty and the indexexpression panics:
This reproduces in all three drivers:
database/postgres,database/pgxanddatabase/pgx/v5.Fix
Return a configuration error when no quoted identifier is found, consistent
with the existing "too many dot characters" error path:
Regression tests
One test per driver (
database/**/*_quoted_test.go) using a ping-only fakedatabase/sqldriver, so no real database is needed:Before:
After:
go build ./...passes.Detection
Found during a SmartBench audit of
the repository. Its evidence-gated LLM review on the vulnerable revision flags
the empty-match indexing in the quoted-table parsing; the regression tests
above confirm the finding independently.