mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
Scan files at latest commit (#348)
* Inspect files at latest commit Added option to scan files at latest commit * Files at latest commit test
This commit is contained in:
1 parent
dae5c142d7
commit
679f00dc9c
3 files changed
+20
-1
No files matched your search
@@ -243,6 +243,16 @@ func TestAudit(t *testing.T) {
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo five files at latest commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_files_at_latest_commit.json.got",
|
||||
FilesAtCommit: "latest",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo five at commit",
|
||||
opts: options.Options{
|
||||
|
||||
@@ -224,6 +224,15 @@ func (repo *Repo) Audit() error {
|
||||
if repo.Manager.Opts.Commit != "" {
|
||||
return inspectCommit(repo.Manager.Opts.Commit, repo, inspectCommitPatches)
|
||||
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||
if repo.Manager.Opts.FilesAtCommit == "latest" {
|
||||
// Getting the latest commit on the current branch
|
||||
// ... retrieving the branch being pointed by HEAD
|
||||
ref, err := repo.Repository.Head()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return inspectCommit(ref.Hash().String(), repo, inspectFilesAtCommit)
|
||||
}
|
||||
return inspectCommit(repo.Manager.Opts.FilesAtCommit, repo, inspectFilesAtCommit)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user