vendor: github.com/moby/buildkit v0.13.0-rc2

full diff: https://github.com/moby/buildkit/compare/8e3fe35738c2...v0.13.0-rc2

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-02-24 14:38:34 +01:00
parent 545a5c97c6
commit e423a67f7b
89 changed files with 1427 additions and 575 deletions

View File

@ -2,8 +2,7 @@ package fsutil
import (
"os"
"path"
"runtime"
"path/filepath"
"sort"
"strings"
"syscall"
@ -28,21 +27,18 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
if v.parentDirs == nil {
v.parentDirs = make([]parent, 1, 10)
}
if runtime.GOOS == "windows" {
p = strings.Replace(p, "\\", "", -1)
}
if p != path.Clean(p) {
if p != filepath.Clean(p) {
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "unclean path"})
}
if path.IsAbs(p) {
if filepath.IsAbs(p) {
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "absolute path"})
}
dir := path.Dir(p)
base := path.Base(p)
dir := filepath.Dir(p)
base := filepath.Base(p)
if dir == "." {
dir = ""
}
if dir == ".." || strings.HasPrefix(p, "../") {
if dir == ".." || strings.HasPrefix(p, filepath.FromSlash("../")) {
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "escape check"})
}
@ -56,12 +52,12 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
}
if dir != v.parentDirs[len(v.parentDirs)-1].dir || v.parentDirs[i].last >= base {
return errors.Errorf("changes out of order: %q %q", p, path.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
return errors.Errorf("changes out of order: %q %q", p, filepath.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
}
v.parentDirs[i].last = base
if kind != ChangeKindDelete && fi.IsDir() {
v.parentDirs = append(v.parentDirs, parent{
dir: path.Join(dir, base),
dir: filepath.Join(dir, base),
last: "",
})
}
@ -76,7 +72,7 @@ func ComparePath(p1, p2 string) int {
switch {
case p1[i] == p2[i]:
continue
case p2[i] != '/' && p1[i] < p2[i] || p1[i] == '/':
case p2[i] != filepath.Separator && p1[i] < p2[i] || p1[i] == filepath.Separator:
return -1
default:
return 1