Fix -l/-list option to parse comma-separated values#898
Fix -l/-list option to parse comma-separated values#898buildingvibes wants to merge 1 commit intoprojectdiscovery:mainfrom
Conversation
This commit fixes issue projectdiscovery#859 where the -l/-list option did not handle comma-separated values on a single line, unlike the -u option which correctly parses comma-separated hosts. Changes: - Modified normalizeAndQueueInputs() to split file input lines by comma - Applied same logic to stdin input for consistency - Each item is trimmed of whitespace before processing - Maintains backward compatibility with newline-separated inputs Now both -u and -l options support the same comma-separated format: ./tlsx -u host1,host2,host3 ./tlsx -l file.txt (where file.txt contains: host1,host2,host3) Fixes projectdiscovery#859
WalkthroughThe runner now expands comma-separated items from file and STDIN inputs: each line is split on commas, trimmed, and each non-empty item is enqueued as an individual input task, preserving existing error handling and single-item behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant File as File/STDIN
participant Runner as Runner (normalize & enqueue)
participant Queue as TaskQueue
participant Worker as Worker
rect rgba(200,230,255,0.5)
File->>Runner: provide line "a,b,c" (or single item)
end
rect rgba(200,255,200,0.5)
Runner->>Runner: split by ',', trim tokens, filter empty
Runner->>Queue: enqueue "a"
Runner->>Queue: enqueue "b"
Runner->>Queue: enqueue "c"
end
rect rgba(255,230,200,0.5)
Queue->>Worker: deliver tasks for processing
Worker->>Queue: ack / process results
end
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)
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 |
570e9d8 to
44fd2e7
Compare
|
Closing this PR to focus on one contribution at a time per project guidelines. I'll resubmit if bandwidth allows. Thank you! |
Summary
Fixes #859 - The
-l/-listoption now correctly parses comma-separated values on a single line, matching the behavior of the-uoption./claim #859
Problem
The
-l/-listoption was treating entire lines as single inputs, even when they contained comma-separated values. This was inconsistent with the-uoption which correctly splits comma-separated values.Before this fix:
Solution
Modified
normalizeAndQueueInputs()ininternal/runner/runner.goto split each line by commas before processing. Applied the same logic to both file input and stdin for consistency.After this fix:
Changes
normalizeAndQueueInputs()Testing
Verified the fix works correctly:
All existing tests pass:
$ go test ./internal/runner ok github.com/projectdiscovery/tlsx/internal/runner 0.313sChecklist
-uflag behaviorSummary by CodeRabbit