backport of commit 425b1e333d008f37fe517ee3c886e8fe96c3e5ce (#23885)

Co-authored-by: Josh Black <raskchanky@gmail.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-10-27 12:42:18 -04:00 committed by GitHub
parent bc19a6d305
commit 435363ef2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

3
changelog/23872.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
storage/etcd: etcd should only return keys when calling List()
```

View File

@ -14,7 +14,7 @@ import (
"sync" "sync"
"time" "time"
metrics "github.com/armon/go-metrics" "github.com/armon/go-metrics"
log "github.com/hashicorp/go-hclog" log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-secure-stdlib/parseutil" "github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/go-secure-stdlib/strutil"
@ -238,7 +238,7 @@ func (c *EtcdBackend) List(ctx context.Context, prefix string) ([]string, error)
ctx, cancel := context.WithTimeout(context.Background(), c.requestTimeout) ctx, cancel := context.WithTimeout(context.Background(), c.requestTimeout)
defer cancel() defer cancel()
prefix = path.Join(c.path, prefix) + "/" prefix = path.Join(c.path, prefix) + "/"
resp, err := c.etcd.Get(ctx, prefix, clientv3.WithPrefix()) resp, err := c.etcd.Get(ctx, prefix, clientv3.WithPrefix(), clientv3.WithKeysOnly())
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -26,7 +26,7 @@ func TestEtcd3Backend(t *testing.T) {
"username": "root", "username": "root",
"password": "insecure", "password": "insecure",
// Syncing adverticed client urls should be disabled since docker port mapping confuses the client. // Syncing advertised client urls should be disabled since docker port mapping confuses the client.
"sync": "false", "sync": "false",
} }