Skip to content

Commit fcc87b7

Browse files
h0tak88rclaude
andcommitted
fix(monitor): Discord 'Scan Finished' always reported 100 findings
RunScanInProcess passed a percent-complete flag (0 or 100, named 'progress') into SendScanNotification's findings-count parameter, so every completed scan's Discord notification said 'Result: 100 findings discovered' regardless of actual matches -- visibly wrong for e.g. the global nuclei scan that matched 0 hosts (UI correctly showed 0 rows / no parseable findings). This was previously silent: SendScanNotification's switch only handled event 'finish', not 'complete' (fixed earlier this session), so this notification never actually sent until that fix shipped -- which is what surfaced the wrong count now. Use the DB record's FilesUploaded (set via db.UpdateScanStats by the module, e.g. pipeline/global-nuclei match counts) instead, so the Discord count matches what the Scan Results page shows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9c13eaf commit fcc87b7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

internal/api/scan_runner.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ func RunScanInProcess(scanID, scanType, target string, fn func() error) {
179179
// Index artifacts written by the module.
180180
indexScanArtifacts(scanID, scanType, target)
181181

182-
progress := 0
183-
if status == "completed" {
184-
progress = 100
182+
// findingsCount comes from the DB row's files_uploaded (set by the module via
183+
// db.UpdateScanStats, e.g. pipeline/global-nuclei match counts) -- NOT a
184+
// percent-complete flag. A prior version passed a 0/100 "progress" value here,
185+
// so every completed scan reported "100 findings" regardless of real matches.
186+
findingsCount := 0
187+
if record != nil {
188+
findingsCount = record.FilesUploaded
185189
}
186190
ScanLogf(scanID, "[%s] scan %s in %s", scanType, status, completedAt.Sub(startedAt).Round(time.Second))
187-
utils.SendScanNotification("complete", scanID, target, scanType, status, progress)
191+
utils.SendScanNotification("complete", scanID, target, scanType, status, findingsCount)
188192
log.Printf("[runner] scan %s (%s/%s) %s in %s",
189193
scanID, scanType, target, status, completedAt.Sub(startedAt).Round(time.Second))
190194

0 commit comments

Comments
 (0)