diff --git a/lib/storage/tool_storage.rs b/lib/storage/tool_storage.rs index e430ea6..3fa5e1d 100644 --- a/lib/storage/tool_storage.rs +++ b/lib/storage/tool_storage.rs @@ -191,8 +191,8 @@ impl ToolStorage { // so look for and try to remove existing links that do not have the extension if should_check_exe_extensions() { for link_path in &mut link_paths { - if !has_exe_extension(&link_path) { - remove_file(&link_path).await?; + if !has_exe_extension(link_path.as_path()) { + remove_file(link_path.as_path()).await?; *link_path = append_exe_extension(&link_path); } } diff --git a/src/cli/authenticate.rs b/src/cli/authenticate.rs index f3813f6..9732aff 100644 --- a/src/cli/authenticate.rs +++ b/src/cli/authenticate.rs @@ -118,11 +118,14 @@ async fn verify_token_format( // Verify the basic format of the token. match provider { ArtifactProvider::GitHub => { - // https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/ - if !token.starts_with("ghp_") && !token.starts_with("gho_") { + if token.len() < 4 + || &token[0..2] != "gh" + || !token.chars().nth(2).unwrap().is_ascii_lowercase() + || token.chars().nth(3).unwrap() != '_' + { bail!( "Invalid GitHub token format.\ - \nGitHub tokens must start with 'ghp_' or 'gho_'." + \nGitHub tokens must start with 'gh' followed by a lowercase letter and an underscore." ) } }