Skip to content

Commit 1f0106d

Browse files
committed
feat: per-phase output summary in log drawer with file/line counts
- RunWorkflowPhase now logs a [SUMMARY] line after each phase completes, counting output files and non-empty lines for every module. - Added missing phase key entries to GetPhaseFiles so js-endpoints, katana, xss-detection, github-scan, js-analysis now produce accurate summaries. - Log drawer now shows at minimum: start message, summary with output counts, and completion status for every phase that ran.
1 parent 060f867 commit 1f0106d

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

internal/utils/discord.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func GetPhaseFiles(phaseName, domain string) []string {
218218
files = []string{
219219
filepath.Join(resultsDir, domain, "vulnerabilities", "kxss-results.txt"),
220220
}
221-
case "js", "jsscan":
221+
case "js", "jsscan", "js-analysis":
222222
jsDir := filepath.Join(resultsDir, domain, "vulnerabilities", "js")
223223
if matches, err := filepath.Glob(filepath.Join(jsDir, "*.txt")); err == nil {
224224
for _, m := range matches {
@@ -227,6 +227,23 @@ func GetPhaseFiles(phaseName, domain string) []string {
227227
}
228228
}
229229
}
230+
case "js-endpoints":
231+
jsDir := filepath.Join(resultsDir, domain, "vulnerabilities", "js")
232+
files = []string{
233+
filepath.Join(jsDir, "js-urls.txt"),
234+
filepath.Join(resultsDir, domain, "vulnerabilities", "js-endpoints-results.txt"),
235+
}
236+
case "katana":
237+
urlsDir := filepath.Join(resultsDir, domain, "urls")
238+
files = []string{
239+
filepath.Join(urlsDir, "katana-urls.json"),
240+
filepath.Join(urlsDir, "all-urls.txt"),
241+
}
242+
case "xss-detection":
243+
files = []string{
244+
filepath.Join(resultsDir, domain, "vulnerabilities", "kxss-results.txt"),
245+
filepath.Join(resultsDir, domain, "vulnerabilities", "dalfox-results.txt"),
246+
}
230247
case "cnames":
231248
rootDomain := domain
232249
parts := strings.Split(domain, ".")
@@ -334,7 +351,7 @@ func GetPhaseFiles(phaseName, domain string) []string {
334351
if matches, err := filepath.Glob(filepath.Join(s3Dir, "*", "scan-results.txt")); err == nil {
335352
files = append(files, matches...)
336353
}
337-
case "githubscan":
354+
case "githubscan", "github-scan":
338355
files = []string{
339356
filepath.Join(resultsDir, "github", "orgs", domain, "secrets.json"),
340357
filepath.Join(resultsDir, "github", "orgs", domain, "secrets_table.txt"),

internal/utils/workflow.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package utils
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
7+
"strings"
68
"time"
79

810
"github.com/h0tak88r/AutoAR/internal/db"
@@ -122,6 +124,34 @@ func RunWorkflowPhase(phaseKey string, step, total int, description, target stri
122124
_ = db.AppendScanPhase(scanID, description, false)
123125
}
124126

127+
// Log a per-phase summary with input / output counts for the log drawer.
128+
if phaseKey != "" {
129+
phaseFiles := GetPhaseFiles(phaseKey, target)
130+
var totalLines int
131+
var foundFiles []string
132+
for _, f := range phaseFiles {
133+
if info, ferr := os.Stat(f); ferr == nil && info.Size() > 0 {
134+
// Count non-empty lines in output files.
135+
if data, rerr := os.ReadFile(f); rerr == nil {
136+
lines := 0
137+
for _, l := range strings.Split(string(data), "\n") {
138+
if strings.TrimSpace(l) != "" {
139+
lines++
140+
}
141+
}
142+
totalLines += lines
143+
foundFiles = append(foundFiles, filepath.Base(f))
144+
}
145+
}
146+
}
147+
parts := []string{fmt.Sprintf("Phase: %s", description)}
148+
parts = append(parts, fmt.Sprintf("Output: %d result file(s), %d total lines", len(foundFiles), totalLines))
149+
if len(foundFiles) > 0 {
150+
parts = append(parts, fmt.Sprintf("Files: %s", strings.Join(foundFiles, ", ")))
151+
}
152+
GetLogger().Infof("[SUMMARY] %s", strings.Join(parts, " | "))
153+
}
154+
125155
// Real-time file reporting
126156
if phaseKey != "" {
127157
phaseFiles := GetPhaseFiles(phaseKey, target)

0 commit comments

Comments
 (0)