mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Change remaining audits to scan (#410)
This commit is contained in:
1 parent
6ca7a11d88
commit
fe69a17c9c
5 files changed
+15
-15
No files matched your search
+1
-1
@@ -104,5 +104,5 @@ func (g *Gitlab) Scan() {
|
|||||||
|
|
||||||
// ScanPR TODO not implemented
|
// ScanPR TODO not implemented
|
||||||
func (g *Gitlab) ScanPR() {
|
func (g *Gitlab) ScanPR() {
|
||||||
log.Error("AuditPR is not implemented in Gitlab host yet...")
|
log.Error("ScanPR is not implemented in Gitlab host yet...")
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ func main() {
|
|||||||
log.Warnf("%d leaks detected in staged changes", len(leaks))
|
log.Warnf("%d leaks detected in staged changes", len(leaks))
|
||||||
} else {
|
} else {
|
||||||
log.Warnf("%d leaks detected. %d commits scanned in %s", len(leaks),
|
log.Warnf("%d leaks detected. %d commits scanned in %s", len(leaks),
|
||||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
|
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
|
||||||
}
|
}
|
||||||
os.Exit(options.LeaksPresent)
|
os.Exit(options.LeaksPresent)
|
||||||
} else {
|
} else {
|
||||||
@@ -62,7 +62,7 @@ func main() {
|
|||||||
log.Infof("No leaks detected in staged changes")
|
log.Infof("No leaks detected in staged changes")
|
||||||
} else {
|
} else {
|
||||||
log.Infof("No leaks detected. %d commits scanned in %s",
|
log.Infof("No leaks detected. %d commits scanned in %s",
|
||||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
|
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
|
||||||
}
|
}
|
||||||
os.Exit(options.Success)
|
os.Exit(options.Success)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -63,8 +63,8 @@ type Leak struct {
|
|||||||
lookupHash string
|
lookupHash string
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuditTime is a type used to determine total scan time
|
// ScanTime is a type used to determine total scan time
|
||||||
type AuditTime int64
|
type ScanTime int64
|
||||||
|
|
||||||
// PatchTime is a type used to determine total patch time during an scan
|
// PatchTime is a type used to determine total patch time during an scan
|
||||||
type PatchTime int64
|
type PatchTime int64
|
||||||
@@ -89,7 +89,7 @@ type Metadata struct {
|
|||||||
|
|
||||||
RegexTime map[string]int64
|
RegexTime map[string]int64
|
||||||
Commits int
|
Commits int
|
||||||
AuditTime int64
|
ScanTime int64
|
||||||
patchTime int64
|
patchTime int64
|
||||||
cloneTime int64
|
cloneTime int64
|
||||||
}
|
}
|
||||||
@@ -214,8 +214,8 @@ func (manager *Manager) receiveMetadata() {
|
|||||||
switch ti := t.(type) {
|
switch ti := t.(type) {
|
||||||
case CloneTime:
|
case CloneTime:
|
||||||
manager.metadata.cloneTime += int64(ti)
|
manager.metadata.cloneTime += int64(ti)
|
||||||
case AuditTime:
|
case ScanTime:
|
||||||
manager.metadata.AuditTime += int64(ti)
|
manager.metadata.ScanTime += int64(ti)
|
||||||
case PatchTime:
|
case PatchTime:
|
||||||
manager.metadata.patchTime += int64(ti)
|
manager.metadata.patchTime += int64(ti)
|
||||||
case RegexTime:
|
case RegexTime:
|
||||||
@@ -243,7 +243,7 @@ func (manager *Manager) DebugOutput() {
|
|||||||
log.Debugf("-------------------------\n")
|
log.Debugf("-------------------------\n")
|
||||||
log.Debugf("| Times and Commit Counts|\n")
|
log.Debugf("| Times and Commit Counts|\n")
|
||||||
log.Debugf("-------------------------\n")
|
log.Debugf("-------------------------\n")
|
||||||
fmt.Println("totalAuditTime: ", durafmt.Parse(time.Duration(manager.metadata.AuditTime)*time.Nanosecond))
|
fmt.Println("totalScanTime: ", durafmt.Parse(time.Duration(manager.metadata.ScanTime)*time.Nanosecond))
|
||||||
fmt.Println("totalPatchTime: ", durafmt.Parse(time.Duration(manager.metadata.patchTime)*time.Nanosecond))
|
fmt.Println("totalPatchTime: ", durafmt.Parse(time.Duration(manager.metadata.patchTime)*time.Nanosecond))
|
||||||
fmt.Println("totalCloneTime: ", durafmt.Parse(time.Duration(manager.metadata.cloneTime)*time.Nanosecond))
|
fmt.Println("totalCloneTime: ", durafmt.Parse(time.Duration(manager.metadata.cloneTime)*time.Nanosecond))
|
||||||
fmt.Println("totalCommits: ", manager.metadata.Commits)
|
fmt.Println("totalCommits: ", manager.metadata.Commits)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func TestSendReceiveMeta(t *testing.T) {
|
|||||||
m, _ := NewManager(opts, cfg)
|
m, _ := NewManager(opts, cfg)
|
||||||
|
|
||||||
for i := 0; i < test.iterations; i++ {
|
for i := 0; i < test.iterations; i++ {
|
||||||
m.RecordTime(AuditTime(test.scanTime))
|
m.RecordTime(ScanTime(test.scanTime))
|
||||||
m.RecordTime(PatchTime(test.patchTime))
|
m.RecordTime(PatchTime(test.patchTime))
|
||||||
m.RecordTime(CloneTime(test.cloneTime))
|
m.RecordTime(CloneTime(test.cloneTime))
|
||||||
m.RecordTime(RegexTime{
|
m.RecordTime(RegexTime{
|
||||||
@@ -82,9 +82,9 @@ func TestSendReceiveMeta(t *testing.T) {
|
|||||||
t.Errorf("clone time mismatch, got %d, wanted %d",
|
t.Errorf("clone time mismatch, got %d, wanted %d",
|
||||||
md.cloneTime, test.cloneTime*int64(test.iterations))
|
md.cloneTime, test.cloneTime*int64(test.iterations))
|
||||||
}
|
}
|
||||||
if md.AuditTime != test.scanTime*int64(test.iterations) {
|
if md.ScanTime != test.scanTime*int64(test.iterations) {
|
||||||
t.Errorf("scan time mismatch, got %d, wanted %d",
|
t.Errorf("scan time mismatch, got %d, wanted %d",
|
||||||
md.AuditTime, test.scanTime*int64(test.iterations))
|
md.ScanTime, test.scanTime*int64(test.iterations))
|
||||||
}
|
}
|
||||||
if md.patchTime != test.patchTime*int64(test.iterations) {
|
if md.patchTime != test.patchTime*int64(test.iterations) {
|
||||||
t.Errorf("clone time mismatch, got %d, wanted %d",
|
t.Errorf("clone time mismatch, got %d, wanted %d",
|
||||||
|
|||||||
+3
-3
@@ -155,7 +155,7 @@ func (repo *Repo) Scan() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
repo.Manager.RecordTime(manager.AuditTime(howLong(scanTimeStart)))
|
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||||
repo.Manager.IncrementCommits(cc)
|
repo.Manager.IncrementCommits(cc)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ func (repo *Repo) scanEmpty() error {
|
|||||||
scanType: uncommittedScan,
|
scanType: uncommittedScan,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
repo.Manager.RecordTime(manager.AuditTime(howLong(scanTimeStart)))
|
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ func (repo *Repo) scanUncommitted() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
repo.Manager.RecordTime(manager.AuditTime(howLong(scanTimeStart)))
|
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user