Skip to content

fix: support comma-separated prefixes in -l option like -u#937

Open
flowerjunjie wants to merge 1 commit intoprojectdiscovery:mainfrom
flowerjunjie:fix/list-comma-separated-prefixes-859
Open

fix: support comma-separated prefixes in -l option like -u#937
flowerjunjie wants to merge 1 commit intoprojectdiscovery:mainfrom
flowerjunjie:fix/list-comma-separated-prefixes-859

Conversation

@flowerjunjie
Copy link

@flowerjunjie flowerjunjie commented Mar 3, 2026

Fixes #859

Summary by CodeRabbit

  • Bug Fixes
    • Fixed input processing to correctly handle comma-separated values as individual items rather than treating the entire line as a single input.

Fixes projectdiscovery#859

The -l option now splits comma-separated values on each line,
matching the behavior of the -u option.

Example:
  echo "192.168.1.0/24,192.168.2.0/24" | tlsx -l -
  # Now correctly processes both CIDR prefixes

Changes:
- Split each line by comma
- Trim whitespace from each part
- Process each part individually
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Walkthrough

The change modifies input processing in normalizeAndQueueInputs to parse comma-separated values within each line of the input list file, splitting them into individual inputs and trimming whitespace, rather than treating each entire line as a single input.

Changes

Cohort / File(s) Summary
Input normalization
internal/runner/runner.go
Modified line processing to split comma-separated values, trim whitespace, and enqueue each part individually instead of the entire line.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A comma here, a comma there,
Now inputs split with gentle care,
Each prefix gets its rightful queue,
No more tangled strings—we're through! ✨

🚥 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 'fix: support comma-separated prefixes in -l option like -u' directly matches the pull request's main objective of enabling the -l option to handle comma-separated prefixes identically to the -u option.
Linked Issues check ✅ Passed The code changes in normalizeAndQueueInputs implement comma-splitting and whitespace trimming to process each comma-separated part individually, directly addressing issue #859's requirement that -l should parse comma-separated prefixes like -u does.
Out of Scope Changes check ✅ Passed The changes are narrowly focused on the InputList processing path in normalizeAndQueueInputs to support comma-separated prefixes, with no unrelated modifications outside this scope.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/runner/runner.go (1)

439-462: ⚠️ Potential issue | 🟠 Major

Handle scanner errors after input loops.

scanner.Err() is not checked after both scan loops. If scanning fails, targets can be silently skipped (e.g., oversized lines), and normalizeAndQueueInputs still returns nil.

🔧 Proposed fix
 		scanner := bufio.NewScanner(file)
 		for scanner.Scan() {
 			text := scanner.Text()
 			if text != "" {
 				// Split comma-separated values like -u option does
 				parts := strings.Split(text, ",")
 				for _, part := range parts {
 					trimmed := strings.TrimSpace(part)
 					if trimmed != "" {
 						r.processInputItem(trimmed, inputs)
 					}
 				}
 			}
 		}
+		if err := scanner.Err(); err != nil {
+			return errkit.Wrap(err, "could not read input file")
+		}
 	}
 	if r.hasStdin {
 		scanner := bufio.NewScanner(os.Stdin)
 		for scanner.Scan() {
 			text := scanner.Text()
 			if text != "" {
 				r.processInputItem(text, inputs)
 			}
 		}
+		if err := scanner.Err(); err != nil {
+			return errkit.Wrap(err, "could not read stdin")
+		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/runner.go` around lines 439 - 462, After each bufio.Scanner
loop in normalizeAndQueueInputs (the loop reading from file using scanner and
the loop reading from os.Stdin when r.hasStdin is true), check scanner.Err() and
return or propagate a descriptive error instead of silently continuing; locate
the scanner usages in the code surrounding processInputItem and add error
handling after each loop (e.g., if err := scanner.Err(); err != nil { return
fmt.Errorf("scanning %s failed: %w", <source-ident>, err) }) so oversized lines
or IO errors don't allow inputs to be silently skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@internal/runner/runner.go`:
- Around line 439-462: After each bufio.Scanner loop in normalizeAndQueueInputs
(the loop reading from file using scanner and the loop reading from os.Stdin
when r.hasStdin is true), check scanner.Err() and return or propagate a
descriptive error instead of silently continuing; locate the scanner usages in
the code surrounding processInputItem and add error handling after each loop
(e.g., if err := scanner.Err(); err != nil { return fmt.Errorf("scanning %s
failed: %w", <source-ident>, err) }) so oversized lines or IO errors don't allow
inputs to be silently skipped.

ℹ️ 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 5f420b4.

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

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/runner/runner.go (1)

439-462: ⚠️ Potential issue | 🟠 Major

Handle scanner errors after input loops.

scanner.Err() is not checked after both scan loops. If scanning fails, targets can be silently skipped (e.g., oversized lines), and normalizeAndQueueInputs still returns nil.

🔧 Proposed fix
 		scanner := bufio.NewScanner(file)
 		for scanner.Scan() {
 			text := scanner.Text()
 			if text != "" {
 				// Split comma-separated values like -u option does
 				parts := strings.Split(text, ",")
 				for _, part := range parts {
 					trimmed := strings.TrimSpace(part)
 					if trimmed != "" {
 						r.processInputItem(trimmed, inputs)
 					}
 				}
 			}
 		}
+		if err := scanner.Err(); err != nil {
+			return errkit.Wrap(err, "could not read input file")
+		}
 	}
 	if r.hasStdin {
 		scanner := bufio.NewScanner(os.Stdin)
 		for scanner.Scan() {
 			text := scanner.Text()
 			if text != "" {
 				r.processInputItem(text, inputs)
 			}
 		}
+		if err := scanner.Err(); err != nil {
+			return errkit.Wrap(err, "could not read stdin")
+		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/runner.go` around lines 439 - 462, After each bufio.Scanner
loop in normalizeAndQueueInputs (the loop reading from file using scanner and
the loop reading from os.Stdin when r.hasStdin is true), check scanner.Err() and
return or propagate a descriptive error instead of silently continuing; locate
the scanner usages in the code surrounding processInputItem and add error
handling after each loop (e.g., if err := scanner.Err(); err != nil { return
fmt.Errorf("scanning %s failed: %w", <source-ident>, err) }) so oversized lines
or IO errors don't allow inputs to be silently skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@internal/runner/runner.go`:
- Around line 439-462: After each bufio.Scanner loop in normalizeAndQueueInputs
(the loop reading from file using scanner and the loop reading from os.Stdin
when r.hasStdin is true), check scanner.Err() and return or propagate a
descriptive error instead of silently continuing; locate the scanner usages in
the code surrounding processInputItem and add error handling after each loop
(e.g., if err := scanner.Err(); err != nil { return fmt.Errorf("scanning %s
failed: %w", <source-ident>, err) }) so oversized lines or IO errors don't allow
inputs to be silently skipped.

ℹ️ 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 5f420b4.

📒 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

Labels

None yet

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