Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags to recursively list secrets for KV Engine. #6463

Closed
wants to merge 15 commits into from

Conversation

clickyotomy
Copy link

Adds `-recursive', `-depth', `-filter' and `-concurrent' flags to
vault CLI's `kv list' subcommand.

Description of the flags:
    * recursive     Recursively list data for a given path.
    * depth         Specifies the depth for recursive listing.
    * filter        Specifies a regular expression for filtering paths.
    * concurrent    Specifies the number of concurrent recursions to run.

Reference: #5275.

Adds `-recursive', `-depth', `-filter' and `-concurrent' flags to the
vault CLI's `kv list' subcommand.

Description of the flags:
    * recursive     Recursively list data for a given path.
    * depth         Specifies the depth for recursive listing.
    * filter        Specifies a regular expression for filtering paths.
    * concurrent    Specifies the number of concurrent recursions to run.

Reference: hashicorp#5275.
@jefferai jefferai changed the title [vault-cli]: Add flags to recursively list secrets for KV Engine. Add flags to recursively list secrets for KV Engine. Mar 23, 2019
@clickyotomy
Copy link
Author

👋 - Not sure why TEST_COMMAND='travis_wait 75 make testracetravis' fails. Ran make testrace locally and it passed.

@clickyotomy
Copy link
Author

@jefferai - Can you please review?

@jefferai
Copy link
Member

We need to discuss internally whether or not we want this functionality and if so whether it should be client or server side.

@v6
Copy link
Contributor

v6 commented Apr 9, 2019

Thanks for considering it guys

@jcrowthe
Copy link
Contributor

@jefferai Regarding your last comment about serverside or clientside.

This feature would be ideal for other projects that integrate with Vault. Currently in order to get a picture of what keys exist you must recursively traverse the entire tree LISTing on each "folder". While it could be done clientside, it would also be costly for larger vault installations. While doing this serverside would still incur a cost, it is in-memory which would be an orders-of-magnitude smaller cost considering the TCP/TLS connections that would need to be established per path.

In the end, both client- and server-side have use cases, but client-side has the ability to be done today through the API. Given there are several tickets regarding this feature, it appears an official server-side implementation would be a welcome addition to the project. Thoughts?

@clickyotomy
Copy link
Author

Hello! Any update on this?

@catsby
Copy link
Contributor

catsby commented Dec 12, 2019

A similar PR was opened in the KV repo, but subsequently closed:

The reasoning for closing involves possible acl exploitation. Do you feel like that's a possible issue with this implementation?

@michelvocks
Copy link
Contributor

hashicorp/vault-plugin-secrets-kv#38 ACL exploit was possible because the implementation happened on the server-side. This PR implements the functionality via the client-side where an ACL exploit is not possible.

I personally think that both hashicorp/vault-plugin-secrets-kv#38 and this PR are not the right way to implement this feature due to the fact that current LIST operations for our storage backends are not optimized to do a recursive list. I agree with @jcrowthe that this feature is much needed but due to complexity reasons, this should be taken over by an HashiCorp employee. @jefferai @briankassouf It would be great to get your input here.

@mcouthon
Copy link

mcouthon commented May 2, 2021

Is there a semi-canonical way to do this somewhere, until an official solution is implemented? Maybe some reference implementation?

@krilor
Copy link

krilor commented May 10, 2021

Is there a semi-canonical way to do this somewhere, until an official solution is implemented? Maybe some reference implementation?

I'm not sure that it is "semi-canonical", but I'm using this little bash script:

#!/bin/bash
# Usage: vault-rlist.sh secret/some/path/
# Trailing slash is mandatory!

walk() {
    wd=$1

    if [ "${wd: -1}" != "/" ]; then
        echo $wd
        exit
    fi

    vault kv list -format=json $wd | jq -r '.[]' | xargs -r -I % bash -c "walk $wd%"
}
export -f walk
walk $1

If I want to hide errors, I do vault-rlist.sh secret/ 2>/dev/null

@heatherezell
Copy link
Contributor

Hi folks! I'm going to go ahead and close this PR - please feel free to re-open it (and rebase off of main) if the questions can be answered and you'd like to continue working on it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants