Unverified Commit 9efbb661 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Relax profile name validation (#861)

* Relax profile name validation

* Update changelog

* Add default provider chain test
parent 7fabbb74
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ Several breaking changes around `aws_smithy_types::Instant` were introduced by s

**New this week**
- Conversions from `aws_smithy_types::DateTime` to `OffsetDateTime` from the `time` crate are now available from the `aws-smithy-types-convert` crate. (smithy-rs#849)
- :bug: Relaxed profile name validation to allow `@` and other characters (smithy-rs#861, aws-sdk-rust#270)

v0.0.25-alpha (November 11th, 2021)
===================================
+1 −0
Original line number Diff line number Diff line
@@ -422,6 +422,7 @@ pub mod credentials {
        make_test!(web_identity_token_invalid_jwt);
        make_test!(web_identity_token_source_profile);
        make_test!(web_identity_token_profile);
        make_test!(profile_name);
        make_test!(profile_overrides_web_identity);
        make_test!(imds_token_fail);

+17 −2
Original line number Diff line number Diff line
@@ -127,11 +127,16 @@ fn merge_into_base<'a>(target: &mut Profile, profile: HashMap<&str, Cow<'a, str>

/// Validate that a string is a valid identifier
///
/// Identifiers must match `[A-Za-z0-9\-_]+`
/// Identifiers must match `[A-Za-z0-9_\-/.%@:\+]+`
fn validate_identifier(input: &str) -> Result<&str, ()> {
    input
        .chars()
        .all(|ch| ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' || ch == '\\')
        .all(|ch| {
            ch.is_ascii_alphanumeric()
                || ['_', '-', '/', '.', '%', '@', ':', '+']
                    .iter()
                    .any(|c| *c == ch)
        })
        .then(|| input)
        .ok_or(())
}
@@ -147,6 +152,7 @@ mod tests {
    use crate::profile::ProfileSet;

    use super::{merge_in, ProfileName};
    use crate::profile::parser::normalize::validate_identifier;

    #[test]
    fn profile_name_parsing() {
@@ -194,6 +200,15 @@ mod tests {
        );
    }

    #[test]
    fn test_validate_identifier() {
        assert_eq!(
            Ok("some-thing:long/the_one%only.foo@bar+"),
            validate_identifier("some-thing:long/the_one%only.foo@bar+")
        );
        assert_eq!(Err(()), validate_identifier("foo!bar"));
    }

    #[test]
    #[traced_test]
    fn ignored_key_generates_warning() {
+4 −0
Original line number Diff line number Diff line
{
  "HOME": "/home",
  "AWS_PROFILE": "some-thing:long/the_one%only.foo@bar+"
}
+9 −0
Original line number Diff line number Diff line
[default]
region = us-east-1
aws_access_key_id = incorrect_key
aws_secret_access_key = incorrect_secret

[profile some-thing:long/the_one%only.foo@bar+]
region = us-east-2
aws_access_key_id = correct_key
aws_secret_access_key = correct_secret
Loading