fix: route warning messages to stderr instead of stdout#7331
fix: route warning messages to stderr instead of stdout#7331jyoti369 wants to merge 1 commit intoprojectdiscovery:devfrom
Conversation
…o stderr Warning messages using Logger.Print() with manually formatted [WRN] labels were being written to stdout via gologger's LevelSilent routing, which corrupts JSON output when using -j flag. Changed all such instances to use Logger.Warning() which: - Routes output to stderr via gologger's LevelWarning - Automatically adds the [WRN] label prefix - Prevents warning text from mixing into structured JSON output Files changed: - internal/runner/runner.go: 4 instances (rate limit deprecation, concurrency warning, no DAST templates, unsigned templates) - pkg/catalog/disk/find.go: deprecated paths warning - pkg/templates/compile.go: unsigned/tampered template warnings - pkg/fuzz/component/value.go: unknown type warning Fixes projectdiscovery#7314
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe PR replaces deprecated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dwisiswant0
left a comment
There was a problem hiding this comment.
Closing this since it's already being handled over at #7316.
Neo - PR Security ReviewCaution Neo couldn't finish analyzing this pull request during this run. Please run the review again. Comment |
Summary
Fixes #7314
Warning messages using
Logger.Print()with manually formatted[WRN]labels were being written to stdout instead of stderr, corrupting JSON output when using the-jflag.Root Cause
In gologger,
Print()creates events atLevelSilent, which the CLI writer routes toos.Stdout. This means any warning message usingPrint().Msgf("[%v] ...", BrightYellow("WRN"), ...)ends up in stdout, mixing with structured scan output.Warning()creates events atLevelWarning, which the CLI writer routes toos.Stderr(the correct destination for diagnostic messages).Changes
Replaced all
Logger.Print()calls that manually format[WRN]labels withLogger.Warning(), which:LevelWarning[WRN]label prefix-jJSON output on stdoutFiles changed (4 files, 8 instances):
internal/runner/runner.gointernal/runner/runner.gointernal/runner/runner.gointernal/runner/runner.gopkg/catalog/disk/find.gopkg/templates/compile.gopkg/fuzz/component/value.goNot Changed
cmd/nuclei/main.go:812—Print().Msg(warning)for the interactive reset prompt. This is intentional stdout output before a user confirmation prompt, not a warning message.Testing
go build ./cmd/nuclei/— compiles successfullygo vet— no issuesSummary by CodeRabbit