Skip to content

Commit

Permalink
Merge pull request getsops#1037 from mozilla/ajvb/limit-role-length
Browse files Browse the repository at this point in the history
Limit role session name length to 64 characters.
  • Loading branch information
ajvb authored Apr 4, 2022
2 parents 268b5ff + 1bb30e2 commit 0f8c335
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kms/keysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ func (key MasterKey) createStsSession(config aws.Config, sess *session.Session)
sanitizedHostname := stsRoleSessionNameRe.ReplaceAllString(hostname, "")
stsService := sts.New(sess)
name := "sops@" + sanitizedHostname

// Make sure the name is no longer than 64 characters (role session name length limit from AWS)
roleSessionNameLengthLimit := 64
if len(name) >= roleSessionNameLengthLimit {
name = name[:roleSessionNameLengthLimit]
}

out, err := stsService.AssumeRole(&sts.AssumeRoleInput{
RoleArn: &key.Role, RoleSessionName: &name})
if err != nil {
Expand Down

0 comments on commit 0f8c335

Please sign in to comment.