Skip to content

Commit

Permalink
fix stats
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Jan 15, 2024
1 parent c8b7d31 commit 68f886a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion v2/pkg/runner/enumerate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (r *Runner) EnumerateSingleDomainWithCtx(ctx context.Context, domain string
uniqueMap := make(map[string]resolve.HostEntry)
// Create a map to track sources for each host
sourceMap := make(map[string]map[string]struct{})
skippedCounts := make(map[string]int)
// Process the results in a separate goroutine
go func() {
for result := range passiveResults {
Expand All @@ -58,6 +59,7 @@ func (r *Runner) EnumerateSingleDomainWithCtx(ctx context.Context, domain string
case subscraping.Subdomain:
// Validate the subdomain found and remove wildcards from
if !strings.HasSuffix(result.Value, "."+domain) {
skippedCounts[result.Source]++
continue
}
subdomain := strings.ReplaceAll(strings.ToLower(result.Value), "*.", "")
Expand All @@ -77,6 +79,7 @@ func (r *Runner) EnumerateSingleDomainWithCtx(ctx context.Context, domain string
// Check if the subdomain is a duplicate. If not,
// send the subdomain for resolution.
if _, ok := uniqueMap[subdomain]; ok {
skippedCounts[result.Source]++
continue
}

Expand Down Expand Up @@ -164,7 +167,17 @@ func (r *Runner) EnumerateSingleDomainWithCtx(ctx context.Context, domain string

if r.options.Statistics {
gologger.Info().Msgf("Printing source statistics for %s", domain)
printStatistics(r.passiveAgent.GetStatistics())
statistics := r.passiveAgent.GetStatistics()
// This is a hack to remove the skipped count from the statistics
// as we don't want to show it in the statistics.
// TODO: Design a better way to do this.
for source, count := range skippedCounts {
if stat, ok := statistics[source]; ok {
stat.Results -= count
statistics[source] = stat
}
}
printStatistics(statistics)
}

return nil
Expand Down

0 comments on commit 68f886a

Please sign in to comment.