Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(KC-687) security-audit-report fix: #1107

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions keepercommander/commands/security_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(self):
class SecurityAuditReportCommand(EnterpriseCommand):
def __init__(self):
super(SecurityAuditReportCommand, self).__init__()
self.tree_key = None
self.user_lookup = None
self.enterprise_private_rsa_key = None
self.score_data_keys = (
Expand All @@ -118,26 +119,23 @@ def get_strong_by_total(self, total, strong):
return 0 if (total == 0) else (strong / total)

def resolve_user_info(self, params, enterprise_user_id):
if self.user_lookup is None:
if self.user_lookup is None or params.enterprise.get('unencrypted_tree_key') != self.tree_key:
self.tree_key = params.enterprise.get('unencrypted_tree_key')
self.user_lookup = {}
if params.enterprise:
if 'users' in params.enterprise:
for user in params.enterprise['users']:
if 'enterprise_user_id' in user and 'username' in user:
email = user['username']
username = user['data']['displayname'] if 'data' in user and 'displayname' in user[
'data'] else None
if (
username is None or not username.strip()) and 'encrypted_data' in user and 'key_type' in user:
username = user['encrypted_data'] if user['key_type'] == 'no_key' else None
username = email if username is None or not username.strip() else username
node_id = user.get('node_id', 0)
self.user_lookup[user['enterprise_user_id']] = \
{
'username': username,
'email': email,
'node_id': node_id
}
for user in params.enterprise.get('users'):
if 'enterprise_user_id' in user and 'username' in user:
email = user['username']
username = user['data']['displayname'] if 'data' in user and 'displayname' in user['data'] \
else None
if (username is None or not username.strip()) and 'encrypted_data' in user and 'key_type' in user:
username = user['encrypted_data'] if user['key_type'] == 'no_key' else None
username = email if username is None or not username.strip() else username
node_id = user.get('node_id', 0)
self.user_lookup[user['enterprise_user_id']] = {
'username': username,
'email': email,
'node_id': node_id
}

info = {
'username': enterprise_user_id,
Expand Down