fishi0x01 / vsh

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

Bug when deleting secret named identically to a path #29

Closed vikin91 closed 4 years ago

vikin91 commented 4 years ago

Affects version: 0.5.0, Mac

Here a scenario to reproduce:

https://vault.example.com/ /secret/apps/> ls
...
dev
dev/
...

# I want to remove `dev` but keep `dev/`
https://vault.example.com/ /secret/apps/> rm dev
Removed /secret/apps/dev/xxx/yyy
# BUG: `dev/` is being deleted - should delete `dev`

# try the same with context menu - selecting proper item with <tab>-key menu
https://vault.example.com/ /secret/apps/> rm dev
Removed /secret/apps/dev/xxx/yyy
# BUG: `dev/` is being deleted - should delete `dev`
fishi0x01 commented 4 years ago

Because of the reference in the PR, GH automatically closed the issue .. I have added some tests which confirmed the bug and implemented/merged a fix.

Re-opening this issue until you can confirm it works as you expect.

vikin91 commented 4 years ago

I will test this using a build from master.

Side note: I need to patch Makefile every time I build, because it results in errors on Mac. I will fix it in my PR, but here is how it looks like:

$ make cross-compile

rm ./build/* || true
mkdir -p ./build/
for GOOS in linux darwin; do \
      for GOARCH in 386 amd64; do \
        export GOOS=$GOOS; \
        export GOARCH=$GOARCH; \
        go build -ldflags "-X main.vshVersion=-n v0.5.0" -o build/vsh_${GOOS}_${GOARCH}; \
      done \
    done
# github.com/fishi0x01/vsh
usage: link [options] main.o
...

Note this part: go build -ldflags "-X main.vshVersion=-n v0.5.0" - the -n should not be there :)

Consider using VERSION := $(shell git describe --tags --always --dirty) for discovering git version in one line.

vikin91 commented 4 years ago

Okay, I can confirm that the original bug is fixed now! Thanks for the quick fix!