From b50c13ddf06e35cba1a320dd943e164debe90c57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jan 2026 03:41:21 +0000 Subject: [PATCH] chore(deps): bump github.com/bmatcuk/doublestar/v4 from 4.9.1 to 4.10.0 Bumps [github.com/bmatcuk/doublestar/v4](https://github.com/bmatcuk/doublestar) from 4.9.1 to 4.10.0. - [Release notes](https://github.com/bmatcuk/doublestar/releases) - [Commits](https://github.com/bmatcuk/doublestar/compare/v4.9.1...v4.10.0) --- updated-dependencies: - dependency-name: github.com/bmatcuk/doublestar/v4 dependency-version: 4.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../bmatcuk/doublestar/v4/.gitignore | 2 +- .../bmatcuk/doublestar/v4/README.md | 53 +++++++++++++++++++ .../github.com/bmatcuk/doublestar/v4/glob.go | 27 +++++++++- .../bmatcuk/doublestar/v4/globoptions.go | 34 +++++++++++- .../bmatcuk/doublestar/v4/globwalk.go | 27 +++++++++- .../github.com/bmatcuk/doublestar/v4/utils.go | 23 ++++---- .../bmatcuk/doublestar/v4/utils_unix.go | 19 +++++++ .../bmatcuk/doublestar/v4/utils_windows.go | 43 +++++++++++++++ .../bmatcuk/doublestar/v4/validate.go | 2 - vendor/modules.txt | 2 +- 12 files changed, 219 insertions(+), 19 deletions(-) create mode 100644 vendor/github.com/bmatcuk/doublestar/v4/utils_unix.go create mode 100644 vendor/github.com/bmatcuk/doublestar/v4/utils_windows.go diff --git a/go.mod b/go.mod index 207e5b7f3..a0a6b4171 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24.0 toolchain go1.24.1 require ( - github.com/bmatcuk/doublestar/v4 v4.9.1 + github.com/bmatcuk/doublestar/v4 v4.10.0 github.com/go-git/go-git/v5 v5.16.3 github.com/hashicorp/go-retryablehttp v0.7.8 github.com/iancoleman/strcase v0.3.0 diff --git a/go.sum b/go.sum index 3e1dcbd46..e75f47b82 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= -github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs= +github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= diff --git a/vendor/github.com/bmatcuk/doublestar/v4/.gitignore b/vendor/github.com/bmatcuk/doublestar/v4/.gitignore index af212ecc2..f2d8e6b8b 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/.gitignore +++ b/vendor/github.com/bmatcuk/doublestar/v4/.gitignore @@ -29,4 +29,4 @@ _testmain.go *.prof # test directory -test/ +testdata/ diff --git a/vendor/github.com/bmatcuk/doublestar/v4/README.md b/vendor/github.com/bmatcuk/doublestar/v4/README.md index e4d1941e3..57d18b0e5 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/README.md +++ b/vendor/github.com/bmatcuk/doublestar/v4/README.md @@ -193,6 +193,27 @@ symlink to a directory. However, from this same example, a pattern such as Note: if combined with the WithFilesOnly option, symlinks to directories _will_ be included in the result since no attempt is made to follow the symlink. +```go +WithNoHidden() +``` + +If passed, doublestar will not match hidden files and directories (those +starting with a dot) when using wildcards. This follows traditional shell glob +behavior where `*` or a `?` at the start will not match dotfiles by default. + +Hidden files can still be matched by explicitly including them in the pattern. +For example, `.*` will match hidden files, and `.config/**` will match files +inside the .config directory. + +The rule is: + - For `**`: do not descend into hidden directories + - For `*` or a pattern starting with `?`: do not match dotfiles or + directories + +On Windows, doublestar will check the file attributes and avoid hidden files +and directories this way, instead of matching the filename. Therefore, any +pattern with a `*` or `?` could potentially match a hidden file/directory. + ### Glob ```go @@ -391,6 +412,38 @@ Class | Meaning `[^class]` | matches any single character which does *not* match the class `[!class]` | same as `^`: negates the class +#### Globs Are Not Regular Expressions + +Occasionally I get bug reports that some regular-expression-style syntax +doesn't work, or feature requests to add some regular-expression-inspired +syntax. Globs are not regular expressions. However, if globs are not +sufficiently expressive for your filtering needs, I recommend a two stage +approach using `GlobWalk`. Something like the following will get you started: + +```go +var matches []string +err := doublestar.GlobWalk(fsys, pattern, func(p string, d fs.DirEntry) error { + if (customFilter(p, d)) { + matches = append(matches, p) + } else if (d.isDir()) { + return doublestar.SkipDir + } + return nil +}) +return matches, err +``` + +In this example, `pattern` should be a glob that does a first pass at fetching +the files you might be interested in; `customFilter` is a function that does a +second pass. This second pass could be anything, including regular expressions. +Try to fashion a `pattern` that reduces the number of files you need to +consider in your second pass `customFilter`. + +One final note: empty alternatives can be used to build some more complicated +globs. For example, `some{thing,}` will match both "something" and "some". +Alternatives can also be nested, like `some{thing{new,},}`, which would match +"somethingnew", "something", and "some". + ## Performance ``` diff --git a/vendor/github.com/bmatcuk/doublestar/v4/glob.go b/vendor/github.com/bmatcuk/doublestar/v4/glob.go index 3471bea78..f3ef03920 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/glob.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/glob.go @@ -158,7 +158,7 @@ func (g *glob) globAlts(fsys fs.FS, pattern string, openingIdx, closingIdx int, nextIdx += patIdx } - alt := buildAlt(d, pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) + alt := buildAlt(escapeMeta(d), pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) matches, err = g.doGlob(fsys, alt, matches, firstSegment, beforeMeta) if err != nil { return @@ -223,8 +223,21 @@ func (g *glob) globDir(fsys fs.FS, dir, pattern string, matches []string, canMat } var matched bool + checkForHidden := g.noHidden && couldUnintentionallyMatchHidden(pattern) for _, info := range dirs { name := info.Name() + + // Skip hidden files when noHidden is set + if checkForHidden { + isHidden, err := isHiddenPath(name, info) + if e = g.forwardErrIfFailOnIOErrors(err); e != nil { + return + } + if isHidden { + continue + } + } + matched, e = matchWithSeparator(pattern, name, '/', false, g.caseInsensitive) if e != nil { return @@ -268,6 +281,18 @@ func (g *glob) globDoubleStar(fsys fs.FS, dir string, matches []string, canMatch for _, info := range dirs { name := info.Name() + + // Skip hidden files/directories when noHidden is set + if g.noHidden { + isHidden, err := isHiddenPath(name, info) + if err = g.forwardErrIfFailOnIOErrors(err); err != nil { + return nil, err + } + if isHidden { + continue + } + } + isDir, err := g.isDir(fsys, dir, name, info) if err != nil { return nil, err diff --git a/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go b/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go index 629835602..07c2bb816 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/globoptions.go @@ -4,11 +4,12 @@ import "strings" // glob is an internal type to store options during globbing. type glob struct { - caseInsensitive bool + caseInsensitive bool failOnIOErrors bool failOnPatternNotExist bool filesOnly bool noFollow bool + noHidden bool } // GlobOption represents a setting that can be passed to Glob, GlobWalk, and @@ -90,6 +91,30 @@ func WithNoFollow() GlobOption { } } +// WithNoHidden is an option that can be passed to Glob, GlobWalk, or +// FilepathGlob. If passed, doublestar will not match hidden files and +// directories (those starting with a dot) when using wildcards. This follows +// traditional shell glob behavior where `*` or a `?` at the start will not +// match dotfiles by default. +// +// Hidden files can still be matched by explicitly including them in the +// pattern. For example, `.*` will match hidden files, and `.config/**` will +// match files inside the .config directory. +// +// The rule is: +// - For `**`: do not descend into hidden directories +// - For `*` or a pattern starting with `?`: do not match dotfiles or +// directories +// +// On Windows, doublestar will check the file attributes and avoid hidden files +// and directories this way, instead of matching the filename. Therefore, any +// pattern with a `*` or `?` could potentially match a hidden file/directory. +func WithNoHidden() GlobOption { + return func(g *glob) { + g.noHidden = true + } +} + // forwardErrIfFailOnIOErrors is used to wrap the return values of I/O // functions. When failOnIOErrors is enabled, it will return err; otherwise, it // always returns nil. @@ -148,6 +173,13 @@ func (g *glob) GoString() string { b.WriteString("WithNoFollow") hasOpts = true } + if g.noHidden { + if hasOpts { + b.WriteString(", ") + } + b.WriteString("WithNoHidden") + hasOpts = true + } if !hasOpts { b.WriteString("nil") diff --git a/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go b/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go index 16601b76a..9516cefdd 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/globwalk.go @@ -205,7 +205,7 @@ func (g *glob) doGlobAltsWalk(fsys fs.FS, d, pattern string, startIdx, openingId nextIdx += patIdx } - alt := buildAlt(d, pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) + alt := buildAlt(escapeMeta(d), pattern, startIdx, openingIdx, patIdx, nextIdx, afterIdx) err = g.doGlobWalk(fsys, alt, firstSegment, beforeMeta, func(p string, d fs.DirEntry) error { // insertion sort, ignoring dups insertIdx := matchesLen @@ -287,8 +287,21 @@ func (g *glob) globDirWalk(fsys fs.FS, dir, pattern string, canMatchFiles, befor } var matched bool + checkForHidden := g.noHidden && couldUnintentionallyMatchHidden(pattern) for _, info := range dirs { name := info.Name() + + // Skip hidden files when noHidden is set + if checkForHidden { + isHidden, err := isHiddenPath(name, info) + if e = g.forwardErrIfFailOnIOErrors(err); e != nil { + return + } + if isHidden { + continue + } + } + matched, e = matchWithSeparator(pattern, name, '/', false, g.caseInsensitive) if e != nil { return @@ -335,6 +348,18 @@ func (g *glob) globDoubleStarWalk(fsys fs.FS, dir string, canMatchFiles bool, fn for _, info := range dirs { name := info.Name() + + // Skip hidden files/directories when noHidden is set + if g.noHidden { + isHidden, err := isHiddenPath(name, info) + if e = g.forwardErrIfFailOnIOErrors(err); e != nil { + return + } + if isHidden { + continue + } + } + isDir, err := g.isDir(fsys, dir, name, info) if err != nil { return err diff --git a/vendor/github.com/bmatcuk/doublestar/v4/utils.go b/vendor/github.com/bmatcuk/doublestar/v4/utils.go index 7831e5c3d..498c0441d 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/utils.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/utils.go @@ -14,16 +14,16 @@ import ( // The second string is everything after that slash. For example, given the // pattern: // -// ../../path/to/meta*/** -// ^----------- split here +// ../../path/to/meta*/** +// ^----------- split here // // SplitPattern returns "../../path/to" and "meta*/**". This is useful for // initializing os.DirFS() to call Glob() because Glob() will silently fail if // your pattern includes `/./` or `/../`. For example: // -// base, pattern := SplitPattern("../../path/to/meta*/**") -// fsys := os.DirFS(base) -// matches, err := Glob(fsys, pattern) +// base, pattern := SplitPattern("../../path/to/meta*/**") +// fsys := os.DirFS(base) +// matches, err := Glob(fsys, pattern) // // If SplitPattern cannot find somewhere to split the pattern (for example, // `meta*/**`), it will return "." and the unaltered pattern (`meta*/**` in @@ -35,7 +35,6 @@ import ( // Of course, it is your responsibility to decide if the returned base path is // "safe" in the context of your application. Perhaps you could use Match() to // validate against a list of approved base directories? -// func SplitPattern(p string) (base, pattern string) { base = "." pattern = p @@ -85,7 +84,6 @@ func SplitPattern(p string) (base, pattern string) { // // Note: the returned error doublestar.ErrBadPattern is not equal to // filepath.ErrBadPattern. -// func FilepathGlob(pattern string, opts ...GlobOption) (matches []string, err error) { if pattern == "" { // special case to match filepath.Glob behavior @@ -152,9 +150,16 @@ func indexNextAlt(s string, allowEscaping bool) int { return -1 } -var metaReplacer = strings.NewReplacer("\\*", "*", "\\?", "?", "\\[", "[", "\\]", "]", "\\{", "{", "\\}", "}") +var escapeMetaReplacer = strings.NewReplacer("*", "\\*", "?", "\\?", "[", "\\[", "]", "\\]", "{", "\\{", "}", "\\}") + +// Escapes meta characters (*?[]{}) +func escapeMeta(path string) string { + return escapeMetaReplacer.Replace(path) +} + +var unescapeMetaReplacer = strings.NewReplacer("\\*", "*", "\\?", "?", "\\[", "[", "\\]", "]", "\\{", "{", "\\}", "}") // Unescapes meta characters (*?[]{}) func unescapeMeta(pattern string) string { - return metaReplacer.Replace(pattern) + return unescapeMetaReplacer.Replace(pattern) } diff --git a/vendor/github.com/bmatcuk/doublestar/v4/utils_unix.go b/vendor/github.com/bmatcuk/doublestar/v4/utils_unix.go new file mode 100644 index 000000000..343e55f83 --- /dev/null +++ b/vendor/github.com/bmatcuk/doublestar/v4/utils_unix.go @@ -0,0 +1,19 @@ +//go:build !windows + +package doublestar + +import ( + "io/fs" +) + +// Returns true if the pattern could "unintentionally" match hidden files/dirs. +// An unintentional pattern would use a meta character that could match +// anything. +func couldUnintentionallyMatchHidden(pattern string) bool { + return len(pattern) > 0 && (pattern[0] == '*' || pattern[0] == '?') +} + +// Returns true if the file is "hidden" +func isHiddenPath(filename string, _info fs.DirEntry) (bool, error) { + return filename[0] == '.', nil +} diff --git a/vendor/github.com/bmatcuk/doublestar/v4/utils_windows.go b/vendor/github.com/bmatcuk/doublestar/v4/utils_windows.go new file mode 100644 index 000000000..5c6a67caf --- /dev/null +++ b/vendor/github.com/bmatcuk/doublestar/v4/utils_windows.go @@ -0,0 +1,43 @@ +package doublestar + +import ( + "io/fs" + "syscall" +) + +// Returns true if the pattern could "unintentionally" match hidden files/dirs. +// An unintentional pattern would use a meta character that could match +// anything. +func couldUnintentionallyMatchHidden(pattern string) bool { + var c byte + inClass := false + l := len(pattern) + for i := 0; i < l; i++ { + c = pattern[i] + if !inClass && (c == '*' || c == '?') { + return true + } else if c == '[' { + inClass = true + } else if c == '\\' { + // skip next byte + i++ + } else if inClass && c == ']' { + inClass = false + } + } + return false +} + +// Returns true if the file is "hidden" +func isHiddenPath(_filename string, info fs.DirEntry) (bool, error) { + fileinfo, err := info.Info() + if err != nil { + return false, err + } + + if stat, ok := fileinfo.Sys().(*syscall.Win32FileAttributeData); ok { + return stat.FileAttributes&syscall.FILE_ATTRIBUTE_HIDDEN != 0, nil + } + + return false, nil +} diff --git a/vendor/github.com/bmatcuk/doublestar/v4/validate.go b/vendor/github.com/bmatcuk/doublestar/v4/validate.go index c689b9eba..312129e72 100644 --- a/vendor/github.com/bmatcuk/doublestar/v4/validate.go +++ b/vendor/github.com/bmatcuk/doublestar/v4/validate.go @@ -9,7 +9,6 @@ import "path/filepath" // you might want to validate it. // // ValidatePattern assumes your pattern uses '/' as the path separator. -// func ValidatePattern(s string) bool { return doValidatePattern(s, '/') } @@ -18,7 +17,6 @@ func ValidatePattern(s string) bool { // ValidatePattern if you would normally use Match() or Glob(). Use // ValidatePathPattern if you would normally use PathMatch(). Keep in mind, // Glob() requires '/' separators, even if your OS uses something else. -// func ValidatePathPattern(s string) bool { return doValidatePattern(s, filepath.Separator) } diff --git a/vendor/modules.txt b/vendor/modules.txt index ae7ddd8e6..493e82c12 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,7 +32,7 @@ github.com/ProtonMail/go-crypto/openpgp/packet github.com/ProtonMail/go-crypto/openpgp/s2k github.com/ProtonMail/go-crypto/openpgp/x25519 github.com/ProtonMail/go-crypto/openpgp/x448 -# github.com/bmatcuk/doublestar/v4 v4.9.1 +# github.com/bmatcuk/doublestar/v4 v4.10.0 ## explicit; go 1.16 github.com/bmatcuk/doublestar/v4 # github.com/clipperhouse/displaywidth v0.3.1