fix: handle comma-separated entries in -l/-list and stdin input#959
fix: handle comma-separated entries in -l/-list and stdin input#959Gengyscan wants to merge 2 commits intoprojectdiscovery:mainfrom
Conversation
Split comma-separated targets when reading from -l file or stdin, matching the existing -u flag behavior that uses CommaSeparatedStringSliceOptions. Fixes projectdiscovery#859
Neo - PR Security ReviewNo security issues found Highlights
Comment |
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughInput parsing in the runner was changed to split each input line by commas, trim whitespace, and enqueue each non-empty segment as a separate input. Errors reading input files and stdin are now wrapped and returned with descriptive messages. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
📝 Coding Plan
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/runner/runner.go`:
- Around line 439-449: The scanner loops that read from file and stdin use
bufio.NewScanner(file) / bufio.NewScanner(os.Stdin) and call
r.processInputItem(...) for each token but never check scanner.Err(); after each
loop (the file-scanner loop around the call to r.processInputItem and the
stdin-scanner loop) call scanner.Err(), and if non-nil return or propagate that
error (or wrap it with context) instead of silently returning nil so token-size
or I/O errors are not swallowed; update the function to handle and surface these
errors where the scanner variables are defined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 96b26ef1-e5a1-4bde-8d26-2de2cbc0439b
📒 Files selected for processing (1)
internal/runner/runner.go
Address CodeRabbit review: check scanner.Err() after both scanner loops to surface token-size or I/O errors instead of silently dropping targets.
Description
Fixes #859 —
-l/-listand stdin input now correctly handle comma-separated targets on a single line, matching the existing-uflag behavior.Problem
When using
-u host1,host2,host3, targets are correctly split by comma viaCommaSeparatedStringSliceOptionsin goflags. However, when using-l file.txtwhere the file contains comma-separated targets on a single line, the entire line is treated as one target, causing connection failures.Root Cause
In
normalizeAndQueueInputs, the bufio scanner reads each line and passes it directly toprocessInputItemwithout splitting on commas. The-uflag gets comma-splitting for free from goflags, but file/stdin inputs bypass that.Fix
Split each scanned line on commas (with trimming) before passing to
processInputItem, in both the file-input and stdin-input code paths.Changes
internal/runner/runner.go: Addedstrings.Split(text, ",")loop withstrings.TrimSpacein both the-lfile scanner and the stdin scanner blocks ofnormalizeAndQueueInputs.Testing
go build -buildvcs=false ./cmd/tlsx/)stringswas already imported)/claim #859
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes