Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
git worktree scanning fix for #827 (#1315)
Brendan Shaklovitzfad34d4dc6ad
diff --git a/go.mod b/go.modindex 834e772d9..bd52c3a75 100644--- a/go.mod+++ b/go.mod@@ -4,10 +4,6 @@ go 1.20replace github.com/jpillora/overseer => github.com/trufflesecurity/overseer v1.1.7-custom5-replace github.com/zricethezav/gitleaks/v8 => github.com/trufflesecurity/gitleaks/v8 v8.6.1-custom10--replace github.com/gitleaks/go-gitdiff => github.com/trufflesecurity/go-gitdiff v0.7.6-zombies2-require (cloud.google.com/go/secretmanager v1.10.0cloud.google.com/go/storage v1.30.1diff --git a/pkg/engine/git.go b/pkg/engine/git.goindex 410d1e7d7..9d7ecbb6e 100644--- a/pkg/engine/git.go+++ b/pkg/engine/git.go@@ -22,7 +22,12 @@ func (e *Engine) ScanGit(ctx context.Context, c sources.GitConfig) error {git.ScanOptionLogOptions(logOptions),}- repo, err := gogit.PlainOpenWithOptions(c.RepoPath, &gogit.PlainOpenOptions{DetectDotGit: true})+ options := &gogit.PlainOpenOptions{+ DetectDotGit: true,+ EnableDotGitCommonDir: true,+ }++ repo, err := gogit.PlainOpenWithOptions(c.RepoPath, options)if err != nil {return fmt.Errorf("could not open repo: %s: %w", c.RepoPath, err)}diff --git a/pkg/output/legacy_json.go b/pkg/output/legacy_json.goindex 2fc9f5005..53f5865b3 100644--- a/pkg/output/legacy_json.go+++ b/pkg/output/legacy_json.go@@ -66,9 +66,14 @@ func ConvertToLegacyJSON(r *detectors.ResultWithMetadata, repoPath string) (*Legreturn nil, fmt.Errorf("legacy JSON output can not be used with this source: %s", r.SourceName)}- // The repo will be needed to gather info needed for the legacy output that isn't included in the new- // output format.- repo, err := gogit.PlainOpenWithOptions(repoPath, &gogit.PlainOpenOptions{DetectDotGit: true})+ options := &gogit.PlainOpenOptions{+ DetectDotGit: true,+ EnableDotGitCommonDir: true,+ }++ // The repo will be needed to gather info needed for the legacy output that+ // isn't included in the new output format.+ repo, err := gogit.PlainOpenWithOptions(repoPath, options)if err != nil {return nil, fmt.Errorf("could not open repo %q: %w", repoPath, err)}diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.goindex a380258e2..541b0cf80 100644--- a/pkg/sources/git/git.go+++ b/pkg/sources/git/git.go@@ -227,7 +227,11 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err}func RepoFromPath(path string) (*git.Repository, error) {- return git.PlainOpen(path)+ options := &git.PlainOpenOptions{+ DetectDotGit: true,+ EnableDotGitCommonDir: true,+ }+ return git.PlainOpenWithOptions(path, options)}func CleanOnError(err *error, path string) {@@ -298,7 +302,11 @@ func CloneRepo(ctx context.Context, userInfo *url.Userinfo, gitUrl string, argsreturn "", nil, fmt.Errorf("could not clone repo: %s, %w", safeUrl, err)}- repo, err := git.PlainOpen(clonePath)+ options := &git.PlainOpenOptions{+ DetectDotGit: true,+ EnableDotGitCommonDir: true,+ }+ repo, err := git.PlainOpenWithOptions(clonePath, options)if err != nil {return "", nil, fmt.Errorf("could not open cloned repo: %w", err)}