github.com/moby/docker@v26.1.3+incompatible/internal/safepath/errors.go (about) 1 package safepath 2 3 // ErrNotAccessible is returned by Join when the resulting path doesn't exist, 4 // is not accessible, or any of the path components was replaced with a symlink 5 // during the path traversal. 6 type ErrNotAccessible struct { 7 Path string 8 Cause error 9 } 10 11 func (*ErrNotAccessible) NotFound() {} 12 13 func (e *ErrNotAccessible) Unwrap() error { 14 return e.Cause 15 } 16 17 func (e *ErrNotAccessible) Error() string { 18 msg := "cannot access path " + e.Path 19 if e.Cause != nil { 20 msg += ": " + e.Cause.Error() 21 } 22 return msg 23 } 24 25 // ErrEscapesBase is returned by Join when the resulting concatenation would 26 // point outside of the specified base directory. 27 type ErrEscapesBase struct { 28 Base, Subpath string 29 } 30 31 func (*ErrEscapesBase) InvalidParameter() {} 32 33 func (e *ErrEscapesBase) Error() string { 34 msg := "path concatenation escapes the base directory" 35 if e.Base != "" { 36 msg += ", base: " + e.Base 37 } 38 if e.Subpath != "" { 39 msg += ", subpath: " + e.Subpath 40 } 41 return msg 42 }