From 238e83ec28c72447ca8a457a1dded85661d813bd Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Wed, 26 Jul 2023 18:21:31 +0530 Subject: [PATCH 1/2] add parsing Err var --- dsl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dsl.go b/dsl.go index 02d2911..52419dd 100644 --- a/dsl.go +++ b/dsl.go @@ -57,6 +57,10 @@ var ( DefaultHelperFunctions map[string]govaluate.ExpressionFunction funcSignatureRegex = regexp.MustCompile(`(\w+)\s*\((?:([\w\d,\s]+)\s+([.\w\d{}&*]+))?\)([\s.\w\d{}&*]+)?`) + + // ErrParsingArg is error when parsing value of argument + // Use With Caution: Nuclei ignores this error in extractors(ref: https://github.com/projectdiscovery/nuclei/issues/3950) + ErrParsingArg = errors.New("error parsing argument value") ) var PrintDebugCallback func(args ...interface{}) error @@ -771,7 +775,7 @@ func init() { firstParsed, parseErr := version.NewVersion(toString(args[0])) if parseErr != nil { - return nil, parseErr + return nil, ErrParsingArg } var versionConstraints []string From de9bd3c7089101d0ca3406bd6a993caf14cc1ad0 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Fri, 28 Jul 2023 17:48:43 +0530 Subject: [PATCH 2/2] propogate err with ErrParsingErr --- dsl.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dsl.go b/dsl.go index 52419dd..512c83b 100644 --- a/dsl.go +++ b/dsl.go @@ -36,13 +36,13 @@ import ( "github.com/hashicorp/go-version" "github.com/kataras/jwt" "github.com/logrusorgru/aurora" - "github.com/pkg/errors" "github.com/projectdiscovery/dsl/deserialization" "github.com/projectdiscovery/dsl/llm" "github.com/projectdiscovery/dsl/randomip" "github.com/projectdiscovery/gologger" "github.com/projectdiscovery/mapcidr" jarm "github.com/projectdiscovery/utils/crypto/jarm" + errors "github.com/projectdiscovery/utils/errors" maputils "github.com/projectdiscovery/utils/maps" randint "github.com/projectdiscovery/utils/rand" stringsutil "github.com/projectdiscovery/utils/strings" @@ -775,7 +775,7 @@ func init() { firstParsed, parseErr := version.NewVersion(toString(args[0])) if parseErr != nil { - return nil, ErrParsingArg + return nil, errors.NewWithErr(ErrParsingArg).Wrap(parseErr) } var versionConstraints []string @@ -846,10 +846,10 @@ func init() { } start, err := strconv.Atoi(toString(args[1])) if err != nil { - return nil, errors.Wrap(err, "invalid start position") + return nil, errors.NewWithErr(err).Msgf("invalid start position") } if start > len(argStr) { - return nil, errors.Wrap(err, "start position bigger than slice length") + return nil, errors.NewWithErr(err).Msgf("start position bigger than slice length") } if len(args) == 2 { return argStr[start:], nil @@ -857,16 +857,16 @@ func init() { end, err := strconv.Atoi(toString(args[2])) if err != nil { - return nil, errors.Wrap(err, "invalid end position") + return nil, errors.NewWithErr(err).Msgf("invalid end position") } if end < 0 { - return nil, errors.Wrap(err, "negative end position") + return nil, errors.NewWithErr(err).Msgf("negative end position") } if end < start { - return nil, errors.Wrap(err, "end position before start") + return nil, errors.NewWithErr(err).Msgf("end position before start") } if end > len(argStr) { - return nil, errors.Wrap(err, "end position bigger than slice length start") + return nil, errors.NewWithErr(err).Msgf("end position bigger than slice length start") } return argStr[start:end], nil }))