mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
Add bytes counter to scans (#876)
This commit is contained in:
parent
0c81cba918
commit
034ca4fb5b
2 changed files with 7 additions and 0 deletions
1
main.go
1
main.go
|
@ -288,6 +288,7 @@ func run(state overseer.State) {
|
|||
}
|
||||
}
|
||||
logrus.Debugf("scanned %d chunks", e.ChunksScanned())
|
||||
logrus.Debugf("scanned %d bytes", e.BytesScanned())
|
||||
|
||||
if *printAvgDetectorTime {
|
||||
printAverageDetectorTime(e)
|
||||
|
|
|
@ -27,6 +27,7 @@ type Engine struct {
|
|||
decoders []decoders.Decoder
|
||||
detectors map[bool][]detectors.Detector
|
||||
chunksScanned uint64
|
||||
bytesScanned uint64
|
||||
detectorAvgTime sync.Map
|
||||
sourcesWg sync.WaitGroup
|
||||
workersWg sync.WaitGroup
|
||||
|
@ -140,6 +141,10 @@ func (e *Engine) ChunksScanned() uint64 {
|
|||
return e.chunksScanned
|
||||
}
|
||||
|
||||
func (e *Engine) BytesScanned() uint64 {
|
||||
return e.bytesScanned
|
||||
}
|
||||
|
||||
func (e *Engine) DetectorAvgTime() map[string][]time.Duration {
|
||||
avgTime := map[string][]time.Duration{}
|
||||
e.detectorAvgTime.Range(func(k, v interface{}) bool {
|
||||
|
@ -163,6 +168,7 @@ func (e *Engine) DetectorAvgTime() map[string][]time.Duration {
|
|||
func (e *Engine) detectorWorker(ctx context.Context) {
|
||||
for originalChunk := range e.chunks {
|
||||
for chunk := range sources.Chunker(originalChunk) {
|
||||
atomic.AddUint64(&e.bytesScanned, uint64(len(chunk.Data)))
|
||||
fragStart, mdLine := fragmentFirstLine(chunk)
|
||||
for _, decoder := range e.decoders {
|
||||
var decoderType detectorspb.DecoderType
|
||||
|
|
Loading…
Reference in a new issue