Skip to content

Fix -l/-list option to parse comma-separated values#898

Closed
buildingvibes wants to merge 1 commit intoprojectdiscovery:mainfrom
buildingvibes:fix-list-comma-parsing
Closed

Fix -l/-list option to parse comma-separated values#898
buildingvibes wants to merge 1 commit intoprojectdiscovery:mainfrom
buildingvibes:fix-list-comma-parsing

Conversation

@buildingvibes
Copy link

@buildingvibes buildingvibes commented Feb 9, 2026

Summary

Fixes #859 - The -l/-list option now correctly parses comma-separated values on a single line, matching the behavior of the -u option.

/claim #859

Problem

The -l/-list option was treating entire lines as single inputs, even when they contained comma-separated values. This was inconsistent with the -u option which correctly splits comma-separated values.

Before this fix:

# This works
./tlsx -u 192.168.1.0/24,192.168.2.0/24,192.168.3.0/24

# This fails (treats entire line as one host)
echo "192.168.1.0/24,192.168.2.0/24,192.168.3.0/24" > hosts.txt
./tlsx -l hosts.txt
# Error: Could not connect input 192.168.1.0/24,192.168.2.0/24,192.168.3.0/24:443

Solution

Modified normalizeAndQueueInputs() in internal/runner/runner.go to split each line by commas before processing. Applied the same logic to both file input and stdin for consistency.

After this fix:

# Both work identically now
./tlsx -u google.com,github.com,example.com
./tlsx -l hosts.txt  # where hosts.txt contains: google.com,github.com,example.com

Changes

  • Split file input lines by comma in normalizeAndQueueInputs()
  • Split stdin input lines by comma for consistency
  • Trim whitespace from each parsed item
  • Maintains backward compatibility with newline-separated inputs

Testing

Verified the fix works correctly:

# Test with comma-separated hosts in file
$ echo "google.com,github.com,example.com" > /tmp/test_hosts.txt
$ ./tlsx -l /tmp/test_hosts.txt -v -silent
[INF] Processing input google.com:443
[INF] Processing input github.com:443
[INF] Processing input example.com:443
google.com:443
github.com:443
example.com:443
[INF] Connections made using crypto/tls: 3, zcrypto/tls: 0, openssl: 0

# Compare with -u flag (identical behavior)
$ ./tlsx -u google.com,github.com,example.com -v -silent
[INF] Processing input github.com:443
[INF] Processing input google.com:443
[INF] Processing input example.com:443
google.com:443
github.com:443
example.com:443
[INF] Connections made using crypto/tls: 3, zcrypto/tls: 0, openssl: 0

# Test with CIDR prefixes (as mentioned in issue)
$ echo "192.168.1.1/32,192.168.1.2/32" > /tmp/test_cidrs.txt
$ ./tlsx -l /tmp/test_cidrs.txt -v -silent
[INF] Processing input 192.168.1.1:443
[INF] Processing input 192.168.1.2:443
# Both IPs processed separately (correctly)

All existing tests pass:

$ go test ./internal/runner
ok  	github.com/projectdiscovery/tlsx/internal/runner	0.313s

Checklist

  • Minimal code changes (14 lines added, 2 removed)
  • Follows existing code style and patterns
  • Backward compatible with newline-separated inputs
  • Maintains consistency with -u flag behavior
  • All runner tests pass
  • Tested with various input formats (domains, IPs, CIDRs)

Summary by CodeRabbit

  • New Features
    • Comma-separated values in input lines are now automatically split, trimmed, and processed as individual items when reading from files or STDIN, allowing a single line to generate multiple tasks and improving batch input handling.

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
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Walkthrough

The 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

Cohort / File(s) Summary
Input Parsing Enhancement
internal/runner/runner.go
When reading from -l/file or STDIN, lines are split by commas, trimmed, and each non-empty token is enqueued separately (expands single line with multiple comma-separated inputs into multiple tasks).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A commaed line once stayed as one,
I nibbled gaps until each shone,
Trimmed and hopped, each token flew,
Now every input finds its queue! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing comma-separated value parsing for the -l/--list option.
Linked Issues check ✅ Passed The changes fully address issue #859 by splitting comma-separated values in file/stdin input and trimming whitespace, matching -u flag behavior.
Out of Scope Changes check ✅ Passed All changes in internal/runner/runner.go are directly scoped to fixing the comma-separated input parsing issue described in #859.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@buildingvibes
Copy link
Author

Closing this PR to focus on one contribution at a time per project guidelines. I'll resubmit if bandwidth allows. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-l -list option does not understand multiple prefixes, comma-separated in a single line

1 participant