mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
guard rm temp dirs
This commit is contained in:
1 parent
0ed0489c2d
commit
c019a9d80d
2 files changed
+8
-3
No files matched your search
@@ -71,7 +71,10 @@ func newOwner() *Owner {
|
|||||||
signal.Notify(sigC, os.Interrupt, os.Interrupt)
|
signal.Notify(sigC, os.Interrupt, os.Interrupt)
|
||||||
go func() {
|
go func() {
|
||||||
<-sigC
|
<-sigC
|
||||||
owner.rmTmp()
|
if opts.Tmp {
|
||||||
|
owner.rmTmp()
|
||||||
|
}
|
||||||
|
os.Exit(ExitFailure)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// if running on local repo, just go right to it.
|
// if running on local repo, just go right to it.
|
||||||
@@ -203,6 +206,9 @@ func (owner *Owner) auditRepos() int {
|
|||||||
exitCode = ExitLeaks
|
exitCode = ExitLeaks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if opts.Tmp {
|
||||||
|
owner.rmTmp()
|
||||||
|
}
|
||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +224,6 @@ func (owner *Owner) failF(format string, args ...interface{}) {
|
|||||||
func (owner *Owner) rmTmp() {
|
func (owner *Owner) rmTmp() {
|
||||||
log.Printf("removing tmp gitleaks repo for %s\n", owner.name)
|
log.Printf("removing tmp gitleaks repo for %s\n", owner.name)
|
||||||
os.RemoveAll(owner.path)
|
os.RemoveAll(owner.path)
|
||||||
os.Exit(ExitFailure)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ownerType returns the owner type extracted from opts.
|
// ownerType returns the owner type extracted from opts.
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ func TestWriteReport(t *testing.T) {
|
|||||||
opts, _ = defaultOptions()
|
opts, _ = defaultOptions()
|
||||||
r := newRepo("fakerepo", "github.com", "")
|
r := newRepo("fakerepo", "github.com", "")
|
||||||
r.leaks = []Leak{*sampleLeak(), *sampleLeak()}
|
r.leaks = []Leak{*sampleLeak(), *sampleLeak()}
|
||||||
r.writeReport()
|
r.writeReport(r.leaks)
|
||||||
if _, err := os.Stat("fakerepo_leaks.json"); os.IsNotExist(err) {
|
if _, err := os.Stat("fakerepo_leaks.json"); os.IsNotExist(err) {
|
||||||
t.Error()
|
t.Error()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user