Skip to content

Commit

Permalink
Merge pull request #68 from projectdiscovery/hide-err-version-parse
Browse files Browse the repository at this point in the history
adds ErrParsingErr
  • Loading branch information
Mzack9999 authored Jul 28, 2023
2 parents 8f2ece6 + de9bd3c commit 596af00
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -771,7 +775,7 @@ func init() {

firstParsed, parseErr := version.NewVersion(toString(args[0]))
if parseErr != nil {
return nil, parseErr
return nil, errors.NewWithErr(ErrParsingArg).Wrap(parseErr)
}

var versionConstraints []string
Expand Down Expand Up @@ -842,27 +846,27 @@ 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
}

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
}))
Expand Down

0 comments on commit 596af00

Please sign in to comment.