From 3193cb0731e207b80cf1a1866bdd94ff453aca60 Mon Sep 17 00:00:00 2001 From: Christian Bagley Date: Sat, 19 Aug 2023 05:07:24 +0000 Subject: [PATCH] Handle whitespace in AWS config profile name --- vault/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vault/config.go b/vault/config.go index a4fdc1e7c..8699fdfc6 100644 --- a/vault/config.go +++ b/vault/config.go @@ -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() { @@ -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 {