-
Notifications
You must be signed in to change notification settings - Fork 12
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
Unnecessary read of secret in rm
operation
#45
Comments
Thank you for the detailed Issue - I appreciate it 🙇 Your observation is absolutely correct, i.e., That being said, I absolutely agree with you that the ambivalence of a file being a node and a leaf at the same time can lead to unexpected results and needs to be fixed. I will have a look at your suggestion and see if I can remove the ACL I will try to submit a PR (in the hopefully near future). |
I created a new release with a fix for the Concerning logging: The logging situation is a mess right now. I will address those in a new issue which I will open tomorrow. I will refer to this thread. |
The tests look fine, but somehow I still got the error although it should be covered by I got $ vsh -v -c "ls secret/test"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
foo
foo/
$ vsh -v -c "ls secret/test/foo"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
bar
$ vsh -v -c "ls secret/test/foo/"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
bar
$ vsh -v -c "rm secret/test/foo"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
[INFO] rm.go:78 Removed secret/test/foo/bar
$ vsh -v -c "ls secret/test/foo"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
[ERROR] ls.go:62 %!!(MISSING)!(MISSING)w(*errors.errorString=&{Not a directory: secret/test/foo})
$ vsh -v -c "ls secret/test/"
[DEBUG] client.go:68 Cannot auto-discover mount backends: Token does not have list permission on sys/mounts
foo When I executed the $ vsh -v -c "ls secret/test/"
[DEBUG] client.go:83 Found KV backend 'secret/' with version '2'
foo
foo/
$ vsh -v -c "ls secret/test/foo"
[DEBUG] client.go:83 Found KV backend 'secret/' with version '2'
[ERROR] ls.go:62 %!!(MISSING)!(MISSING)w(*errors.errorString=&{Not a directory: secret/test/foo})
$ vsh -v -c "ls secret/test/foo/"
[DEBUG] client.go:83 Found KV backend 'secret/' with version '2'
bar The permission for the delete-user is this one. Adding # List all the mounted secrets engines
path "/sys/mounts" {
capabilities = ["read", "list"]
}
path "secret/*" {
capabilities = ["list", "delete"]
}
path "secret/metadata/*" {
capabilities = ["read", "list", "delete"]
} I am pretty sure list on the metadata path is not a valid operation for K/V v2 🤔 I can get results with Line 37 in 7da8422
|
Interesting. I will enhance the tests to properly show this behavior. |
I drafted a new PR #50 which contains a test that should do exactly the same as you mention above for a user without read permissions - however, the test seems to work properly. I am not sure how to reproduce the issue. Do you see something I am missing? Concerning |
Oh man! 🤦 I realized I had version 0.6.2 locally and that is where the weird error message format came from! Turns out I must have ran Now I get the new Thanks a lot for the fix and sorry for that 😞 ! For some reason, |
Coolio - glad it works 👍 For the sake of completion, I also added a test for Thx again for the effort of creating these detailed issue reports. I highly appreciate it 🙇 |
The problem with the version is that I install the module with |
Description
I was looking at the code of the tool, but it seems like a
read
is performed all the time to know if a secret is a node, a leaf or both invsh/client/type.go
Line 36 in a6721cc
This is unnecessary and will yield incorrect results in case the user does not have the permission to read the content of the secret.
version
I was using
v0.6.2
.Current behaviour
For instance, a user should be able to delete a secret without reading it. For now, the behaviour without read access is:
/secret/foo
and/secret/foo/bar
:vsh -v -c "rm /secret/foo"
[INFO] rm.go:78 Removed /secret/foo/bar
<-- This is not what you would expect to happen/secret/foo
and/secret/foo/bar
:vsh -v -c "rm /secret/foo/"
[INFO] rm.go:78 Removed /secret/foo/bar
/secret/foo
only:vsh -v -c "rm /secret/foo"
[ERROR] rm.go:67 Invalid path: /secret/foo
<-- This is not what you would expect to happen/secret/foo/bar
only:vsh -v -c "rm /secret/foo"
[INFO] rm.go:78 Removed /secret/foo/bar
<-- This is not what you would expect to happenExpected behaviour
I would expect the
rm
operation to only delete thefoo
secret when/secret/foo
is specified, and to deletebar
secret when/secret/foo/
is specified./secret/foo
and/secret/foo/bar
:vsh -c "rm /secret/foo"
[INFO] Removed /secret/foo
/secret/foo
and/secret/foo/bar
:vsh -c "rm /secret/foo/"
[INFO] Removed /secret/foo/bar
/secret/foo
only:vsh -c "rm /secret/foo/"
[ERROR] Invalid path: /secret/foo/
/secret/foo/bar
only:vsh -c "rm /secret/foo"
[ERROR] Invalid secret: /secret/foo
Suggestion
I think checking if the path ends with a
/
or not is enough to know if the user means a node or a leaf.Anyhow, if you need to know for other reasons if a secret is a node, leaf or both, looking at the result of the previous folder list output would give the information without reading the secret.
So with
/secret/foo/
or/secret/foo
specified, you would/secret/foo
./secret/
./secret/foo
and/secret/foo/
/secret/foo
: then it's a leaf/secret/foo/
: then it's a nodeAdditional information
Also, few nice things that would be helpful is to:
-v
to have feedback.-v INFO|WARN|ERROR|...
The text was updated successfully, but these errors were encountered: