Skip to content

Commit

Permalink
fix: allow slash
Browse files Browse the repository at this point in the history
Fixes #44
  • Loading branch information
aripalo committed Apr 30, 2024
1 parent 37dee67 commit aa420d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/assumecfg/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ User, Role or Role Session Names can be maximum 64 characters.
Names of users, groups, roles, policies, instance profiles, and server certificates must be alphanumeric, including the following common characters: plus (+), equal (=), comma (,), period (.), at (@), underscore (_), and hyphen (-).
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entity-length
*/
var iamResourceNamePatternBase = `[a-zA-Z0-9_+=,.@-]{1,64}`
var iamResourceNamePatternBase = `[a-zA-Z0-9_+=,./@-]{1,64}`
var iamResourceNamePAtternFull = fmt.Sprintf("^%s$", iamResourceNamePatternBase)
var iamResourceNamePattern = regexp.MustCompile(iamResourceNamePAtternFull)

Expand Down
16 changes: 13 additions & 3 deletions internal/assumecfg/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ func TestValidate(t *testing.T) {
MfaSerial: "arn:aws:iam::111111111111:mfa/FrankSinatra",
RoleArn: "invalid",
},
expected: errors.New("Profile \"frank@concerts\" contains invalid vegas_role_arn \"invalid\". Must satisty ^arn:aws:iam:\\d*:\\d{12}:role\\/[a-zA-Z0-9_+=,.@-]{1,64}$"),
expected: errors.New("Profile \"frank@concerts\" contains invalid vegas_role_arn \"invalid\". Must satisty ^arn:aws:iam:\\d*:\\d{12}:role\\/[a-zA-Z0-9_+=,./@-]{1,64}$"),
},
{
name: "vegas_role_arn may contain slash",
input: AssumeCfg{
ProfileName: "frank@concerts",
SourceProfile: "default",
MfaSerial: "arn:aws:iam::111111111111:mfa/FrankSinatra",
RoleArn: "arn:aws:iam::111111111111:role/FrankSinatra/WithASlash",
},
expected: nil,
},
{
name: "role_session_name invalid",
Expand All @@ -68,9 +78,9 @@ func TestValidate(t *testing.T) {
SourceProfile: "default",
MfaSerial: "arn:aws:iam::111111111111:mfa/FrankSinatra",
RoleArn: "arn:aws:iam::222222222222:role/SingerRole",
RoleSessionName: "invalid//",
RoleSessionName: "invalid",
},
expected: errors.New("Profile \"frank@concerts\" contains invalid role_session_name \"invalid//\". Must satisfy ^[a-zA-Z0-9_+=,.@-]{1,64}$"),
expected: errors.New("Profile \"frank@concerts\" contains invalid role_session_name \"invalid\". Must satisfy ^[a-zA-Z0-9_+=,./@-]{1,64}$"),
},
{
name: "external_id invalid",
Expand Down

0 comments on commit aa420d7

Please sign in to comment.