Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
fix(print): Segment fault if cannot assume role (#36)
Browse files Browse the repository at this point in the history
If `print` cannot assume a role, then error instead of attempting to print invalid credentials.

This resolves the issue where if the `AssumeRole` cannot be assumed with the permissions of the AWS SSO Role, then it will attempt to print `nil` credentials, resulting in a segfault (`panic: runtime error: invalid memory address or nil pointer dereference`). This can reproduced by removing all policies from an SSO role, resulting in `AssumeRole` failing on permission denied.
  • Loading branch information
rtkjbeverly authored Feb 24, 2021
1 parent f1b7afd commit a8c5ca4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions print.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func Print(idProvider identityProviders.IdentityProvider, awsProvider servicePro

if printOptions.AssumeRole != "" {
creds, err = awsProvider.AssumeRole(*creds, printOptions.AssumeRole, printOptions.User)
if err != nil {
log.Fatal(fmt.Errorf("Could not assume role %s with current permissions", printOptions.AssumeRole))
}
}

command := printCommand(printOptions, creds)
Expand Down

0 comments on commit a8c5ca4

Please sign in to comment.