Skip to content

Commit

Permalink
Add doublestar glob for postive patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanohoro committed Nov 3, 2023
1 parent 178e13f commit 082893c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion configs/go/fileshot/fileshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ files:
patterns:
positive:
- '/glob/to/your/files/*'
# negative
- '/superglob/to/your/files/**'
# negative # Does not support doublestar **
# - '/*/badfiles/*'
minsize: 1 # Limit minimum file size in bytes
maxsize: 999999999 # Limit max file size in bytes
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
)

require (
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
Expand Down
4 changes: 2 additions & 2 deletions src/go/cmd/strelka-fileshot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/target/strelka/src/go/pkg/rpc"
"github.com/target/strelka/src/go/pkg/structs"

"github.com/bmatcuk/doublestar/v4"
"github.com/gabriel-vasile/mimetype"

"google.golang.org/grpc"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -478,7 +478,7 @@ func getFilePaths(conf structs.FileShot, verbose *bool, hashes []string) []strin
}

// Expand the pattern to a list of matching file paths
match, err := filepath.Glob(p)
match, err := doublestar.FilepathGlob(p)
if err != nil {
log.Printf("failed to glob pattern %s: %v", p, err)
continue
Expand Down

0 comments on commit 082893c

Please sign in to comment.