fix: support comma-separated prefixes in -l option like -u#937
fix: support comma-separated prefixes in -l option like -u#937flowerjunjie wants to merge 1 commit intoprojectdiscovery:mainfrom
Conversation
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
WalkthroughThe change modifies input processing in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 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)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
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 | 🟠 MajorHandle 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), andnormalizeAndQueueInputsstill returnsnil.🔧 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.
There was a problem hiding this comment.
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 | 🟠 MajorHandle 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), andnormalizeAndQueueInputsstill returnsnil.🔧 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.
Fixes #859
Summary by CodeRabbit