Skip to content

Commit

Permalink
fix(github): sanitize the GitHub token in debug logs
Browse files Browse the repository at this point in the history
fixes #515
  • Loading branch information
orhun committed Feb 28, 2024
1 parent 4508d4d commit be34949
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion git-cliff/src/args.rs
Expand Up @@ -18,6 +18,7 @@ use git_cliff_core::{
DEFAULT_OUTPUT,
};
use glob::Pattern;
use secrecy::SecretString;
use std::path::PathBuf;

#[derive(Debug, Clone, Copy, ValueEnum)]
Expand Down Expand Up @@ -227,7 +228,7 @@ pub struct Opt {
value_name = "TOKEN",
hide_env_values = true
)]
pub github_token: Option<String>,
pub github_token: Option<SecretString>,
/// Sets the GitHub repository.
#[arg(
long,
Expand Down
7 changes: 3 additions & 4 deletions git-cliff/src/lib.rs
Expand Up @@ -39,7 +39,6 @@ use git_cliff_core::{
DEFAULT_CONFIG,
IGNORE_FILE,
};
use secrecy::Secret;
use std::env;
use std::fs::{
self,
Expand Down Expand Up @@ -126,8 +125,8 @@ fn process_repository<'a>(
}

// Print debug information about configuration and arguments.
log::trace!("{:#?}", args);
log::trace!("{:#?}", config);
log::trace!("Arguments: {:#?}", args);
log::trace!("Config: {:#?}", config);

// Parse commits.
let mut commit_range = args.range.clone();
Expand Down Expand Up @@ -399,7 +398,7 @@ pub fn run(mut args: Opt) -> Result<()> {
}
}
if args.github_token.is_some() {
config.remote.github.token = args.github_token.clone().map(Secret::new);
config.remote.github.token = args.github_token.clone();
}
if let Some(ref remote) = args.github_repo {
config.remote.github.owner = remote.0.owner.to_string();
Expand Down

0 comments on commit be34949

Please sign in to comment.