mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-23 21:35:26 +00:00
Adding one-time method override (#3373)
This commit is contained in:
parent
d9e953acfa
commit
d7ac306bdf
@ -148,7 +148,6 @@ func (p *Page) hasModificationRules() bool {
|
|||||||
if containsAnyModificationActionType(rule.Action) {
|
if containsAnyModificationActionType(rule.Action) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-rod/rod"
|
"github.com/go-rod/rod"
|
||||||
@ -92,6 +93,7 @@ func (p *Page) ExecuteActions(baseURL *url.URL, actions []*Action) (map[string]s
|
|||||||
}
|
}
|
||||||
|
|
||||||
type rule struct {
|
type rule struct {
|
||||||
|
*sync.Once
|
||||||
Action ActionType
|
Action ActionType
|
||||||
Part string
|
Part string
|
||||||
Args map[string]string
|
Args map[string]string
|
||||||
@ -215,12 +217,12 @@ func (p *Page) ActionSetBody(act *Action, out map[string]string /*TODO review un
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ActionSetMethod executes an SetMethod action.
|
// ActionSetMethod executes an SetMethod action.
|
||||||
func (p *Page) ActionSetMethod(act *Action, out map[string]string /*TODO review unused parameter*/) error {
|
func (p *Page) ActionSetMethod(act *Action, out map[string]string) error {
|
||||||
in := p.getActionArgWithDefaultValues(act, "part")
|
in := p.getActionArgWithDefaultValues(act, "part")
|
||||||
|
|
||||||
args := make(map[string]string)
|
args := make(map[string]string)
|
||||||
args["method"] = p.getActionArgWithDefaultValues(act, "method")
|
args["method"] = p.getActionArgWithDefaultValues(act, "method")
|
||||||
p.rules = append(p.rules, rule{Action: ActionSetMethod, Part: in, Args: args})
|
p.rules = append(p.rules, rule{Action: ActionSetMethod, Part: in, Args: args, Once: &sync.Once{}})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,9 @@ func (p *Page) routingRuleHandler(ctx *rod.Hijack) {
|
|||||||
|
|
||||||
switch rule.Action {
|
switch rule.Action {
|
||||||
case ActionSetMethod:
|
case ActionSetMethod:
|
||||||
|
rule.Do(func() {
|
||||||
ctx.Request.Req().Method = rule.Args["method"]
|
ctx.Request.Req().Method = rule.Args["method"]
|
||||||
|
})
|
||||||
case ActionAddHeader:
|
case ActionAddHeader:
|
||||||
ctx.Request.Req().Header.Add(rule.Args["key"], rule.Args["value"])
|
ctx.Request.Req().Header.Add(rule.Args["key"], rule.Args["value"])
|
||||||
case ActionSetHeader:
|
case ActionSetHeader:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user