Skip to content

Commit

Permalink
trivy: improve filepath.Rel call when root is / in walker (#34604)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux authored Mar 3, 2025
1 parent 96cdcd7 commit a0caaff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/util/trivy/walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func (w *FSWalker) WalkDirFunc(root string, fn walker.WalkFunc, opt walker.Optio
}

if !strings.HasPrefix(filePath, "/") {
filePath = root + "/" + filePath
if strings.HasSuffix(root, "/") {
filePath = root + filePath
} else {
filePath = root + "/" + filePath
}
}

relPath, err := filepath.Rel(root, filePath)
Expand Down

0 comments on commit a0caaff

Please sign in to comment.