mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 19:35:27 +00:00
converting to post-processor prototype
This commit is contained in:
parent
e517797cfa
commit
eb61c519c3
@ -139,7 +139,7 @@ type Request struct {
|
||||
// description: |
|
||||
// SelfContained specifies if the request is self contained.
|
||||
SelfContained bool `yaml:"-" json:"-"`
|
||||
AwsSign bool `yaml:"-" json:"-"`
|
||||
PostProcessors []string `yaml:"-" json:"-"`
|
||||
|
||||
// description: |
|
||||
// CookieReuse is an optional setting that enables cookie reuse for
|
||||
|
||||
@ -197,6 +197,10 @@ func (request *Request) executeTurboHTTP(reqURL string, dynamicValues, previous
|
||||
return requestErr
|
||||
}
|
||||
|
||||
func (request *Request) hasPreprocessors() bool {
|
||||
return len(request.PostProcessors) > 0
|
||||
}
|
||||
|
||||
// ExecuteWithResults executes the final request on a URL
|
||||
func (request *Request) ExecuteWithResults(reqURL string, dynamicValues, previous output.InternalEvent, callback protocols.OutputEventCallback) error {
|
||||
// verify if pipeline was requested
|
||||
@ -296,6 +300,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||
// For race conditions we can't dump the request body at this point as it's already waiting the open-gate event, already handled with a similar code within the race function
|
||||
if !generatedRequest.original.Race {
|
||||
var dumpError error
|
||||
// TODO: dump is currently not working with post-processors - somehow it alters the signature
|
||||
dumpedRequest, dumpError = dump(generatedRequest, reqURL)
|
||||
if dumpError != nil {
|
||||
return dumpError
|
||||
@ -349,23 +354,26 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||
}
|
||||
}
|
||||
if resp == nil {
|
||||
// aws sign the request if necessary
|
||||
if request.AwsSign {
|
||||
for _, postProcessor := range request.PostProcessors {
|
||||
switch postProcessor {
|
||||
case "aws-sign":
|
||||
var awsSigner *AwsSigner
|
||||
payloads := request.options.Options.Vars.AsMap()
|
||||
if request.options.Options.EnvironmentVariables {
|
||||
var err error
|
||||
awsSigner, err = NewAwsSignerFromEnv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else { // get from variables {
|
||||
awsAccessKeyId := types.ToString(payloads["aws-id"])
|
||||
awsSecretAccessKey := types.ToString(payloads["aws-secret"])
|
||||
if awsAccessKeyId != "" && awsSecretAccessKey != "" {
|
||||
awsSigner, err = NewAwsSigner(awsAccessKeyId, awsSecretAccessKey)
|
||||
} else {
|
||||
awsSigner, err = NewAwsSignerFromEnv()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
service := types.ToString(payloads["service"])
|
||||
region := types.ToString(payloads["region"])
|
||||
if service == "" || region == "" {
|
||||
return errors.New("service and region are mandatory")
|
||||
}
|
||||
|
||||
args := SignArguments{
|
||||
@ -378,6 +386,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
resp, err = request.httpClient.Do(generatedRequest.request)
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,9 +107,9 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Execute
|
||||
|
||||
// parseSelfContainedRequests parses the self contained template requests.
|
||||
func (template *Template) parseSelfContainedRequests() {
|
||||
if template.AwsSign {
|
||||
if len(template.PostProcessors) > 0 {
|
||||
for _, request := range template.RequestsHTTP {
|
||||
request.AwsSign = true
|
||||
request.PostProcessors = template.PostProcessors
|
||||
}
|
||||
}
|
||||
if !template.SelfContained {
|
||||
|
||||
@ -74,7 +74,7 @@ type Template struct {
|
||||
// description: |
|
||||
// Self Contained marks Requests for the template as self-contained
|
||||
SelfContained bool `yaml:"self-contained,omitempty" jsonschema:"title=mark requests as self-contained,description=Mark Requests for the template as self-contained"`
|
||||
AwsSign bool `yaml:"aws-sign,omitempty"`
|
||||
PostProcessors []string `yaml:"post-processors,omitempty"`
|
||||
|
||||
// TotalRequests is the total number of requests for the template.
|
||||
TotalRequests int `yaml:"-" json:"-"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user