@@ -40,8 +40,6 @@ func (auditor *AzureAuditor) auditRoleAssignments(ctx context.Context, logger *l
40
40
func (auditor * AzureAuditor ) fetchRoleAssignments (ctx context.Context , logger * log.Entry , subscription * subscriptions.Subscription ) (list []* validator.AzureObject ) {
41
41
list = []* validator.AzureObject {}
42
42
43
- roleDefinitionList := auditor .fetchRoleDefinitionList (ctx , logger , subscription )
44
-
45
43
client := authorization .NewRoleAssignmentsClientWithBaseURI (auditor .azure .client .Environment .ResourceManagerEndpoint , * subscription .SubscriptionID )
46
44
auditor .decorateAzureClient (& client .Client , auditor .azure .client .GetAuthorizer ())
47
45
@@ -72,7 +70,7 @@ func (auditor *AzureAuditor) fetchRoleAssignments(ctx context.Context, logger *l
72
70
obj := map [string ]interface {}{
73
71
"resource.id" : stringPtrToStringLower (roleAssignment .ID ),
74
72
"subscription.id" : to .String (subscription .SubscriptionID ),
75
- "role .id" : stringPtrToStringLower (roleAssignment .RoleDefinitionID ),
73
+ "roledefinition .id" : stringPtrToStringLower (roleAssignment .RoleDefinitionID ),
76
74
"principal.objectid" : stringPtrToStringLower (roleAssignment .PrincipalID ),
77
75
"resourcegroup.name" : azureScope .ResourceGroup ,
78
76
@@ -84,12 +82,6 @@ func (auditor *AzureAuditor) fetchRoleAssignments(ctx context.Context, logger *l
84
82
"roleassignment.age" : time .Since (roleAssignment .CreatedOn .Time ),
85
83
}
86
84
87
- if roleDefinition , exists := roleDefinitionList [stringPtrToStringLower (roleAssignment .RoleDefinitionID )]; exists {
88
- obj ["role.name" ] = stringPtrToStringLower (roleDefinition .RoleName )
89
- obj ["role.type" ] = stringPtrToStringLower (roleDefinition .RoleType )
90
- obj ["role.description" ] = stringPtrToStringLower (roleDefinition .Description )
91
- }
92
-
93
85
list = append (list , validator .NewAzureObject (obj ))
94
86
95
87
if response .NextWithContext (ctx ) != nil {
@@ -101,29 +93,3 @@ func (auditor *AzureAuditor) fetchRoleAssignments(ctx context.Context, logger *l
101
93
102
94
return
103
95
}
104
-
105
- func (auditor * AzureAuditor ) fetchRoleDefinitionList (ctx context.Context , logger * log.Entry , subscription * subscriptions.Subscription ) map [string ]authorization.RoleDefinition {
106
- client := authorization .NewRoleDefinitionsClientWithBaseURI (auditor .azure .client .Environment .ResourceManagerEndpoint , * subscription .SubscriptionID )
107
- auditor .decorateAzureClient (& client .Client , auditor .azure .client .GetAuthorizer ())
108
-
109
- response , err := client .ListComplete (ctx , * subscription .ID , "" )
110
-
111
- if err != nil {
112
- logger .Panic (err )
113
- }
114
-
115
- roleDefinitionList := map [string ]authorization.RoleDefinition {}
116
-
117
- for response .NotDone () {
118
- roleDefinition := response .Value ()
119
-
120
- roleDefinitionID := stringPtrToStringLower (roleDefinition .ID )
121
- roleDefinitionList [roleDefinitionID ] = roleDefinition
122
-
123
- if response .NextWithContext (ctx ) != nil {
124
- break
125
- }
126
- }
127
-
128
- return roleDefinitionList
129
- }
0 commit comments