mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 04:35:24 +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) {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-rod/rod"
|
||||
@ -92,6 +93,7 @@ func (p *Page) ExecuteActions(baseURL *url.URL, actions []*Action) (map[string]s
|
||||
}
|
||||
|
||||
type rule struct {
|
||||
*sync.Once
|
||||
Action ActionType
|
||||
Part 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.
|
||||
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")
|
||||
|
||||
args := make(map[string]string)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@ func (p *Page) routingRuleHandler(ctx *rod.Hijack) {
|
||||
|
||||
switch rule.Action {
|
||||
case ActionSetMethod:
|
||||
ctx.Request.Req().Method = rule.Args["method"]
|
||||
rule.Do(func() {
|
||||
ctx.Request.Req().Method = rule.Args["method"]
|
||||
})
|
||||
case ActionAddHeader:
|
||||
ctx.Request.Req().Header.Add(rule.Args["key"], rule.Args["value"])
|
||||
case ActionSetHeader:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user