Skip to content

Commit

Permalink
Merge pull request #192 from sabre1041/npe-azure-fixes
Browse files Browse the repository at this point in the history
Added checks to avoid NPE in azure provider
  • Loading branch information
raffaelespazzoli authored May 26, 2022
2 parents a1eb3e1 + 46a9b0a commit bc36630
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions pkg/syncer/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,18 @@ func (a *AzureSyncer) Sync() ([]userv1.Group, error) {
// Add base groups
if GraphGroupType == *baseGroupMemberODataType {

baseGroupDisplayNameRaw, _ := baseGroupMember.GetAdditionalData()[GraphDisplayName]
baseGroupDisplayName := baseGroupDisplayNameRaw.(*string)
baseGroup := graph.Group{
DirectoryObject: baseGroupMember,
baseGroupDisplayNameRaw, ok := baseGroupMember.GetAdditionalData()[GraphDisplayName]

if ok {

baseGroupDisplayName := baseGroupDisplayNameRaw.(*string)
baseGroup := graph.Group{
DirectoryObject: baseGroupMember,
}
baseGroup.SetDisplayName(baseGroupDisplayName)
aadGroups = append(aadGroups, baseGroup)

}
baseGroup.SetDisplayName(baseGroupDisplayName)
aadGroups = append(aadGroups, baseGroup)
}
}

Expand Down Expand Up @@ -352,7 +357,13 @@ func (a *AzureSyncer) getUsernameForUser(user graph.DirectoryObject) (string, bo
func (a *AzureSyncer) isUsernamePresent(user graph.DirectoryObject, field string) (string, bool) {

value, ok := user.GetAdditionalData()[field].(*string)
return fmt.Sprintf("%v", *value), ok

if ok {
return fmt.Sprintf("%v", *value), ok
} else {
return "", ok
}

}

func (a *AzureSyncer) GetPrune() bool {
Expand Down

0 comments on commit bc36630

Please sign in to comment.