[proxy] Don't print passwords (#1298)

This commit is contained in:
bojanserafimov
2022-04-06 20:05:24 -04:00
committed by GitHub
parent 6bc78a0e77
commit d5258cdc4d
2 changed files with 12 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ pub enum ConnectionError {
impl UserFacingError for ConnectionError {}
/// Compute node connection params.
#[derive(Serialize, Deserialize, Debug, Default)]
#[derive(Serialize, Deserialize, Default)]
pub struct DatabaseInfo {
pub host: String,
pub port: u16,
@@ -33,6 +33,16 @@ pub struct DatabaseInfo {
pub password: Option<String>,
}
// Manually implement debug to omit personal and sensitive info
impl std::fmt::Debug for DatabaseInfo {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt.debug_struct("DatabaseInfo")
.field("host", &self.host)
.field("port", &self.port)
.finish()
}
}
/// PostgreSQL version as [`String`].
pub type Version = String;

View File

@@ -107,7 +107,7 @@ impl postgres_backend::Handler for MgmtHandler {
}
fn try_process_query(pgb: &mut PostgresBackend, query_string: &str) -> anyhow::Result<()> {
println!("Got mgmt query: '{}'", query_string);
println!("Got mgmt query [redacted]"); // Content contains password, don't print it
let resp: PsqlSessionResponse = serde_json::from_str(query_string)?;