diff --git a/pkg/catalog/aws/catalog.go b/pkg/catalog/aws/catalog.go index 5dfa86a56..58d409360 100644 --- a/pkg/catalog/aws/catalog.go +++ b/pkg/catalog/aws/catalog.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "path" + "slices" "strings" "github.com/aws/aws-sdk-go-v2/aws" @@ -140,10 +141,8 @@ func (c Catalog) ResolvePath(templateName, second string) (string, error) { } // check if templateName is already an absolute path to c key - for _, key := range keys { - if key == templateName { - return templateName, nil - } + if slices.Contains(keys, templateName) { + return templateName, nil } return "", fmt.Errorf("no such path found: %s%s for keys: %v", second, templateName, keys) diff --git a/pkg/catalog/aws/catalog_test.go b/pkg/catalog/aws/catalog_test.go index 57dac391a..59095d635 100644 --- a/pkg/catalog/aws/catalog_test.go +++ b/pkg/catalog/aws/catalog_test.go @@ -3,6 +3,7 @@ package aws import ( "io" "reflect" + "slices" "strings" "testing" @@ -250,13 +251,7 @@ func (m mocks3svc) getAllKeys() ([]string, error) { } func (m mocks3svc) downloadKey(name string) (io.ReadCloser, error) { - found := false - for _, key := range m.keys { - if key == name { - found = true - break - } - } + found := slices.Contains(m.keys, name) if !found { return nil, errors.New("key not found") } diff --git a/pkg/catalog/config/nucleiconfig.go b/pkg/catalog/config/nucleiconfig.go index a7bb0ba23..246870935 100644 --- a/pkg/catalog/config/nucleiconfig.go +++ b/pkg/catalog/config/nucleiconfig.go @@ -7,6 +7,7 @@ import ( "log" "os" "path/filepath" + "slices" "strings" "github.com/projectdiscovery/goflags" @@ -334,12 +335,7 @@ func (c *Config) copyIgnoreFile() { // this could be a feature specific to debugging like PPROF or printing stats // of max host error etc func (c *Config) IsDebugArgEnabled(arg string) bool { - for _, v := range c.debugArgs { - if v == arg { - return true - } - } - return false + return slices.Contains(c.debugArgs, arg) } // parseDebugArgs from string diff --git a/pkg/input/formats/openapi/examples.go b/pkg/input/formats/openapi/examples.go index 235f940c9..2c79d5c89 100644 --- a/pkg/input/formats/openapi/examples.go +++ b/pkg/input/formats/openapi/examples.go @@ -2,6 +2,7 @@ package openapi import ( "fmt" + "slices" "github.com/getkin/kin-openapi/openapi3" "github.com/pkg/errors" @@ -84,13 +85,7 @@ func excludeFromMode(schema *openapi3.Schema) bool { // isRequired checks whether a key is actually required. func isRequired(schema *openapi3.Schema, key string) bool { - for _, req := range schema.Required { - if req == key { - return true - } - } - - return false + return slices.Contains(schema.Required, key) } type cachedSchema struct { diff --git a/pkg/protocols/http/request_condition.go b/pkg/protocols/http/request_condition.go index 50f881322..e92541443 100644 --- a/pkg/protocols/http/request_condition.go +++ b/pkg/protocols/http/request_condition.go @@ -2,6 +2,7 @@ package http import ( "regexp" + "slices" ) var ( @@ -32,10 +33,5 @@ func (request *Request) NeedsRequestCondition() bool { } func checkRequestConditionExpressions(expressions ...string) bool { - for _, expression := range expressions { - if reRequestCondition.MatchString(expression) { - return true - } - } - return false + return slices.ContainsFunc(expressions, reRequestCondition.MatchString) }