diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 91e80136..114ebc77 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -440,7 +440,7 @@ func (r *Runner) normalizeAndQueueInputs(inputs chan taskInput) error { for scanner.Scan() { text := scanner.Text() if text != "" { - r.processInputItem(text, inputs) + r.processCommaSeparatedInput(text, inputs) } } } @@ -449,13 +449,23 @@ func (r *Runner) normalizeAndQueueInputs(inputs chan taskInput) error { for scanner.Scan() { text := scanner.Text() if text != "" { - r.processInputItem(text, inputs) + r.processCommaSeparatedInput(text, inputs) } } } return nil } +func (r *Runner) processCommaSeparatedInput(text string, inputs chan taskInput) { + for _, part := range strings.Split(text, ",") { + trimmed := strings.TrimSpace(part) + if trimmed == "" { + continue + } + r.processInputItem(trimmed, inputs) + } +} + // resolveFQDN resolves a FQDN and returns the IP addresses func (r *Runner) resolveFQDN(target string) ([]string, error) { // If the host is a Domain, then perform resolution and discover all IP diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index b4ed856e..0a6bab36 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -429,3 +429,25 @@ func Test_CTLogsModeOutputOptions(t *testing.T) { }) } } + +func Test_ProcessCommaSeparatedInput(t *testing.T) { + options := &clients.Options{Ports: []string{"443"}} + runner := &Runner{options: options} + + inputs := make(chan taskInput) + go func() { + runner.processCommaSeparatedInput("example.com, one.one.one.one ,", inputs) + close(inputs) + }() + + var got []taskInput + for task := range inputs { + got = append(got, task) + } + + expected := []taskInput{ + {host: "example.com", port: "443"}, + {host: "one.one.one.one", port: "443"}, + } + require.ElementsMatch(t, expected, got) +}