fetch and decrypt all secrets
965741
def getAllSecrets(version="", region=None, table="credential-store",
                  context=None, credential=None, session=None, **kwargs):
    '''
    
    '''
    if session is None:
        session = get_session(**kwargs)
    dynamodb = session.resource('dynamodb', region_name=region)
    kms = session.client('kms', region_name=region)
    secrets = listSecrets(region, table, **kwargs)

    # Only return the secrets that match the pattern in `credential`
    # This already works out of the box with the CLI get action,
    # but that action doesn't support wildcards when using as library
    if credential and WILDCARD_CHAR in credential:
        names = set(expand_wildcard(credential,
                                    [x["name"]
                                     for x in secrets]))
    else:
        names = set(x["name"] for x in secrets)

    pool = ThreadPool(min(len(names), THREAD_POOL_MAX_SIZE))
    results = pool.map(
        lambda credential: getSecret(credential, version, region, table, context, dynamodb, kms, **kwargs),
        names)
    pool.close()
    pool.join()
    return dict(zip(names, results))
887093
def get_keys(self):
        '''
        
        '''
        # Make sure all key parent directories are accessible
        user = self.opts.get('user', 'root')
        salt.utils.verify.check_path_traversal(self.opts['pki_dir'], user)

        if not os.path.exists(self.rsa_path):
            log.info('Generating keys: %s', self.opts['pki_dir'])
            gen_keys(self.opts['pki_dir'],
                     'minion',
                     self.opts['keysize'],
                     self.opts.get('user'))
        key = get_rsa_key(self.rsa_path, None)
        log.debug('Loaded minion key: %s', self.rsa_path)
        return key
1356566
def read_data(item, parent = '')
      me = File.join(parent, item)

      # me will contain /metadata if secrets_version 2 due to list_prefix method
      if secrets_version == "2"
        me = me.sub(/metadata/, "data")
        # It's possible for a vault secret to be nil...
        if vault_client.logical.read(me).nil?
          warn red("vault secret '#{me}' contains a null vaule, ignoring...")
          {}
        else
          vault_client.logical.read(me).data[:data]
        end
      else
        vault_client.logical.read(me).data
      end
    end
130603
def decrypt_var(passphrase=None):
    """"""
    encrypted = cryptorito.portable_b64decode(sys.stdin.read())
    print(cryptorito.decrypt_var(encrypted, passphrase))
275414
function extractReadableKeys (dir, options) {
  const pwd = options.input
  prompt.start()
  prompt.get(promptSchema, (err, { password }) => {
    const key = fs.readFileSync(path.join(pwd, dir, 'sign_key'))
    const pubKey = fs.readFileSync(path.join(pwd, dir, 'sign_key.pub'))

    const decrypted = Crypto.decryptPrivateKey(password, key)

    const privateHex = Buffer.from(decrypted).toString('hex')
    const decryptedPub = Crypto.decryptPubKey(password, pubKey)

    console.log(`Private key (hex): ${privateHex}`)
    console.log(`Public key (base check): ak_${Crypto.encodeBase58Check(decryptedPub)}`)
    console.log(`Public key (hex): ${decryptedPub.toString('hex')}`)
  })
}
1041716
def fetch_all(options = {})
      options = { :prune => false }.merge(options)
      git_args = ['--all']
      git_args << '--prune' if options[:prune]
      fetch(git_args)
      fetch('--tags')  # need a separate call for tags or else you don't get all the tags
      true
    end
1144671
def _secret_yaml(loader, node):
    """"""
    fname = os.path.join(os.path.dirname(loader.name), "secrets.yaml")

    try:
        with open(fname, encoding="utf-8") as secret_file:
            secrets = YAML(typ="safe").load(secret_file)
    except FileNotFoundError:
        raise ValueError("Secrets file {} not found".format(fname)) from None

    try:
        return secrets[node.value]
    except KeyError:
        raise ValueError("Secret {} not found".format(node.value)) from None
949823
function readAllSecure(user, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;
    const action = 'read';
    const rules = shield.getApplicableRules(action);
    return shield._fetchAll.call(self, options)
        .then(function runShieldRules(collection) {
            // TODO: investigate what happens if fetch returns nothing (err?)
            return collection.mapThen((mdl) => applyRules(rules, mdl, user))
                .then(function resolveResult() {
                    return collection;
                });
        });
}
215583
def reload(self):
        """"""
        self._source = self._fetch_secrets(self._vault_url, self._path, self._token)
609089
def Decrypt(self, data, iv):
    """"""
    key = rdf_crypto.EncryptionKey(self.cipher.key)
    iv = rdf_crypto.EncryptionKey(iv)
    return rdf_crypto.AES128CBCCipher(key, iv).Decrypt(data)
695188
def get_secret(
        end_state: NettingChannelEndState,
        secrethash: SecretHash,
) -> Optional[Secret]:
    """"""
    partial_unlock_proof = end_state.secrethashes_to_unlockedlocks.get(secrethash)

    if partial_unlock_proof is None:
        partial_unlock_proof = end_state.secrethashes_to_onchain_unlockedlocks.get(secrethash)

    if partial_unlock_proof is not None:
        return partial_unlock_proof.secret

    return None
1192126
def fetch_all(self, api_client, fetchstatuslogger, q, targets):
        '''
        
        '''
        self.fetchstatuslogger = fetchstatuslogger
        if targets != None:
            # Ensure targets is a tuple
            if type(targets) != list and type(targets) != tuple:
                targets = tuple(targets,)
            elif type(targets) != tuple:
                targets = tuple(targets)
        for target in targets:
            self._fetch_targets(api_client, q, target)
1289483
def get_secrets(namespace, name="", apiserver_url=None, decode=False, brief=False):
    '''
    

    '''
    # Try to get kubernetes master
    apiserver_url = _guess_apiserver(apiserver_url)
    if apiserver_url is None:
        return False

    # Get data
    if not decode:
        ret = _get_secrets(namespace, name, apiserver_url)
    else:
        ret = _decode_secrets(_get_secrets(namespace, name, apiserver_url))
    return ret
1073475
def decrypt(message):
    '''
    '''
    try:
        ret = kms.decrypt(
            CiphertextBlob=base64.decodestring(message))
        decrypted_data = ret.get('Plaintext')
    except Exception as e:
        # returns http 500 back to user and log error details in Cloudwatch Logs
        raise Exception("Unable to decrypt data: ", e)

    return decrypted_data
289903
function decrypt(message) {
  if (this.secure && this.cipher && this.secret) {
    if (this.secret === 'secret') {
      console.warn('PLEASE change default secret password!');
    }
    debug('%s decrypt message with %s', this.name, this.cipher);
    var decipher = crypto.createDecipher(this.cipher, this.secret);
    return Buffer.concat([decipher.update(message), decipher.final()]);
  }
  return message;
}
837740
function(localHashes, files, done) {
        fetchRemoteHashes(function(err, remoteHashes) {
          done(err, localHashes, remoteHashes, files);
        });
      }
885314
def _redact_secret(
        data: Union[Dict, List],
) -> Union[Dict, List]:
    

    if isinstance(data, dict):
        stack = [data]
    else:
        stack = []

    while stack:
        current = stack.pop()

        if 'secret' in current:
            current['secret'] = '<redacted>'
        else:
            stack.extend(
                value
                for value in current.values()
                if isinstance(value, dict)
            )

    return data