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

Class SyncSecurityDataCommand

keepercommander/commands/utils.py:2487–2516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

register_commandsFunction · 0.85
executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected