diff --git a/scrapers/aws/aws.go b/scrapers/aws/aws.go index eed8688a..31f0057e 100644 --- a/scrapers/aws/aws.go +++ b/scrapers/aws/aws.go @@ -1074,6 +1074,13 @@ func (aws Scraper) iamProfiles(ctx *AWSContext, config v1.AWS, results *v1.Scrap return } + // We need to cast roles as []map[string]any to update the policy doc + var profileRoles []map[string]any + for _, r := range profileMap["Roles"].([]any) { + profileRoles = append(profileRoles, r.(map[string]any)) + } + profileMap["Roles"] = profileRoles + for _, role := range profileMap["Roles"].([]map[string]any) { if val, exists := role["AssumeRolePolicyDocument"]; exists { policyDocEncoded := val.(string) diff --git a/utils/json.go b/utils/json.go index 69a05966..a2e15cd2 100644 --- a/utils/json.go +++ b/utils/json.go @@ -24,11 +24,11 @@ func ToJSONMap(s any) (map[string]any, error) { var raw []byte var err error - switch s.(type) { + switch s := s.(type) { case string: - raw = []byte(s.(string)) + raw = []byte(s) case []byte: - raw = s.([]byte) + raw = s default: raw, err = json.Marshal(s) if err != nil {