mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-19 05:31:10 +02:00
parent
85de18f231
commit
aa6a19cfbd
@ -1,10 +1,14 @@
|
|||||||
package physical
|
package physical
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrRelativePath = errors.New("relative paths not supported")
|
||||||
|
)
|
||||||
|
|
||||||
// View represents a prefixed view of a physical backend
|
// View represents a prefixed view of a physical backend
|
||||||
type View struct {
|
type View struct {
|
||||||
backend Backend
|
backend Backend
|
||||||
@ -74,7 +78,7 @@ func (v *View) Delete(key string) error {
|
|||||||
// sanityCheck is used to perform a sanity check on a key
|
// sanityCheck is used to perform a sanity check on a key
|
||||||
func (v *View) sanityCheck(key string) error {
|
func (v *View) sanityCheck(key string) error {
|
||||||
if strings.Contains(key, "..") {
|
if strings.Contains(key, "..") {
|
||||||
return fmt.Errorf("key cannot be relative path")
|
return ErrRelativePath
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package vault
|
package vault
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/logical"
|
"github.com/hashicorp/vault/logical"
|
||||||
@ -20,6 +20,10 @@ type BarrierView struct {
|
|||||||
readonly bool
|
readonly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrRelativePath = errors.New("relative paths not supported")
|
||||||
|
)
|
||||||
|
|
||||||
// NewBarrierView takes an underlying security barrier and returns
|
// NewBarrierView takes an underlying security barrier and returns
|
||||||
// a view of it that can only operate with the given prefix.
|
// a view of it that can only operate with the given prefix.
|
||||||
func NewBarrierView(barrier BarrierStorage, prefix string) *BarrierView {
|
func NewBarrierView(barrier BarrierStorage, prefix string) *BarrierView {
|
||||||
@ -32,7 +36,7 @@ func NewBarrierView(barrier BarrierStorage, prefix string) *BarrierView {
|
|||||||
// sanityCheck is used to perform a sanity check on a key
|
// sanityCheck is used to perform a sanity check on a key
|
||||||
func (v *BarrierView) sanityCheck(key string) error {
|
func (v *BarrierView) sanityCheck(key string) error {
|
||||||
if strings.Contains(key, "..") {
|
if strings.Contains(key, "..") {
|
||||||
return fmt.Errorf("key cannot be relative path")
|
return ErrRelativePath
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,9 @@ func (c *Core) handleRequest(req *logical.Request) (retResp *logical.Response, r
|
|||||||
if errType != nil {
|
if errType != nil {
|
||||||
retErr = multierror.Append(retErr, errType)
|
retErr = multierror.Append(retErr, errType)
|
||||||
}
|
}
|
||||||
|
if ctErr == ErrInternalError {
|
||||||
|
return nil, auth, retErr
|
||||||
|
}
|
||||||
return logical.ErrorResponse(ctErr.Error()), auth, retErr
|
return logical.ErrorResponse(ctErr.Error()), auth, retErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user