mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-20 14:05:24 +00:00
Escape Identifier when building up SQL dynamically
Signed-off-by: Feike Steenbergen <feike@timescale.com>
This commit is contained in:
parent
1b492a6c59
commit
1e9b19da84
@ -43,9 +43,7 @@ func queryNamespaceMapping(server *Server, namespace string, mapping MetricMapNa
|
||||
var err error
|
||||
|
||||
if !found {
|
||||
// I've no idea how to avoid this properly at the moment, but this is
|
||||
// an admin tool so you're not injecting SQL right?
|
||||
rows, err = server.db.Query(fmt.Sprintf("SELECT * FROM %s;", namespace)) // nolint: gas
|
||||
rows, err = server.db.Query(fmt.Sprintf("SELECT * FROM %s;", pq.QuoteIdentifier(namespace))) // nolint: gas
|
||||
} else {
|
||||
rows, err = server.db.Query(query)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user