Reject requests read and write requests to cubbyhole with an empty path (#8971)

* Reject requests read and write requests to cubbyhole with an empty path
This commit is contained in:
Scott Miller 2020-05-11 14:15:36 -05:00 committed by GitHub
parent 16cc804086
commit c3b6db2f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -111,6 +111,10 @@ func (b *CubbyholeBackend) handleRead(ctx context.Context, req *logical.Request,
path := data.Get("path").(string)
if path == "" {
return nil, fmt.Errorf("missing path")
}
// Read the path
out, err := req.Storage.Get(ctx, req.ClientToken+"/"+path)
if err != nil {
@ -147,6 +151,10 @@ func (b *CubbyholeBackend) handleWrite(ctx context.Context, req *logical.Request
path := data.Get("path").(string)
if path == "" {
return nil, fmt.Errorf("missing path")
}
// JSON encode the data
buf, err := json.Marshal(req.Data)
if err != nil {