Split up Azure credential working to make it easier for the server to understand.

Fixed bugs in Azure report server side and fixed a hardcoded constant in get_issues_overview
This commit is contained in:
Daniel Goldberg 2018-03-26 19:30:53 +03:00
parent 93fee0d2c5
commit 9d7b345d1d
2 changed files with 13 additions and 13 deletions

View File

@ -125,8 +125,7 @@ class InfoCollector(object):
self.info["credentials"][username] = {}
# we might be losing passwords in case of multiple reset attempts on same username
# or in case another collector already filled in a password for this user
self.info["credentials"][username]['Password'] = password
self.info["credentials"][username]['Azure'] = True
self.info["credentials"][username]['password'] = password
if len(azure_creds) != 0:
self.info["Azure"] = True
self.info["Azure"] = {}
self.info["Azure"]['usernames'] = [cred[0] for cred in azure_creds]

View File

@ -81,7 +81,7 @@ class ReportService:
{
'type': 'azure_password',
'machine': machine,
'users': set([instance['username'] for instance in creds if instance['origin']==machine])
'users': set([instance['username'] for instance in creds if instance['origin'] == machine])
}
for machine in machines]
@ -158,15 +158,15 @@ class ReportService:
creds = []
for telem in mongo.db.telemetry.find(
{'telem_type': 'system_info_collection', 'data.Azure': {'$exists': True}},
{'data.credentials': 1, 'monkey_guid': 1}
{'data.Azure': 1, 'monkey_guid': 1}
):
monkey_creds = telem['data']['credentials']
if len(monkey_creds) == 0:
azure_users = telem['data']['Azure']['usernames']
if len(azure_users) == 0:
continue
origin = NodeService.get_monkey_by_guid(telem['monkey_guid'])['hostname']
new_creds = [{'username': user.replace(',', '.'), 'type': 'Clear Password',
'origin': origin} for user in monkey_creds if 'Azure' in user]
creds.extend(new_creds)
azure_leaked_users = [{'username': user.replace(',', '.'), 'type': 'Clear Password',
'origin': origin} for user in azure_users]
creds.extend(azure_leaked_users)
return creds
@staticmethod
@ -349,7 +349,8 @@ class ReportService:
@staticmethod
def get_config_ips():
if ConfigService.get_config_value(['basic_network', 'network_range', 'range_class'], True, True) != 'FixedRange':
if ConfigService.get_config_value(['basic_network', 'network_range', 'range_class'], True,
True) != 'FixedRange':
return []
return ConfigService.get_config_value(['basic_network', 'network_range', 'range_fixed'], True, True)
@ -359,7 +360,7 @@ class ReportService:
@staticmethod
def get_issues_overview(issues, config_users, config_passwords):
issues_byte_array = [False] * 6
issues_byte_array = [False] * len(ReportService.ISSUES_DICT)
for machine in issues:
for issue in issues[machine]: