MCPcopy Create free account
hub / github.com/chainreactors/spray / AddCustomExtractor

Function AddCustomExtractor

pkg/proton.go:101–129  ·  view source on GitHub ↗

AddCustomExtractor creates a one-off regex extractor at runtime (for --extract ).

(name, pattern string)

Source from the content-addressed store, hash-verified

99
100// AddCustomExtractor creates a one-off regex extractor at runtime (for --extract <regex>).
101func AddCustomExtractor(name, pattern string) {
102 protonMu.Lock()
103 defer protonMu.Unlock()
104
105 req := &file.Request{
106 Extensions: []string{"all"},
107 }
108 req.Operators.Extractors = append(req.Operators.Extractors, &operators.Extractor{
109 Name: name,
110 Type: "regex",
111 Regex: []string{pattern},
112 })
113 opts := &protocols.ExecuterOptions{Options: &protocols.Options{}}
114 if err := req.Compile(opts); err != nil {
115 return
116 }
117
118 tmpl := &protonTmpl.Template{
119 Id: "custom-" + name,
120 RequestsFile: []*file.Request{req},
121 }
122 tmpl.Info.Name = name
123 tmpl.Info.Severity = "info"
124 tmpl.Info.Tags = "spray, custom"
125
126 protonTemplates = append(protonTemplates, tmpl)
127 protonTemplateMap[tmpl.Id] = tmpl
128 rebuildScanner()
129}
130
131// EnableExtractors activates a subset of templates by name or tag.
132// Called after LoadProtonTemplates to filter what runs during scanning.

Callers 2

PrepareMethod · 0.92
TestAddCustomExtractorFunction · 0.85

Calls 1

rebuildScannerFunction · 0.85

Tested by 1

TestAddCustomExtractorFunction · 0.68