Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/offlinehttp/offlinehttp.go
2070 views
1
package offlinehttp
2
3
import (
4
"github.com/pkg/errors"
5
6
"github.com/projectdiscovery/nuclei/v3/pkg/operators"
7
"github.com/projectdiscovery/nuclei/v3/pkg/protocols"
8
)
9
10
// Request is a offline http response processing request
11
type Request struct {
12
options *protocols.ExecutorOptions
13
compiledOperators []*operators.Operators
14
}
15
16
// RequestPartDefinitions contains a mapping of request part definitions and their
17
// description. Multiple definitions are separated by commas.
18
// Definitions not having a name (generated on runtime) are prefixed & suffixed by <>.
19
var RequestPartDefinitions = map[string]string{
20
"template-id": "ID of the template executed",
21
"template-info": "Info Block of the template executed",
22
"template-path": "Path of the template executed",
23
"host": "Host is the input to the template",
24
"matched": "Matched is the input which was matched upon",
25
"type": "Type is the type of request made",
26
"request": "HTTP request made from the client",
27
"response": "HTTP response received from server",
28
"status_code": "Status Code received from the Server",
29
"body": "HTTP response body received from server (default)",
30
"content_length": "HTTP Response content length",
31
"header,all_headers": "HTTP response headers",
32
"duration": "HTTP request time duration",
33
"all": "HTTP response body + headers",
34
"cookies_from_response": "HTTP response cookies in name:value format",
35
"headers_from_response": "HTTP response headers in name:value format",
36
}
37
38
// GetID returns the unique ID of the request if any.
39
func (request *Request) GetID() string {
40
return ""
41
}
42
43
// Compile compiles the protocol request for further execution.
44
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
45
for _, operator := range options.Operators {
46
if err := operator.Compile(); err != nil {
47
return errors.Wrap(err, "could not compile operators")
48
}
49
request.compiledOperators = append(request.compiledOperators, operator)
50
}
51
request.options = options
52
return nil
53
}
54
55
// Requests returns the total number of requests the YAML rule will perform
56
func (request *Request) Requests() int {
57
return 1
58
}
59
60