Skip to content

Comments

fix: handle comma-separated entries in -l/--list input file#922

Open
Bushi-gg wants to merge 1 commit intoprojectdiscovery:mainfrom
Bushi-gg:fix/list-comma-parsing
Open

fix: handle comma-separated entries in -l/--list input file#922
Bushi-gg wants to merge 1 commit intoprojectdiscovery:mainfrom
Bushi-gg:fix/list-comma-parsing

Conversation

@Bushi-gg
Copy link

@Bushi-gg Bushi-gg commented Feb 24, 2026

Fix

Resolves #859 — the -l/--list flag now handles comma-separated entries within a single line, matching the behavior of -u.

/claim #859

Problem

When using -l filename.txt where the file contains comma-separated prefixes on a single line (e.g. 192.168.1.0/24,192.168.2.0/24,192.168.3.0/24), tlsx tried to use the entire comma-separated string as a single host, resulting in:

[WRN] Could not connect input 192.168.1.0/24,192.168.2.0/24,192.168.3.0/24:443

Changes

In normalizeAndQueueInputs() (internal/runner/runner.go), lines read from the input file and stdin are now split by comma before processing:

  • Single entries per line: unchanged behavior (strings.Split returns one-element slice)
  • Comma-separated entries: split and processed individually
  • Whitespace around commas: handled via strings.TrimSpace
  • Empty items from trailing commas: skipped

Testing

  • go build ./... passes
  • Consistent with how -u handles comma-separated inputs via goflags.CommaSeparatedStringSliceOptions

Summary by CodeRabbit

  • New Features
    • Input processing now supports comma-separated values on individual lines. Both file-based and standard input sources can handle multiple items per line with automatic whitespace trimming and empty value filtering, improving input handling flexibility.

@neo-by-projectdiscovery-dev
Copy link

neo-by-projectdiscovery-dev bot commented Feb 24, 2026

Neo Security Audit

No security issues found

Comment @neo help for available commands. · Open in Neo

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Walkthrough

The input parsing in normalizeAndQueueInputs was updated to support comma-separated lists per line. Each scanned line is now split by commas, trimmed of whitespace, filtered for non-empty strings, and each resulting item is individually passed to processInputItem. This change affects both file-based and stdin input processing paths.

Changes

Cohort / File(s) Summary
Input Parsing Enhancement
internal/runner/runner.go
Modified normalizeAndQueueInputs to split comma-separated values within each input line and process each item individually, enabling consistent multi-item input handling across file-based and stdin inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through comma streams,
Splitting lines into items and dreams,
Where once one lived, now many play,
Input parsing works the same way! 🌾

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding comma-separated entry support to the -l/--list input file, directly addressing the core functionality improvement.
Linked Issues check ✅ Passed The pull request fully addresses issue #859 by implementing comma-separated entry support in the -l/--list flag, matching -u behavior and resolving the reported parsing failure.
Out of Scope Changes check ✅ Passed All changes in internal/runner/runner.go are directly scoped to the comma-separated parsing requirement; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/runner/runner.go (1)

441-448: Deduplicate comma-splitting logic for file/stdin inputs.

The same split/trim/skip logic appears twice; a small helper keeps future tweaks consistent in both paths.

♻️ Suggested refactor
 func (r *Runner) normalizeAndQueueInputs(inputs chan taskInput) error {
+	normalizeLine := func(text string) {
+		for _, item := range strings.Split(text, ",") {
+			item = strings.TrimSpace(item)
+			if item != "" {
+				r.processInputItem(item, inputs)
+			}
+		}
+	}
 	// Process Normal Inputs
 	for _, text := range r.options.Inputs {
 		r.processInputItem(text, inputs)
 	}
@@
 	scanner := bufio.NewScanner(file)
 	for scanner.Scan() {
 		text := scanner.Text()
 		if text != "" {
-			for _, item := range strings.Split(text, ",") {
-				item = strings.TrimSpace(item)
-				if item != "" {
-					r.processInputItem(item, inputs)
-				}
-			}
+			normalizeLine(text)
 		}
 	}
@@
 	scanner := bufio.NewScanner(os.Stdin)
 	for scanner.Scan() {
 		text := scanner.Text()
 		if text != "" {
-			for _, item := range strings.Split(text, ",") {
-				item = strings.TrimSpace(item)
-				if item != "" {
-					r.processInputItem(item, inputs)
-				}
-			}
+			normalizeLine(text)
 		}
 	}
 	return nil
 }

Also applies to: 456-462

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/runner.go` around lines 441 - 448, The comma-split/trim/skip
loop used to feed r.processInputItem from scanner.Text (and the duplicate at
lines 456-462) should be extracted into a small helper to avoid duplication;
create a method like splitAndProcessInputItems(text string, inputs *InputType)
(or a package-level helper if appropriate) that does strings.Split(text, ","),
strings.TrimSpace per item, skips empty items, and calls
r.processInputItem(item, inputs); then replace both inline loops with calls to
this helper, keeping the original scanner.Text usage and r.processInputItem
calls intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/runner/runner.go`:
- Around line 441-448: The comma-split/trim/skip loop used to feed
r.processInputItem from scanner.Text (and the duplicate at lines 456-462) should
be extracted into a small helper to avoid duplication; create a method like
splitAndProcessInputItems(text string, inputs *InputType) (or a package-level
helper if appropriate) that does strings.Split(text, ","), strings.TrimSpace per
item, skips empty items, and calls r.processInputItem(item, inputs); then
replace both inline loops with calls to this helper, keeping the original
scanner.Text usage and r.processInputItem calls intact.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d13b67f and dee2a17.

📒 Files selected for processing (1)
  • internal/runner/runner.go

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