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

Method execute

keepercommander/commands/scim.py:313–505  ·  view source on GitHub ↗
(self, params, target=None, **kwargs)

Source from the content-addressed store, hash-verified

311 return scim_push_parser
312
313 def execute(self, params, target=None, **kwargs):
314 scim = find_scim(params, target)
315 dry_run = kwargs.get('dry_run') is True
316
317 scim_url = get_scim_url(params, scim['node_id'])
318 record_uid = kwargs.get('record')
319 record = None # type: Optional[vault.TypedRecord]
320 if record_uid:
321 if record_uid in params.record_cache:
322 r = vault.KeeperRecord.load(params, record_uid)
323 if isinstance(r, vault.TypedRecord):
324 record = r
325 else:
326 raise CommandError('', f'Record UID "{record_uid}": invalid record type ')
327 else:
328 raise CommandError('', f'Record UID "{record_uid}": does not exist')
329 else:
330 for r in vault_extensions.find_records(params, record_version=3):
331 if not isinstance(r, vault.TypedRecord):
332 continue
333 field = next((x for x in r.fields if x.type == 'url'), None)
334 if field:
335 url = field.get_default_value(str)
336 if url and url == scim_url:
337 record = r
338 break
339 if not isinstance(record, vault.TypedRecord):
340 raise CommandError('', f'Cannot find SCIM record with URL: {scim_url}')
341
342 destructive = 0
343 verbose = False
344 field = next((x for x in record.fields if x.type == 'password'), None)
345 if not field:
346 raise CommandError('', f'"Password" field not found on record "{record.title}"')
347 token = field.get_default_value(str)
348 if not token:
349 raise CommandError('', f'"Password" field is empty on record "{record.title}"')
350
351 field = record.get_typed_field('text', 'Destructive')
352 if field:
353 sv = field.get_default_value(str)
354 if sv and sv.isnumeric():
355 destructive = int(sv)
356 field = record.get_typed_field('text', 'Verbose')
357 if field:
358 sv = field.get_default_value(str)
359 if sv and sv.lower() in ('true', 'yes', 'on', '1'):
360 verbose = True
361
362 def verbose_logging(message):
363 if verbose:
364 logging.info(message)
365
366 keeper_users = {} # type: Dict[str, ScimUser]
367 keeper_groups = {} # type: Dict[str, ScimGroup]
368 logging.debug('SCIM Query Keeper')
369 for element in ScimPushCommand.scim_keeper(scim_url, token):
370 if isinstance(element, ScimUser):

Callers

nothing calls this directly

Calls 15

populateMethod · 0.95
sync_groupsMethod · 0.95
sync_usersMethod · 0.95
sync_membershipMethod · 0.95
executeMethod · 0.95
find_scimFunction · 0.85
get_scim_urlFunction · 0.85
GoogleCrmDataSourceClass · 0.85
user_choiceFunction · 0.85
AdCrmDataSourceClass · 0.85
LocalCrmDataSourceClass · 0.85
TeamApproveCommandClass · 0.85

Tested by

no test coverage detected