Skip to content

FileProfileImporter breaks if profile names contain whitespace #43

@aph3rson

Description

@aph3rson

private static final Pattern awsProfileStartPattern = Pattern.compile("\\s*\\[(?:profile\\s)?(\\S+)\\]\\s*", Pattern.CASE_INSENSITIVE);

The above line is used during the import process for profile files (either exported by AWS Signer, or from the ~/.aws/config file locally). The former supports profile names with spaces in them. However, importing these files breaks, with AWS Signer detecting no profiles in the file:

[DEBUG] Import Profile Button Clicked.
[DEBUG] Selected path from file dialog: /fake_path/aws_signer.ini
[INFO] Imported 0 profile(s) from file: /fake_path/aws_signer.ini

Here's an example export file from AWS Signer that causes this:

[profile Foo: Bar]
signer_enabled=true
signer_in_scope_only=true
credential_process=/fake_path/bin/gimme --account foo --role bar
duration_seconds=60

[profile Foo external]
signer_enabled=true
signer_in_scope_only=true
role_arn=arn:aws:iam::123456789012:role/external
source_profile=Foo: Bar
role_session_name=aph3rson_external

[profile Foo: Baz]
signer_enabled=true
signer_in_scope_only=true
credential_process=/fake_path/bin/gimme --account foo --role baz
duration_seconds=60

[profile Creds: OhYes]
signer_enabled=true
signer_in_scope_only=true
credential_process=/fake_path/bin/gimme --account creds --role ohyes
duration_seconds=60

It may be more appropriate to use an INI library for this - the ~/.aws/config file is INI-formatted, as mentioned here if that's what AWS Signer is shooting for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions