Files
uptop/internal/store/dialect.go
T
lerko d30d1460bd
CI / test (pull_request) Successful in 4m31s
CI / lint (pull_request) Successful in 56s
fix(security): phase 2 high-severity hardening
- Push heartbeat accepts Authorization: Bearer header (query string deprecated)
- Gotify alerts use X-Gotify-Key header instead of token in URL
- Per-IP rate limiting on all API endpoints (token-bucket)
- /metrics gated behind cluster secret (UPTOP_METRICS_PUBLIC=true to opt out)
- Config export redacts passwords/tokens by default (redact_secrets=false to override)
- Fix rewritePlaceholders for 100+ SQL parameters
- Fix AddSiteReturningID/AddAlertReturningID race with LastInsertId/RETURNING
- HTTP server timeouts: read 30s, write 60s, idle 120s
2026-05-25 21:15:33 -04:00

36 lines
668 B
Go

package store
import (
"database/sql"
"strconv"
)
type Dialect interface {
DriverName() string
CreateTablesSQL() []string
MigrationsSQL() []string
BoolFalse() string
ResetSequenceOnEmpty(db *sql.DB, table string)
ImportWipe(tx *sql.Tx)
ImportResetSequences(tx *sql.Tx)
UpsertNodeSQL() string
}
func rewritePlaceholders(query string, dollarStyle bool) string {
if !dollarStyle {
return query
}
buf := make([]byte, 0, len(query)+32)
n := 0
for i := 0; i < len(query); i++ {
if query[i] == '?' {
n++
buf = append(buf, '$')
buf = append(buf, []byte(strconv.Itoa(n))...)
} else {
buf = append(buf, query[i])
}
}
return string(buf)
}