mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
Make paths and fingerprints platform-agnostic (#1622)
* test: windows * fix: make paths platform-agnostic this change also fixes, or skips, windows failures
This commit is contained in:
1 parent
818e32f7a4
commit
c2afd56bbe
13 files changed
+535
-91
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/fatih/semgroup"
|
||||
|
||||
@@ -15,6 +16,8 @@ type ScanTarget struct {
|
||||
Symlink string
|
||||
}
|
||||
|
||||
var isWindows = runtime.GOOS == "windows"
|
||||
|
||||
func DirectoryTargets(source string, s *semgroup.Group, followSymlinks bool, shouldSkip func(string) bool) (<-chan ScanTarget, error) {
|
||||
paths := make(chan ScanTarget)
|
||||
s.Go(func() error {
|
||||
@@ -63,7 +66,10 @@ func DirectoryTargets(source string, s *semgroup.Group, followSymlinks bool, sho
|
||||
}
|
||||
|
||||
// TODO: Also run this check against the resolved symlink?
|
||||
skip := shouldSkip(path)
|
||||
skip := shouldSkip(path) ||
|
||||
// TODO: Remove this in v9.
|
||||
// This is an awkward hack to mitigate https://github.com/gitleaks/gitleaks/issues/1641.
|
||||
(isWindows && shouldSkip(filepath.ToSlash(path)))
|
||||
if fInfo.IsDir() {
|
||||
// Directory
|
||||
if skip {
|
||||
|
||||
Reference in new issue
Block a user