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

Class SyncSecurityDataCommand

keepercommander/commands/utils.py:2485–2514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2483
2484
2485class SyncSecurityDataCommand(Command):
2486 def get_parser(self):
2487 return sync_security_data_parser
2488
2489 def execute(self, params, **kwargs):
2490 if not params.enterprise_ec_key:
2491 msg = 'Command not allowed -- This command is limited to enterprise users only.'
2492 raise CommandError('sync-security-data', msg)
2493
2494 def parse_input_records(): # type: () -> Set[str]
2495 names = kwargs.get('record',[])
2496 do_all = '@all' in names
2497 return params.record_cache.keys() if do_all \
2498 else itertools.chain.from_iterable(get_ruids(params, n) for n in names)
2499
2500 force_update = kwargs.get('force', False)
2501 api.sync_down(params)
2502 recs = [KeeperRecord.load(params, r) for r in parse_input_records()]
2503 should_update = lambda r: force_update or bool(needs_security_audit(params, r))
2504 recs_to_update = [r for r in recs if should_update(r)]
2505 num_to_update = len(recs_to_update)
2506 num_updated = update_security_audit_data(params, recs_to_update)
2507 if num_updated:
2508 BreachWatch.save_reused_pw_count(params)
2509 api.sync_down(params)
2510 if not kwargs.get('quiet'):
2511 if num_updated:
2512 logging.info(f'Updated security data for {num_updated} {"record" if num_updated == 1 else "records"}')
2513 elif not kwargs.get('suppress_no_op') and not num_to_update:
2514 logging.info('No records requiring security-data updates found')
2515
2516
2517class BlankRecordCommand(Command):

Callers 2

register_commandsFunction · 0.85
executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected