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

Fix: Allow slash character in Role name #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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
Loading