fishi0x01 / vsh

vsh - HashiCorp Vault interactive shell and cli tool
MIT License
284 stars 12 forks source link

grep nothing working for paths #104

Open camAtGitHub opened 2 years ago

camAtGitHub commented 2 years ago

Hello,

its seems the grep command doesn't return results for paths that match. If you imagine a layout like this:

/secrets/servers/server1-statename/root_password
/secrets/servers/server1-statename/tech_password
/secrets/servers/server2-statename/root_password
/secrets/servers/server2-statename/tech_password

You can see why being able to grep for 'server1' or 'statename' may be important.

My real example where I'm searching for 'syncthing'.

https://consul.acme.com /secret/> cd docker/vars
https://consul.acme.com /secret/docker/vars/> ls
production/
tnd/
https://consul.acme.com /secret/docker/vars/> ls production/
syncthing
https://consul.acme.com /secret/docker/vars/> grep synct
https://consul.acme.com /secret/docker/vars/> grep --keys synct
https://consul.acme.com /secret/docker/vars/> grep --values synct
https://consul.acme.com /secret/docker/vars/> grep --regexp ^synct.*
https://consul.acme.com /secret/docker/vars/> grep --regexp ^gui.*
/secret/docker/vars/tnd/syncthing> gui_admin_password = superSecretPassword

Many Thanks

fishi0x01 commented 2 years ago

Thanks for reaching out! :)

This is expected behavior - from the docs:

grep recursively searches the given SEARCH substring in key and value pairs of given PATH

I.e., (like unix grep) vsh grep does not grep paths for patterns, but rather searches all files for that pattern in a given path. I think what you are looking for would be sth similar to unix find. I will mark this as a new feature request.