Skip to content

Commit 8e8f8e2

Browse files
committed
Hide archive password in snapshot download output.
1 parent c41b354 commit 8e8f8e2

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

cmd/crates/soroban-test/tests/it/integration/snapshot.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,24 @@ fn snapshot_merge() {
211211
assert!(merged.ledger_entries.len() > snapshot_b.ledger_entries.len());
212212
}
213213

214+
#[test]
215+
fn snapshot_create_redacts_archive_url_password() {
216+
let sandbox = &TestEnv::new();
217+
sandbox
218+
.new_assert_cmd("snapshot")
219+
.arg("create")
220+
.arg("--archive-url=https://archiveuser:supersecret@archive.invalid/")
221+
.arg("--ledger=1")
222+
.arg("--out=snapshot.json")
223+
.assert()
224+
.failure()
225+
.stderr(
226+
predicate::str::contains("supersecret")
227+
.not()
228+
.and(predicate::str::contains("redacted")),
229+
);
230+
}
231+
214232
#[test]
215233
fn snapshot_merge_conflict_resolution() {
216234
let sandbox = &TestEnv::new();

cmd/soroban-cli/src/commands/snapshot/create.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ use crate::{
3131
tx::builder,
3232
utils::get_name_from_stellar_asset_contract_storage,
3333
};
34-
use crate::{config::address::UnresolvedMuxedAccount, utils::http};
34+
use crate::{
35+
config::address::UnresolvedMuxedAccount,
36+
utils::{http, url::redact_url},
37+
};
3538

3639
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum, Default)]
3740
pub enum Output {
@@ -559,7 +562,10 @@ async fn get_history(
559562
};
560563
let history_url = Url::from_str(&history_url).unwrap();
561564

562-
print.globeln(format!("Downloading history {history_url}"));
565+
print.globeln(format!(
566+
"Downloading history {}",
567+
redact_url(history_url.as_str())
568+
));
563569

564570
let response = http::client()
565571
.get(history_url.as_str())
@@ -589,7 +595,10 @@ async fn get_history(
589595
.map_err(Error::ReadHistoryHttpStream)?;
590596

591597
print.clear_previous_line();
592-
print.globeln(format!("Downloaded history {}", &history_url));
598+
print.globeln(format!(
599+
"Downloaded history {}",
600+
redact_url(history_url.as_str())
601+
));
593602

594603
serde_json::from_slice::<History>(&body).map_err(Error::JsonDecodingHistory)
595604
}
@@ -608,7 +617,10 @@ async fn get_ledger_metadata_from_archive(
608617
"{archive_url}/ledger/{ledger_hex_0}/{ledger_hex_1}/{ledger_hex_2}/ledger-{ledger_hex}.xdr.gz"
609618
);
610619

611-
print.globeln(format!("Downloading ledger headers {ledger_url}"));
620+
print.globeln(format!(
621+
"Downloading ledger headers {}",
622+
redact_url(&ledger_url)
623+
));
612624

613625
let ledger_url = Url::from_str(&ledger_url).map_err(Error::ParsingBucketUrl)?;
614626
let response = http::client()

0 commit comments

Comments
 (0)