vaultmanager/modules/VaultManagerKV.py
def kv_find_duplicates(self, vault_addr, vault_token, paths, excluded=[]):
        """
        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to look for duplicates
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        """
        self.logger.debug("KV find duplicates starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        kv_full = {}
        kv_list = []
        for path in paths:
            kv_list += vault_client.secrets_tree_list(path, excluded)
        for kv in kv_list:
            kv_full[kv] = vault_client.read_secret(kv)
        values_count = {}
        for path in kv_full:
            for key in kv_full[path]:
                if kv_full[path][key] not in values_count:
                    values_count[kv_full[path][key]] = [path + ":" + key]
                else:
                    values_count[kv_full[path][key]].append(path + ":" + key)

        grouped_duplicates = {}
        dup_counter = 0
        for elem in values_count:
            if len(values_count[elem]) > 1:
                grouped_duplicates[dup_counter] = values_count[elem]
                dup_counter += 1
        self.logger.info(json.dumps(grouped_duplicates, indent=4))
        return grouped_duplicates

        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to look for duplicates
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        
Method running the count function of KV module
Method running the count function of KV module
def kv_find_duplicates(self, vault_addr, vault_token, paths, excluded=[]):
        self.logger.debug("KV find duplicates starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        kv_full = {}
        kv_list = []
        for path in paths:
            kv_list += vault_client.secrets_tree_list(path, excluded)
        for kv in kv_list:
            kv_full[kv] = vault_client.read_secret(kv)
        values_count = {}
        for path in kv_full:
            for key in kv_full[path]:
                if kv_full[path][key] not in values_count:
                    values_count[kv_full[path][key]] = [path + ":" + key]
                else:
                    values_count[kv_full[path][key]].append(path + ":" + key)
        grouped_duplicates = {}
        dup_counter = 0
        for elem in values_count:
            if len(values_count[elem]) > 1:
                grouped_duplicates[dup_counter] = values_count[elem]
                dup_counter += 1
        self.logger.info(json.dumps(grouped_duplicates, indent=4))
        return grouped_duplicates
def kv_find_duplicates ( self , vault_addr , vault_token , paths , excluded = [ ] ) : self . logger . debug ( "KV find duplicates starting" ) vault_client = self . connect_to_vault ( vault_addr , vault_token ) kv_full = { } kv_list = [ ] for path in paths : kv_list += vault_client . secrets_tree_list ( path , excluded ) for kv in kv_list : kv_full [ kv ] = vault_client . read_secret ( kv ) values_count = { } for path in kv_full : for key in kv_full [ path ] : if kv_full [ path ] [ key ] not in values_count : values_count [ kv_full [ path ] [ key ] ] = [ path + ":" + key ] else : values_count [ kv_full [ path ] [ key ] ] . append ( path + ":" + key ) grouped_duplicates = { } dup_counter = 0 for elem in values_count : if len ( values_count [ elem ] ) > 1 : grouped_duplicates [ dup_counter ] = values_count [ elem ] dup_counter += 1 self . logger . info ( json . dumps ( grouped_duplicates , indent = 4 ) ) return grouped_duplicates
Method running the count function of KV module
Method running the count function of KV module
"""
        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to look for duplicates
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        """
None
self
vault_addr
Vault instance URL
Vault instance URL
vault_token
None
paths
Paths to look for duplicates
Paths to look for duplicates
excluded
Paths to exclude from count
Paths to exclude from count