Skip to content

Commit 45f5f10

Browse files
committed
fix: Fix issue with super match and exclude combined.
When not adding a include it would always catch every file and the exclude would be of no benefit. Signed-off-by: Matthias Glastra <[email protected]>
1 parent b24a8f1 commit 45f5f10

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

attestation/file/file.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"path/filepath"
2121

2222
"github.com/gobwas/glob"
23+
"github.com/gobwas/glob/match"
2324
"github.com/in-toto/go-witness/cryptoutil"
2425
"github.com/in-toto/go-witness/log"
2526
)
@@ -94,11 +95,16 @@ func RecordArtifacts(basePath string, baseArtifacts map[string]cryptoutil.Digest
9495
// if it is not equal to the existing artifact, return true, otherwise return false
9596
func shouldRecord(path string, artifact cryptoutil.DigestSet, baseArtifacts map[string]cryptoutil.DigestSet, includeGlob glob.Glob, excludeGlob glob.Glob) bool {
9697

98+
superInclude := false
99+
if _, ok := includeGlob.(match.Super); ok {
100+
superInclude = true
101+
}
102+
97103
includePath := true
98104
if excludeGlob != nil && excludeGlob.Match(path) {
99105
includePath = false
100106
}
101-
if includeGlob != nil && includeGlob.Match(path) {
107+
if !(superInclude && !includePath) && includeGlob != nil && includeGlob.Match(path) {
102108
includePath = true
103109
}
104110

0 commit comments

Comments
 (0)