Skip to content

Commit

Permalink
feat(doctor): display redacted github token
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 17, 2025
1 parent ec0dd1d commit 3db86d5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/cli/doctor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ impl Doctor {
.map(|(k, p)| (k, p.to_string_lossy().to_string()))
.collect(),
);
data.insert("env_vars".into(), mise_env_vars().into_iter().collect());
data.insert(
"env_vars".into(),
mise_env_vars(false).into_iter().collect(),
);
data.insert(
"settings".into(),
serde_json::from_str(&cmd!("mise", "settings", "-J").read()?)?,
Expand Down Expand Up @@ -194,7 +197,7 @@ impl Doctor {

self.analyze_plugins();

let env_vars = mise_env_vars()
let env_vars = mise_env_vars(true)
.into_iter()
.map(|(k, v)| format!("{k}={v}"))
.join("\n");
Expand Down Expand Up @@ -413,10 +416,18 @@ fn mise_dirs() -> Vec<(String, &'static Path)> {
.collect()
}

fn mise_env_vars() -> Vec<(String, String)> {
fn mise_env_vars(redact: bool) -> Vec<(String, String)> {
const REDACT_KEYS: &[&str] = &["MISE_GITHUB_TOKEN"];
env::vars()
.filter(|(k, _)| k.starts_with("MISE_"))
.filter(|(k, _)| k != "MISE_GITHUB_TOKEN")
.map(|(k, v)| {
let v = if redact && REDACT_KEYS.contains(&k.as_str()) {
style::ndim("REDACTED").to_string()
} else {
v
};
(k, v)
})
.collect()
}

Expand Down

0 comments on commit 3db86d5

Please sign in to comment.