Skip to content

Commit

Permalink
fix: Fix issue with super match and exclude combined.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
matglas committed Apr 12, 2024
1 parent 81bff39 commit 5a5a99d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion attestation/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"path/filepath"

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

superInclude := false
if _, ok := includeGlob.(match.Super); ok {
superInclude = true
}

includePath := true
if excludeGlob != nil && excludeGlob.Match(path) {
includePath = false
}
if includeGlob != nil && includeGlob.Match(path) {
if !(superInclude && !includePath) && includeGlob != nil && includeGlob.Match(path) {
includePath = true
}

Expand Down

0 comments on commit 5a5a99d

Please sign in to comment.