Skip to content

Commit

Permalink
fix: don't log tor control port password (#3110)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
Implement custom Debug impl that redacts the password

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Logging passwords = bad

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
Base node doesnt log password

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
* [x] I'm merging against the `development` branch.
* [x] I have squashed my commits into a single commit.
  • Loading branch information
aviator-app[bot] committed Jul 20, 2021
2 parents c4d4cae + 03e679e commit 12320ec
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion common/src/configuration/global.rs
Expand Up @@ -27,6 +27,8 @@ use config::{Config, ConfigError, Environment};
use multiaddr::Multiaddr;
use std::{
convert::TryInto,
fmt,
fmt::Formatter,
net::SocketAddr,
num::{NonZeroU16, TryFromIntError},
path::PathBuf,
Expand Down Expand Up @@ -824,7 +826,7 @@ pub enum DatabaseType {
}

//--------------------------------------------- Network Transport ------------------------------------------//
#[derive(Debug, Clone)]
#[derive(Clone)]
pub enum TorControlAuthentication {
None,
Password(String),
Expand Down Expand Up @@ -861,6 +863,16 @@ impl FromStr for TorControlAuthentication {
}
}

impl fmt::Debug for TorControlAuthentication {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
use TorControlAuthentication::*;
match self {
None => write!(f, "None"),
Password(_) => write!(f, "Password(...)"),
}
}
}

#[derive(Debug, Clone)]
pub enum SocksAuthentication {
None,
Expand Down

0 comments on commit 12320ec

Please sign in to comment.