Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions internal/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}