Skip to content

Commit ea61ed1

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Limit logging of passwords in logs
Typically, one does not want to log PostgreSQL or PGO credentials in logs, not even debug logs. There are other ways to retrieve credentials if one is a Kubernetes adminsitrator or has access to the appropriate PostgreSQL Operator commands. Issue: [ch7000]
1 parent 3e74d8b commit ea61ed1

File tree

6 files changed

+6
-12
lines changed

6 files changed

+6
-12
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,6 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns, pgouser string) msgs.
656656

657657
}
658658

659-
log.Debug("userLabelsMap")
660-
log.Debugf("%v", userLabelsMap)
661-
662659
if existsGlobalConfig(ns) {
663660
userLabelsMap[config.LABEL_CUSTOM_CONFIG] = config.GLOBAL_CUSTOM_CONFIGMAP
664661
}

apiserver/dfservice/dfimpl.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func getPGSize(port, host, databaseName, clusterName, ns string) (string, int, e
176176
log.Error(err.Error())
177177
return dbsizePretty, dbsize, err
178178
}
179-
//log.Debug("username=" + username + " password=" + password)
180179

181180
conn, err = sql.Open("postgres", "sslmode=disable user="+username+" host="+host+" port="+port+" dbname="+databaseName+" password="+password)
182181
if err != nil {

apiserver/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func BasicAuthCheck(username, password string) bool {
218218

219219
psw := string(secret.Data["password"])
220220
if psw != password {
221-
log.Errorf("%s %s password does not match for user %s ", psw, password, username)
221+
log.Errorf("password does not match for user [%s]", username)
222222
return false
223223
}
224224

operator/backrest/restore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ package backrest
1616
*/
1717

1818
import (
19-
"strings"
2019
"bytes"
2120
"encoding/json"
2221
"errors"
2322
"os"
23+
"strings"
2424
"time"
2525

2626
crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1"
@@ -326,7 +326,7 @@ func CreateRestoredDeployment(restclient *rest.RESTClient, cluster *crv1.Pgclust
326326
affinityStr = operator.GetAffinity(cluster.Spec.UserLabels["NodeLabelKey"], cluster.Spec.UserLabels["NodeLabelValue"], "In")
327327
}
328328

329-
log.Debugf("creating restored PG deployment with bouncer pass of [%s]", cluster.Spec.UserLabels[config.LABEL_PGBOUNCER_PASS])
329+
log.Debugf("creating restored postgresql deployment for cluster [%s]", restoreToName)
330330

331331
deploymentFields := operator.DeploymentTemplateFields{
332332
Name: restoreToName,

operator/cluster/pgbouncer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ func AddPgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
278278
err, secretUser, secretPass := createPgbouncerSecret(clientset, cl, primaryName, replicaName, primaryName, secretName, namespace)
279279

280280
log.Debugf("secretUser: %s", secretUser)
281-
log.Debugf("secretPass: %s", secretPass)
282281

283282
if err != nil {
284283
log.Error(err)
@@ -306,7 +305,6 @@ func AddPgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
306305

307306
pgbouncerName := clusterName + PGBOUNCER_SUFFIX
308307
log.Debugf("adding a pgbouncer %s", pgbouncerName)
309-
// log.Debugf("secretUser: %s, secretPass: %s", secretUser, secretPass)
310308

311309
//create the pgbouncer deployment
312310
fields := PgbouncerTemplateFields{
@@ -445,7 +443,7 @@ func updatePgBouncerDBPassword(clusterName string, p connectionInfo, username, n
445443
var err error
446444
var conn *sql.DB
447445

448-
log.Debugf("Updating credentials for %s in %s with %s ", username, p.Database, newPassword)
446+
log.Debugf("Updating credentials for %s in %s", username, p.Database)
449447

450448
conn, err = sql.Open("postgres", "sslmode=disable user="+p.Username+" host="+p.Hostip+" port="+p.Port+" dbname="+p.Database+" password="+p.Password)
451449
if err != nil {

pgo/cmd/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func parseCredentials(dat string) msgs.BasicAuthCredentials {
8989
fmt.Println("unable to parse credentials in pgouser file")
9090
os.Exit(2) // TODO: graceful exit
9191
}
92-
log.Debugf("%v", fields)
93-
log.Debugf("username=[%s] password=[%s]", fields[0], fields[1])
92+
93+
log.Debugf("username=[%s]", fields[0])
9494

9595
creds := msgs.BasicAuthCredentials{
9696
Username: fields[0],

0 commit comments

Comments
 (0)