vaultmanager/modules/VaultManagerKV.py
def kv_search(
            self, vault_addr, vault_token, to_search, included=[], excluded=[]
    ):
        """
        Method running the search function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param to_search: Values to search in KV
        :type to_search: list(str)
        :param included: Paths to include in search
        :type included: list(str)
        :param excluded: Paths to exclude from search
        :type excluded: list(str)

        :return: list
        """
        self.logger.debug("KV search secrets starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        kv_full = {}
        kv_list = []
        found_values = []
        for path in included:
            kv_list += vault_client.secrets_tree_list(path, excluded)
        for kv in kv_list:
            kv_full[kv] = vault_client.read_secret(kv)

        for path in kv_full:
            for key in kv_full[path]:
                for v in to_search:
                    if v in os.path.join(path, key) or v in kv_full[path][key]:
                        found_values.append(os.path.join(path, key))

        self.logger.info(json.dumps(found_values, indent=4))
        return found_values

        Method running the search function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param to_search: Values to search in KV
        :type to_search: list(str)
        :param included: Paths to include in search
        :type included: list(str)
        :param excluded: Paths to exclude from search
        :type excluded: list(str)

        :return: list
        
Method running the search function of KV module
Method running the search function of KV module
def kv_search(
            self, vault_addr, vault_token, to_search, included=[], excluded=[]
    ):
        self.logger.debug("KV search secrets starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        kv_full = {}
        kv_list = []
        found_values = []
        for path in included:
            kv_list += vault_client.secrets_tree_list(path, excluded)
        for kv in kv_list:
            kv_full[kv] = vault_client.read_secret(kv)
        for path in kv_full:
            for key in kv_full[path]:
                for v in to_search:
                    if v in os.path.join(path, key) or v in kv_full[path][key]:
                        found_values.append(os.path.join(path, key))
        self.logger.info(json.dumps(found_values, indent=4))
        return found_values
def kv_search ( self , vault_addr , vault_token , to_search , included = [ ] , excluded = [ ] ) : self . logger . debug ( "KV search secrets starting" ) vault_client = self . connect_to_vault ( vault_addr , vault_token ) kv_full = { } kv_list = [ ] found_values = [ ] for path in included : kv_list += vault_client . secrets_tree_list ( path , excluded ) for kv in kv_list : kv_full [ kv ] = vault_client . read_secret ( kv ) for path in kv_full : for key in kv_full [ path ] : for v in to_search : if v in os . path . join ( path , key ) or v in kv_full [ path ] [ key ] : found_values . append ( os . path . join ( path , key ) ) self . logger . info ( json . dumps ( found_values , indent = 4 ) ) return found_values
Method running the search function of KV module
Method running the search function of KV module
"""
        Method running the search function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param to_search: Values to search in KV
        :type to_search: list(str)
        :param included: Paths to include in search
        :type included: list(str)
        :param excluded: Paths to exclude from search
        :type excluded: list(str)

        :return: list
        """
None
self
vault_addr
Vault instance URL
Vault instance URL
vault_token
None
to_search
Values to search in KV
Values to search in KV
included
Paths to include in search
Paths to include in search
excluded
Paths to exclude from search
Paths to exclude from search