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

Handle whitespace in AWS config profile names #1219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 7 additions & 1 deletion vault/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ func (c *ConfigFile) ProfileSections() []ProfileSection {
}
for _, section := range c.iniFile.SectionStrings() {
if section == defaultSectionName || strings.HasPrefix(section, "profile ") {
profile, _ := c.ProfileSection(strings.TrimPrefix(section, "profile "))
profileName := strings.TrimPrefix(section, "profile ")
profileName = strings.TrimSpace(profileName)
profile, _ := c.ProfileSection(profileName)

// ignore the default profile if it's empty
if section == defaultSectionName && profile.IsEmpty() {
Expand Down Expand Up @@ -199,6 +201,10 @@ func (c *ConfigFile) ProfileSection(name string) (ProfileSection, bool) {
if c.iniFile == nil {
return profile, false
}

// Trim whitespace from the profile name
name = strings.TrimSpace(name)

// default profile name has a slightly different section format
sectionName := "profile " + name
if name == defaultSectionName {
Expand Down