Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_user_params():
p = params.KeeperParams(server='https://test.keepersecurity.com/', device_id=_DEVICE_ID)
p.config['device_id'] = base64.urlsafe_b64encode(_DEVICE_ID).decode('utf-8').rstrip('=')
p.user = _USER_NAME
p.password = _USER_PASSWORD
return p
def setUpClass(cls):
cls.params = KeeperParams()
read_config_file(cls.params)
api.login(cls.params)
TestConnectedCommands.wipe_out_data()
for r in password_rules:
m = re.match(r['pattern'], pwd)
if r['match']:
if m is None:
failed_rules.append(r['description'])
else:
if m is not None:
failed_rules.append(r['description'])
if len(failed_rules) == 0:
password = pwd
else:
logging.error(rs['password_rules_intro'])
for fr in failed_rules:
logging.error(fr)
new_params = KeeperParams()
new_params.server = params.server
data_center = kwargs.get('data_center')
if data_center:
parts = list(urlsplit(new_params.server))
host = parts[1]
port = ''
colon_pos = host.rfind(':')
if colon_pos > 0:
port = host[colon_pos:]
host = host[:colon_pos]
suffix = '.eu' if data_center == 'eu' else '.com'
if not host.endswith(suffix):
dot_pos = host.rfind('.')
if dot_pos > 0:
host = host[:dot_pos] + suffix
parts[1] = host + port
def get_params_from_config(config_filename):
params = KeeperParams()
params.config_filename = config_filename or 'config.json'
try:
with open(params.config_filename) as config_file:
try:
params.config = json.load(config_file)
if 'user' in params.config:
params.user = params.config['user'].lower()
if 'server' in params.config:
params.server = params.config['server']
if 'password' in params.config:
params.password = params.config['password']
# |_|\_\___\___| .__/\___|_|
# |_|
#
# Keeper Commander
# Copyright 2018 Keeper Security Inc.
# Contact: ops@keepersecurity.com
#
# Example showing how to add a new or existing record
# to an existing shared folder.
#
from keepercommander.params import KeeperParams
from keepercommander import api
from keepercommander.commands.record import RecordAddCommand
params = KeeperParams()
# Inputs - hard coded for demo purposes
params.user = 'your_keeper_email'
params.password = 'your_keeper_password'
shared_folder_uid = 'your_shared_folder_uid'
# Login and sync
api.sync_down(params)
command = RecordAddCommand()
record_uid = command.execute(params, title='Test Record', login='someone@company.com', url='https://google.com', folder=shared_folder_uid, generate=True, force=True)
print('Added record to shared folder')
'client_key': api.encrypt_aes(os.urandom(32), data_key)
}
if verification_code:
rq['verification_code'] = verification_code
rs = api.run_command(new_params, rq)
if rs['result'] == 'success':
logging.info("Created account: %s ", email)
if kwargs.get('question'):
if not kwargs.get('answer'):
print('...' + 'Security Question: '.rjust(24) + kwargs['question'])
kwargs['answer'] = input('...' + 'Security Answer: '.rjust(24))
if kwargs.get('answer'):
try:
param1 = KeeperParams()
param1.server = new_params.server
param1.user = email
param1.password = password
param1.rest_context.device_id = params.rest_context.device_id
api.login(param1)
answer = kwargs['answer'].lower().replace(' ', '')
rq = {
'command': 'set_data_key_backup',
'version': 2,
'data_key_backup': api.create_encryption_params(answer, backup_salt, iterations, data_key),
'security_question': kwargs['question'],
'security_answer_salt': base64.urlsafe_b64encode(backup_salt).decode().rstrip('='),
'security_answer_iterations': iterations,
'security_answer_hash': base64.urlsafe_b64encode(api.derive_key(answer, backup_salt, iterations)).decode().rstrip('=')
}
api.communicate(param1, rq)
# |_|
#
# Keeper Commander
# Copyright 2019 Keeper Security Inc.
# Contact: ops@keepersecurity.com
#
# Example showing how to access the raw enterprise event logs
# for some custom processing.
#
import getpass
from keepercommander.params import KeeperParams
from keepercommander import api
my_params = KeeperParams()
while not my_params.user:
my_params.user = input('User(Email): ')
while not my_params.password:
my_params.password = getpass.getpass(prompt='Master Password: ', stream=None)
events = []
finished = False
# UNIX epoch time in seconds
last_event_time = 0
logged_ids = set()
print('Downloading ', end='', flush=True)
while not finished:
# Contact: ops@keepersecurity.com
#
# Example showing how to create a record and upload
# to the server, then deleting the record from the
# server.
#
import getpass
import string
import random
from keepercommander.record import Record
from keepercommander.params import KeeperParams
from keepercommander import display, api
my_params = KeeperParams()
while not my_params.user:
my_params.user = getpass.getpass(prompt='User(Email): ', stream=None)
while not my_params.password:
my_params.password = getpass.getpass(prompt='Master Password: ', stream=None)
api.sync_down(my_params)
# Add record
r = Record()
r.title = 'Test Record'
r.login = 'someone@company.com'
# generate a 32-char random password
r.password = ''.join(random.SystemRandom().choice(string.printable) for _ in range(32))