-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(auth): propagate error when token directory cannot be created #542
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ---\n"@googleworkspace/cli": patch\n---\n\nfix(auth): propagate error when token directory cannot be created |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,13 @@ impl EncryptedTokenStorage { | |
| let encrypted = crate::credential_store::encrypt(json.as_bytes())?; | ||
|
|
||
| if let Some(parent) = self.file_path.parent() { | ||
| let _ = tokio::fs::create_dir_all(parent).await; | ||
| tokio::fs::create_dir_all(parent).await.map_err(|e| { | ||
| anyhow::anyhow!( | ||
| "Failed to create token directory '{}': {}", | ||
| parent.display(), | ||
| e | ||
| ) | ||
| })?; | ||
|
Comment on lines
+85
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this change correctly propagates errors from The result of std::fs::set_permissions(parent, std::fs::Permissions::from_mode(0o700))
.map_err(|e| anyhow::anyhow!("Failed to set permissions on token directory '{}': {}", parent.display(), e))?; |
||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::fs::PermissionsExt; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path
parent.display()is included in the error message without sanitization. If a path contains terminal escape sequences, this could lead to escape sequence injection when the error is printed to a terminal. It's safer to sanitize external inputs like file paths before including them in messages that will be displayed.References