Skip to content

Commit

Permalink
fix(authority-claimer): redact mnemonic from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
torives committed Jan 25, 2024
1 parent ad1178a commit acd98b3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed concurrent block fetch in foldable `InputBox`.
- Removed snapshot-saving feature. Now, the node will always start from the beginning.

### Fixed

- Fixed mnemonic leaking through log entries.

## [1.2.0]

### Added
Expand Down
1 change: 1 addition & 0 deletions offchain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions offchain/authority-claimer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ http-server = { path = "../http-server" }
log = { path = "../log" }
rollups-events = { path = "../rollups-events" }
types = { path = "../types" }
redacted = { path = "../redacted" }

async-trait.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
Expand Down
5 changes: 3 additions & 2 deletions offchain/authority-claimer/src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use eth_tx_manager::{
Priority,
};
use log::{LogConfig, LogEnvCliConfig};
use redacted::Redacted;
use rollups_events::{BrokerCLIConfig, BrokerConfig};
use rusoto_core::Region;
use snafu::ResultExt;
Expand Down Expand Up @@ -118,7 +119,7 @@ impl TryFrom<TxSigningCLIConfig> for TxSigningConfig {
let account_index = cli.tx_signing_mnemonic_account_index;
if let Some(mnemonic) = cli.tx_signing_mnemonic {
Ok(TxSigningConfig::Mnemonic {
mnemonic,
mnemonic: Redacted::new(mnemonic),
account_index,
})
} else if let Some(path) = cli.tx_signing_mnemonic_file {
Expand All @@ -127,7 +128,7 @@ impl TryFrom<TxSigningCLIConfig> for TxSigningConfig {
.trim()
.to_string();
Ok(TxSigningConfig::Mnemonic {
mnemonic,
mnemonic: Redacted::new(mnemonic),
account_index,
})
} else {
Expand Down
3 changes: 2 additions & 1 deletion offchain/authority-claimer/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use cli::AuthorityClaimerCLI;
use eth_tx_manager::{config::TxManagerConfig, Priority};
use http_server::HttpServerConfig;
use log::LogConfig;
use redacted::Redacted;
use rollups_events::BrokerConfig;
use rusoto_core::Region;

Expand All @@ -35,7 +36,7 @@ pub struct AuthorityClaimerConfig {
#[derive(Debug, Clone)]
pub enum TxSigningConfig {
Mnemonic {
mnemonic: String,
mnemonic: Redacted<String>,
account_index: Option<u32>,
},

Expand Down
5 changes: 3 additions & 2 deletions offchain/authority-claimer/src/signer/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ConditionalSigner {
const DEFAULT_ACCOUNT_INDEX: u32 = 0;
let index = account_index.unwrap_or(DEFAULT_ACCOUNT_INDEX);
let wallet = MnemonicBuilder::<English>::default()
.phrase(mnemonic.as_str())
.phrase(mnemonic.inner().as_str())
.index(index)
.context(LocalWalletSnafu)?
.build()
Expand Down Expand Up @@ -153,6 +153,7 @@ mod tests {
Address, Eip1559TransactionRequest,
};
use ethers_signers::Signer;
use redacted::Redacted;

use crate::{config::TxSigningConfig, signer::ConditionalSigner};

Expand Down Expand Up @@ -191,7 +192,7 @@ mod tests {

async fn local_wallet_conditional_signer() -> ConditionalSigner {
let tx_signing_config = TxSigningConfig::Mnemonic {
mnemonic: MNEMONIC.to_string(),
mnemonic: Redacted::new(MNEMONIC.to_string()),
account_index: Some(1),
};
ConditionalSigner::new(CHAIN_ID, &tx_signing_config)
Expand Down

0 comments on commit acd98b3

Please sign in to comment.