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

Class SyncSecurityDataCommand

keepercommander/commands/utils.py:2572–2601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2570
2571
2572class SyncSecurityDataCommand(Command):
2573 def get_parser(self):
2574 return sync_security_data_parser
2575
2576 def execute(self, params, **kwargs):
2577 if not params.enterprise_ec_key:
2578 msg = 'Command not allowed -- This command is limited to enterprise users only.'
2579 raise CommandError('sync-security-data', msg)
2580
2581 def parse_input_records(): # type: () -> Set[str]
2582 names = kwargs.get('record',[])
2583 do_all = '@all' in names
2584 return params.record_cache.keys() if do_all \
2585 else itertools.chain.from_iterable(get_ruids(params, n) for n in names)
2586
2587 force_update = kwargs.get('force', False)
2588 api.sync_down(params)
2589 recs = [KeeperRecord.load(params, r) for r in parse_input_records()]
2590 should_update = lambda r: force_update or bool(needs_security_audit(params, r))
2591 recs_to_update = [r for r in recs if should_update(r)]
2592 num_to_update = len(recs_to_update)
2593 num_updated = update_security_audit_data(params, recs_to_update)
2594 if num_updated:
2595 BreachWatch.save_reused_pw_count(params)
2596 api.sync_down(params)
2597 if not kwargs.get('quiet'):
2598 if num_updated:
2599 logging.info(f'Updated security data for {num_updated} {"record" if num_updated == 1 else "records"}')
2600 elif not kwargs.get('suppress_no_op') and not num_to_update:
2601 logging.info('No records requiring security-data updates found')
2602
2603
2604class BlankRecordCommand(Command):

Callers 2

register_commandsFunction · 0.85
executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected