Test/postgresql #73
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/postgresql"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR Summary (auto-generated)
@ -126,1 +134,3 @@func cleanupPostgresTestData(db *sql.DB) {// dropTestDatabase connects to the admin database and drops the specified test database.func dropTestDatabase(config PostgresTestConfig, dbName string) {adminDB, err := sql.Open("postgres", config.ConnectionString())SQL Injection Risk: Database identifiers should be properly quoted. Use
pq.QuoteIdentifier(testDBName)instead of direct string interpolation.While
testDBNameis internally generated, this establishes an unsafe pattern that could be copied elsewhere.CRITICAL - SQL Injection Vulnerability: Direct string formatting into SQL with unescaped single quotes. If
dbNameever comes from untrusted input, this is exploitable.Use a parameterized query instead:
SQL Injection Risk: Same issue as line 95. Database identifiers must be properly quoted.
@ -122,1 +124,3 @@_, _ = db.ExecContext(ctx, drops)// uniqueTestDBName generates a unique database name like "paso_test_a1b2c3d4".func uniqueTestDBName() string {b := make([]byte, 4)Guard Pattern Flattening: The manual
adminDB.Close()on line 84 is redundant. Use early defer instead:Code Review Summary
Critical Security Issues
SQL Injection Vulnerabilities - 3 locations in
db_postgres.go:CREATE DATABASEwith unescaped identifierpg_terminate_backendquery - CRITICALDROP DATABASEwith unescaped identifierAll PostgreSQL identifiers must use
pq.QuoteIdentifier()and query parameters must use$1placeholders instead of string formatting.Code Quality Issues
DRY Violations:
testEnvstruct andsetupTestEnvfunction duplicated across column, label, project, and task service test filesRunDatabaseTestswrapper pattern repeated 80+ timesinternal/testing/fixturesusing Go genericsGuard Pattern Flattening (db_postgres.go:74-89):
adminDB.Close()on line 84 should use early defer insteadError Handling:
Close()errors ignored without logging throughout cleanup pathsMinor Issues:
uniqueTestDBName()could collide in parallel tests - add PID or additional entropyPriority
See inline comments for specific code suggestions.