Skip to content

Commit

Permalink
handle IAM credentials report better
Browse files Browse the repository at this point in the history
  • Loading branch information
kubasobon committed Mar 20, 2024
1 parent c4dc93f commit 47082fb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/resources/providers/awslib/iam/root_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ func (p Provider) getRootAccountUser(rootAccount *CredentialReport) *types.User
return nil
}

pwdLastUsed, err := time.Parse(time.RFC3339, rootAccount.PasswordLastUsed)
if err != nil {
p.log.Errorf("fail to parse root account password last used, error: %v", err)
return nil
pwdLastUsed := time.Time{}
// "no_information" if never used, "N/A" if user has no password
// Docs: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_getting-report.html
if rootAccount.PasswordLastUsed != "no_information" && rootAccount.PasswordLastUsed != "N/A" {
pwdLastUsed, err = time.Parse(time.RFC3339, rootAccount.PasswordLastUsed)
if err != nil {
p.log.Errorf("fail to parse root account password last used, error: %v", err)
return nil
}
}

return &types.User{
Expand Down

0 comments on commit 47082fb

Please sign in to comment.