Skip to content

Commit e206e63

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: [ch7272]
1 parent 1feb1fd commit e206e63

File tree

7 files changed

+9
-15
lines changed

7 files changed

+9
-15
lines changed

apiserver/clusterservice/clusterimpl.go

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

626626
}
627627

628-
log.Debug("userLabelsMap")
629-
log.Debugf("%v", userLabelsMap)
630-
631628
if existsGlobalConfig(ns) {
632629
userLabelsMap[config.LABEL_CUSTOM_CONFIG] = config.GLOBAL_CUSTOM_CONFIGMAP
633630
}

apiserver/dfservice/dfimpl.go

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

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

apiserver/root.go

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

233233
psw := string(secret.Data["password"])
234234
if psw != password {
235-
log.Errorf("%s %s password does not match for user %s ", psw, password, username)
235+
log.Errorf("password does not match for user [%s]", username)
236236
return false
237237
}
238238

operator/backrest/restore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func CreateRestoredDeployment(restclient *rest.RESTClient, cluster *crv1.Pgclust
395395
affinityStr = operator.GetAffinity(cluster.Spec.UserLabels["NodeLabelKey"], cluster.Spec.UserLabels["NodeLabelValue"], "In")
396396
}
397397

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

400400
deploymentFields := operator.DeploymentTemplateFields{
401401
Name: restoreToName,
@@ -483,7 +483,7 @@ func publishRestore(id, clusterName, username, namespace string) {
483483
Timestamp: time.Now(),
484484
EventType: events.EventRestoreCluster,
485485
},
486-
Clustername: clusterName,
486+
Clustername: clusterName,
487487
}
488488

489489
err := events.Publish(f)

operator/cluster/pgbouncer.go

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

277277
log.Debugf("secretUser: %s", secretUser)
278-
log.Debugf("secretPass: %s", secretPass)
279278

280279
if err != nil {
281280
log.Error(err)
@@ -303,7 +302,6 @@ func AddPgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
303302

304303
pgbouncerName := clusterName + PGBOUNCER_SUFFIX
305304
log.Debugf("adding a pgbouncer %s", pgbouncerName)
306-
// log.Debugf("secretUser: %s, secretPass: %s", secretUser, secretPass)
307305

308306
//create the pgbouncer deployment
309307
fields := PgbouncerTemplateFields{
@@ -435,7 +433,7 @@ func updatePgBouncerDBPassword(clusterName string, p connectionInfo, username, n
435433
var err error
436434
var conn *sql.DB
437435

438-
log.Debugf("Updating credentials for %s in %s with %s ", username, p.Database, newPassword)
436+
log.Debugf("Updating credentials for %s in %s", username, p.Database)
439437

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

pgo/cmd/auth.go

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

9797
creds := msgs.BasicAuthCredentials{
9898
Username: fields[0],

util/failover.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func GetReplicationInfo(target string) (*ReplicationInfo, error) {
212212
conn, err := sql.Open("postgres", target)
213213

214214
if err != nil {
215-
log.Errorf("Could not connect to: %s", target)
215+
log.Error(err)
216216
return nil, err
217217
}
218218

@@ -224,7 +224,7 @@ func GetReplicationInfo(target string) (*ReplicationInfo, error) {
224224
rows, err := conn.Query("SELECT current_setting('server_version_num')")
225225

226226
if err != nil {
227-
log.Errorf("Could not perform query for version: %s", target)
227+
log.Error(err)
228228
return nil, err
229229
}
230230

@@ -257,7 +257,7 @@ func GetReplicationInfo(target string) (*ReplicationInfo, error) {
257257
rows, err = conn.Query(replicationInfoQuery)
258258

259259
if err != nil {
260-
log.Errorf("Could not perform replication info query: %s", target)
260+
log.Error(err)
261261
return nil, err
262262
}
263263

0 commit comments

Comments
 (0)