# Buggy code
def assign_group_memberships(self):
    """
    Assigns members to groups
    """
    for group in self["groups"]:
        for user in self["users"]:
            if group in self["users"][user]["groups"]:
                self["groups"][group]["users"].append(user)


# Traceback (azure.graphrbac.models.graph_error_py3.GraphErrorException)
2020-07-24 03:56:32 ubuntu scout[3614] ERROR aad.py L30: Failed to retrieve user xxx-xxx-xxx-xxx-xxx: Resource 'xxx-xxxx-xxx-xxx-xxx-xx' does not exist or one of its queried reference-property objects are not present.
Traceback (most recent call last):
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/facade/aad.py", line 30, in get_user
return await run_concurrently(lambda: self.get_client().users.get(user_id))
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/utils.py", line 24, in run_concurrently
return await run_function_concurrently(function)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/facade/aad.py", line 30, in <lambda>
return await run_concurrently(lambda: self.get_client().users.get(user_id))
File "/home/victor/.local/lib/python3.6/site-packages/azure/graphrbac/operations/users_operations.py", line 218, in get
raise models.GraphErrorException(self._deserialize, response)
azure.graphrbac.models.graph_error_py3.GraphErrorException: Resource 'xxx-xxx-xxx-xxx-xxx' does not exist or one of its queried reference-property objects are not present.
Traceback (most recent call last):
File "./scout.py", line 8, in <module>
sys.exit(run_from_cli())
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/__main__.py", line 77, in run_from_cli
programmatic_execution=False)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/__main__.py", line 131, in run
result = loop.run_until_complete(_run(**locals()))  # pass through all the parameters
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/__main__.py", line 258, in _run
await cloud_provider.fetch(regions=regions, excluded_regions=excluded_regions)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/base/provider.py", line 81, in fetch
await self.services.fetch(self.service_list, regions, excluded_regions)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/services.py", line 78, in fetch
await self.aad.fetch_additional_users(user_list)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/resources/aad/base.py", line 26, in fetch_additional_users
await additional_users.fetch_additional_users(user_list)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/resources/aad/users.py", line 17, in fetch_additional_users
id, user = await self._parse_user(raw_user)
File "/home/victor/Documents/scout_59/ScoutSuite/ScoutSuite/providers/azure/resources/aad/users.py", line 22, in _parse_user
user_dict['id'] = raw_user.object_id
AttributeError: 'list' object has no attribute 'object_id'

# Fixed code
def assign_group_memberships(self):
    """
    Assigns members to groups
    """
    try:
        for group in self["groups"]:
            for user in self["users"]:
                if group in self["users"][user]["groups"]:
                    self["groups"][group]["users"].append(user)
    except Exception as e:
        print_exception("Unable to assign group memberships: {}".format(e))