diff --git a/Makefile b/Makefile index b4ae15f4..aeec1993 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,14 @@ release: gh-release clean dist govendor sync github-release release \ --security-token $$GH_LOGIN \ - --user segmentio \ + --user ixydo \ --repo chamber \ --tag $(VERSION) \ --name $(VERSION) github-release upload \ --security-token $$GH_LOGIN \ - --user segmentio \ + --user ixydo \ --repo chamber \ --tag $(VERSION) \ --name chamber-$(VERSION)-darwin-amd64 \ @@ -20,7 +20,7 @@ release: gh-release clean dist github-release upload \ --security-token $$GH_LOGIN \ - --user segmentio \ + --user ixydo \ --repo chamber \ --tag $(VERSION) \ --name chamber-$(VERSION)-linux-amd64 \ diff --git a/cmd/list.go b/cmd/list.go index 83adedc8..61ce877c 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -66,13 +66,12 @@ func list(cmd *cobra.Command, args []string) error { func key(s string) string { _, noPaths := os.LookupEnv("CHAMBER_NO_PATHS") - if !noPaths { - tokens := strings.Split(s, "/") - secretKey := tokens[2] - return secretKey + sep := "/" + if noPaths { + sep = "." } - tokens := strings.Split(s, ".") - secretKey := tokens[1] + tokens := strings.Split(s, sep) + secretKey := tokens[len(tokens)-1] return secretKey } diff --git a/cmd/root.go b/cmd/root.go index ef689c80..440108c7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( // Regex's used to validate service and key names var ( validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+$`) - validServiceFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+$`) + validServiceFormat = regexp.MustCompile(`^[A-Za-z0-9-_\/.]+$`) numRetries int chamberVersion string @@ -51,7 +51,7 @@ func Execute(vers string) { func validateService(service string) error { if !validServiceFormat.MatchString(service) { - return fmt.Errorf("Failed to validate service name '%s'. Only alphanumeric, dashes, and underscores are allowed for service names", service) + return fmt.Errorf("Failed to validate service name '%s'. Only alphanumeric, dashes, forwardslases, fullstops and underscores are allowed for service names", service) } return nil } diff --git a/store/ssmstore.go b/store/ssmstore.go index 18cf11bf..a60ec8b2 100644 --- a/store/ssmstore.go +++ b/store/ssmstore.go @@ -22,11 +22,11 @@ const ( // validPathKeyFormat is the format that is expected for key names inside parameter store // when using paths -var validPathKeyFormat = regexp.MustCompile(`^\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+$`) +var validPathKeyFormat = regexp.MustCompile(`^\/[A-Za-z0-9-_/]+$`) // validKeyFormat is the format that is expected for key names inside parameter store when // not using paths -var validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$`) +var validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_.]+$`) // ensure SSMStore confirms to Store interface var _ Store = &SSMStore{} @@ -501,7 +501,8 @@ func basePath(key string) string { if len(pathParts) == 1 { return pathParts[0] } - return "/" + pathParts[1] + end := len(pathParts) - 1 + return strings.Join(pathParts[0:end], "/") } func parameterMetaToSecretMeta(p *ssm.ParameterMetadata) SecretMetadata {