Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ice3man543 committed Oct 2, 2023
1 parent 46ca080 commit 06a7d08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 11 additions & 2 deletions v2/pkg/protocols/common/fuzz/component/value.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package component

import (
"strconv"

"github.com/leslie-qiwa/flat"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/fuzz/dataformat"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/fuzz/encoding"
)
Expand Down Expand Up @@ -64,7 +67,7 @@ func (v *Value) SetParsed(parsed map[string]interface{}, dataFormat string) {

// SetParsedValue sets the parsed value for a key
// in the parsed map
func (v *Value) SetParsedValue(key string, value interface{}) bool {
func (v *Value) SetParsedValue(key string, value string) bool {
origValue, ok := v.parsed[key]
if !ok {
v.parsed[key] = value
Expand All @@ -77,8 +80,14 @@ func (v *Value) SetParsedValue(key string, value interface{}) bool {
origValue = append(v, value)
case string:
origValue = value
case int, int32, int64, float32, float64:
parsed, err := strconv.ParseInt(value, 10, 64)
if err != nil {
return false
}
origValue = parsed
default:
return false
gologger.Error().Msgf("unknown type %T for value %s", v, v)
}
v.parsed[key] = origValue
return true
Expand Down
7 changes: 5 additions & 2 deletions v2/pkg/protocols/common/fuzz/parts.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func (rule *Rule) executePartComponent(input *ExecuteRuleInput, payload string,
var evaluated string
evaluated, input.InteractURLs = rule.executeEvaluate(input, key, valueStr, payload, input.InteractURLs)
if !input.HasAnalyzers {
component.SetValue(key, evaluated)
if err := component.SetValue(key, evaluated); err != nil {
return
}
}

if rule.modeType == singleModeType {
Expand All @@ -39,7 +41,7 @@ func (rule *Rule) executePartComponent(input *ExecuteRuleInput, payload string,
}

if qerr := rule.buildInput(input, req, input.InteractURLs, component, key, evaluated, valueStr); qerr != nil {
finalErr = err
finalErr = qerr
return
}
component.SetValue(key, valueStr) // change back to previous value for temp
Expand All @@ -59,6 +61,7 @@ func (rule *Rule) executePartComponent(input *ExecuteRuleInput, payload string,
if err != nil {
return err
}

if qerr := rule.buildInput(input, req, input.InteractURLs, component, "", "", ""); qerr != nil {
err = qerr
return err
Expand Down

0 comments on commit 06a7d08

Please sign in to comment.