MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / prep_security_data

Function prep_security_data

keepercommander/security_audit.py:39–70  ·  view source on GitHub ↗
(params, record)

Source from the content-addressed store, hash-verified

37 return encrypt_fn(data, pubkey)
38
39def prep_security_data(params, record):
40 get_bw_obj = lambda rec: next(
41 iter(params.breach_watch_records.get(rec, {}).get('data_unencrypted', {}).get('passwords', [])),
42 {}) if params.breach_watch else None
43
44 from .breachwatch import BreachWatch
45 score = get_security_score(record)
46 # Send empty object to remove old security data (when password and/or passkey are removed)
47 sec_data = b''
48 if score is not None:
49 sec_data = {'strength': score}
50 password = _get_pass(record)
51 login_url = BreachWatch.extract_url(record)
52 parse_results = urllib.parse.urlparse(login_url)
53 domain = parse_results.hostname or parse_results.path
54 pw_obj = get_bw_obj(record.record_uid)
55 if pw_obj is not None and password:
56 status = pw_obj.get('status')
57 sec_data['bw_result'] = client_pb2.BWStatus.Value(status) if status \
58 else client_pb2.BWStatus.GOOD if is_pw_strong(score) \
59 else client_pb2.BWStatus.WEAK
60 if domain:
61 sec_data.update(dict(domain=domain))
62 data_size = len(json.dumps(sec_data).encode('utf8'))
63 max_size = 244
64 diff = max_size - data_size
65 # truncate domain string if needed to avoid reaching RSA encryption data size limitation
66 if diff < 0:
67 new_length = len(domain) + diff
68 sec_data.update(dict(domain=domain[:new_length]))
69 sec_data = encrypt_security_data(params, sec_data)
70 return sec_data
71
72def prep_security_data_update(params, record): # type: (KeeperParams, KeeperRecord) -> Optional[APIRequest_pb2.SecurityData]
73 sd = APIRequest_pb2.SecurityData()

Callers 2

attach_security_dataFunction · 0.85

Calls 7

get_security_scoreFunction · 0.85
_get_passFunction · 0.85
is_pw_strongFunction · 0.85
encrypt_security_dataFunction · 0.85
getMethod · 0.80
extract_urlMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected