Skip to content
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

Return 500 if existence check fails, not 400 #3173

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions physical/physical_view.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package physical

import (
"fmt"
"errors"
"strings"
)

var (
ErrRelativePath = errors.New("relative paths not supported")
)

// View represents a prefixed view of a physical backend
type View struct {
backend Backend
Expand Down Expand Up @@ -74,7 +78,7 @@ func (v *View) Delete(key string) error {
// sanityCheck is used to perform a sanity check on a key
func (v *View) sanityCheck(key string) error {
if strings.Contains(key, "..") {
return fmt.Errorf("key cannot be relative path")
return ErrRelativePath
}
return nil
}
Expand Down
8 changes: 6 additions & 2 deletions vault/barrier_view.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vault

import (
"fmt"
"errors"
"strings"

"github.com/hashicorp/vault/logical"
Expand All @@ -20,6 +20,10 @@ type BarrierView struct {
readonly bool
}

var (
ErrRelativePath = errors.New("relative paths not supported")
)

// NewBarrierView takes an underlying security barrier and returns
// a view of it that can only operate with the given prefix.
func NewBarrierView(barrier BarrierStorage, prefix string) *BarrierView {
Expand All @@ -32,7 +36,7 @@ func NewBarrierView(barrier BarrierStorage, prefix string) *BarrierView {
// sanityCheck is used to perform a sanity check on a key
func (v *BarrierView) sanityCheck(key string) error {
if strings.Contains(key, "..") {
return fmt.Errorf("key cannot be relative path")
return ErrRelativePath
}
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions vault/request_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ func (c *Core) handleRequest(req *logical.Request) (retResp *logical.Response, r
if errType != nil {
retErr = multierror.Append(retErr, errType)
}
if ctErr == ErrInternalError {
return nil, auth, retErr
}
return logical.ErrorResponse(ctErr.Error()), auth, retErr
}

Expand Down