Skip to content
2 changes: 1 addition & 1 deletion internal/runner/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestParseHeadlessOptionalArguments(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
strsl := goflags.StringSlice{}
for _, v := range strings.Split(tt.input, ",") {
for v := range strings.SplitSeq(tt.input, ",") {
//nolint
strsl.Set(v)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/runner/preflight_portscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,8 @@ func splitPorts(s string) []string {
if s == "" {
return nil
}
parts := strings.Split(s, ",")
out := make([]string, 0, len(parts))
for _, p := range parts {
var out []string
for p := range strings.SplitSeq(s, ",") {
p = strings.TrimSpace(p)
if p != "" {
out = append(out, p)
Expand Down
10 changes: 5 additions & 5 deletions internal/tests/integration/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func (h *httpRawUnsafePath) Execute(filepath string) error {
}

actual := []string{}
for _, v := range strings.Split(results, "\n") {
for v := range strings.SplitSeq(results, "\n") {
if strings.Contains(v, "GET") {
parts := strings.Fields(v)
if len(parts) == 3 {
Expand Down Expand Up @@ -877,7 +877,7 @@ func (h *httpPaths) Execute(filepath string) error {
}

actual := []string{}
for _, v := range strings.Split(results, "\n") {
for v := range strings.SplitSeq(results, "\n") {
if strings.Contains(v, "GET") {
parts := strings.Fields(v)
if len(parts) == 3 {
Expand Down Expand Up @@ -1394,7 +1394,7 @@ func (h *httpVariableDSLFunction) Execute(filePath string) error {
}

actual := []string{}
for _, v := range strings.Split(results, "\n") {
for v := range strings.SplitSeq(results, "\n") {
if strings.Contains(v, "GET") {
parts := strings.Fields(v)
if len(parts) == 3 {
Expand Down Expand Up @@ -1763,7 +1763,7 @@ func (h *httpRawPathSingleSlash) Execute(filepath string) error {
}

var actual string
for _, v := range strings.Split(results, "\n") {
for v := range strings.SplitSeq(results, "\n") {
if strings.Contains(v, "GET") {
parts := strings.Fields(v)
if len(parts) == 3 {
Expand All @@ -1788,7 +1788,7 @@ func (h *httpRawUnsafePathSingleSlash) Execute(filepath string) error {
}

var actual string
for _, v := range strings.Split(results, "\n") {
for v := range strings.SplitSeq(results, "\n") {
if strings.Contains(v, "GET") {
parts := strings.Fields(v)
if len(parts) == 3 {
Expand Down
11 changes: 3 additions & 8 deletions pkg/catalog/config/nucleiconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,12 @@ func (c *Config) IsDebugArgEnabled(arg string) bool {
// parseDebugArgs from string
func (c *Config) parseDebugArgs(data string) {
// use space as separator instead of commas
tmp := strings.Fields(data)
for _, v := range tmp {
for v := range strings.FieldsSeq(data) {
key := v
value := ""
// if it is key value pair then split it
if strings.Contains(v, "=") {
parts := strings.SplitN(v, "=", 2)
if len(parts) != 2 {
continue
}
key, value = strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
if k, val, ok := strings.Cut(v, "="); ok {
key, value = strings.TrimSpace(k), strings.TrimSpace(val)
}
if value == "false" || value == "0" {
// if false or disabled then skip
Expand Down
3 changes: 1 addition & 2 deletions pkg/catalog/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func IsTemplateWithRoot(fpath, rootDir string) bool {
// Only check components if pathToCheck is NOT absolute
// This avoids false positives on parent directories for absolute paths
if !filepath.IsAbs(pathToCheck) {
parts := strings.Split(pathToCheck, string(os.PathSeparator))
for _, p := range parts {
for p := range strings.SplitSeq(pathToCheck, string(os.PathSeparator)) {
for _, excluded := range knownMiscDirectories {
if strings.EqualFold(p, excluded) {
return false
Expand Down
3 changes: 2 additions & 1 deletion pkg/installer/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@
checksums, err := os.ReadFile(checksumFilePath)
if err == nil {
allChecksums := make(map[string]string)
for _, v := range strings.Split(string(checksums), ";") {
for v := range strings.SplitSeq(string(checksums), ";") {
v = strings.TrimSpace(v)
// Strict two-field parse: paths may contain commas (Cut would mis-parse).

Check warning on line 588 in pkg/installer/template.go

View workflow job for this annotation

GitHub Actions / Spell Check

"mis" should be "miss" or "mist".
tmparr := strings.Split(v, ",")
if len(tmparr) != 2 {
continue
Expand Down
3 changes: 1 addition & 2 deletions pkg/js/devtools/tsgen/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,7 @@ func updateFuncWithConstructorSig(sig string, f Function) Function {
sig = strings.TrimPrefix(sig, "constructor(")
sig = strings.TrimSuffix(sig, ")")
// split by comma
args := strings.Split(sig, ",")
for _, arg := range args {
for arg := range strings.SplitSeq(sig, ",") {
arg = strings.TrimSpace(arg)
// check if it is optional
typeData := strings.Split(arg, ":")
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocols/javascript/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ func (request *Request) getPorts() []string {
if strings.EqualFold(k, "Port") {
portStr := types.ToString(v)
ports := []string{}
for _, p := range strings.Split(portStr, ",") {
for p := range strings.SplitSeq(portStr, ",") {
trimmed := strings.TrimSpace(p)
if trimmed != "" {
ports = append(ports, trimmed)
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocols/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
// parse ports and validate
if request.Port != "" {
seen := make(map[string]struct{})
for _, port := range strings.Split(request.Port, ",") {
for port := range strings.SplitSeq(request.Port, ",") {
port = strings.TrimSpace(port)
if port == "" {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/templates/fuzz_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (candidate *fuzzTemplateCandidate) yaml() []byte {
builder.WriteString("http:\n - ")
if candidate.useRawRequest {
builder.WriteString("raw:\n - |\n")
for _, line := range strings.Split(candidate.rawRequest(), "\r\n") {
for line := range strings.SplitSeq(candidate.rawRequest(), "\r\n") {
if line == "" {
builder.WriteString(" \n")
continue
Expand Down
22 changes: 14 additions & 8 deletions pkg/tmplexec/flow/flow_executor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package flow

import (
"bufio"
"fmt"
"io"
"strconv"
Expand Down Expand Up @@ -331,14 +332,19 @@ func (f *FlowExecutor) ReadDataFromFile(payload string) ([]string, error) {
defer func() {
_ = reader.Close()
}()
bin, err := io.ReadAll(reader)
if err != nil {
return values, err
}
for _, line := range strings.Split(string(bin), "\n") {
line = strings.TrimSpace(line)
if line != "" {
values = append(values, line)
// Stream the helper file line-by-line instead of loading it whole into memory:
// helper files for flow templates can be large (wordlists, payload corpora).
br := bufio.NewReader(reader)
for {
line, readErr := br.ReadString('\n')
if trimmed := strings.TrimSpace(line); trimmed != "" {
values = append(values, trimmed)
}
if readErr == io.EOF {
break
}
if readErr != nil {
return values, readErr
}
}
return values, nil
Expand Down
Loading