Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
remove head from git diff command, rename unstaged to staged (#1439)
Zachary Rice452734adc8f9
diff --git a/pkg/gitparse/gitparse.go b/pkg/gitparse/gitparse.goindex 2c5990772..4e74bd0f5 100644--- a/pkg/gitparse/gitparse.go+++ b/pkg/gitparse/gitparse.go@@ -140,10 +140,10 @@ func (c *Parser) RepoPath(ctx context.Context, source string, head string, abbrereturn c.executeCommand(ctx, cmd)}-// Unstaged parses the output of the `git diff` command for the `source` path.-func (c *Parser) Unstaged(ctx context.Context, source string) (chan Commit, error) {+// Staged parses the output of the `git diff` command for the `source` path.+func (c *Parser) Staged(ctx context.Context, source string) (chan Commit, error) {// Provide the --cached flag to diff to get the diff of the staged changes.- args := []string{"-C", source, "diff", "-p", "--cached", "--full-history", "--diff-filter=AM", "--date=format:%a %b %d %H:%M:%S %Y %z", "HEAD"}+ args := []string{"-C", source, "diff", "-p", "--cached", "--full-history", "--diff-filter=AM", "--date=format:%a %b %d %H:%M:%S %Y %z"}cmd := exec.Command("git", args...)diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.goindex 45045995f..f84dfafe0 100644--- a/pkg/sources/git/git.go+++ b/pkg/sources/git/git.go@@ -482,7 +482,7 @@ func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string,// Get the URL metadata for reporting (may be empty).urlMetadata := getSafeRemoteURL(repo, "origin")- commitChan, err := gitparse.NewParser().Unstaged(ctx, path)+ commitChan, err := gitparse.NewParser().Staged(ctx, path)if err != nil {return err}