Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Fix panic that occurred when sentry-cli login called with --auth-token #1893

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(api): Validate Auth Tokens client-side (#1885)
Perform client-side validation of all Auth Tokens input to the Sentry CLI. To ensure future-compatibility, we only provide soft validation, meaning that we only print a warning message if we detect that the Auth Token is invalid – the CLI will still proceed with normal execution if the Auth Token is invalid.

Fixes GH-1859
  • Loading branch information
szokeasaurusrex committed Jan 5, 2024
commit d52f56a9d8e4dcfe6d0ed342325f7488b4020ba1
168 changes: 162 additions & 6 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ prettytable-rs = "0.10.0"
proguard = { version = "5.0.0", features = ["uuid"] }
r2d2 = "0.8.10"
rayon = "1.6.1"
regex = "1.7.1"
regex = "1.7.3"
runas = "1.0.0"
rust-ini = "0.18.0"
semver = "1.0.16"
Expand Down Expand Up @@ -83,7 +83,9 @@ chrono-tz = "0.8.4"
insta = { version = "1.26.0", features = ["redactions", "yaml"] }
mockito = "0.31.1"
predicates = "2.1.5"
rstest = "0.18.2"
tempfile = "3.8.1"
testing_logger = "0.1.1"
trycmd = "0.14.11"

[features]
Expand Down
4 changes: 2 additions & 2 deletions src/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn make_command(command: Command) -> Command {

fn update_config(config: &Config, token: &str) -> Result<()> {
let mut new_cfg = config.clone();
new_cfg.set_auth(Auth::Token(token.to_string()))?;
new_cfg.set_auth(Auth::Token(token.into()))?;
new_cfg.save()?;
Ok(())
}
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
};

let test_cfg = config.make_copy(|cfg| {
cfg.set_auth(Auth::Token(token.to_string()))?;
cfg.set_auth(Auth::Token(token.clone().into()))?;
Ok(())
})?;

Expand Down
4 changes: 3 additions & 1 deletion src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use log::{debug, info, set_logger, set_max_level, LevelFilter};
use crate::api::Api;
use crate::config::{Auth, Config};
use crate::constants::{ARCH, PLATFORM, VERSION};
use crate::utils::auth_token::AuthToken;
use crate::utils::logging::set_quiet_mode;
use crate::utils::logging::Logger;
use crate::utils::system::{init_backtrace, load_dotenv, print_error, QuietExit};
Expand Down Expand Up @@ -107,7 +108,7 @@ fn configure_args(config: &mut Config, matches: &ArgMatches) -> Result<()> {
config.set_auth(Auth::Key(api_key.to_owned()))?;
}

if let Some(auth_token) = matches.get_one::<String>("auth_token") {
if let Some(auth_token) = matches.get_one::<AuthToken>("auth_token") {
config.set_auth(Auth::Token(auth_token.to_owned()))?;
}

Expand Down Expand Up @@ -161,6 +162,7 @@ fn app() -> Command {
.value_name("AUTH_TOKEN")
.long("auth-token")
.global(true)
.value_parser(value_parser!(AuthToken))
.help("Use the given Sentry auth token."),
)
.arg(
Expand Down
Loading