mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 22:55:27 +00:00
feat: add -enable-global-matchers flag (#5857)
* feat: add `-enable-global-matchers` flag Signed-off-by: Dwi Siswanto <git@dw1.io> * refactor(templates): use embedded `types.Options` in `Template` Signed-off-by: Dwi Siswanto <git@dw1.io> * feat(lib): add `EnableGlobalMatchersTemplates` SDK opt Signed-off-by: Dwi Siswanto <git@dw1.io> --------- Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
parent
b2d4efef1e
commit
3a07fa9c22
@ -264,6 +264,7 @@ on extensive configurability, massive extensibility and ease of use.`)
|
||||
flagSet.BoolVar(&options.EnableCodeTemplates, "code", false, "enable loading code protocol-based templates"),
|
||||
flagSet.BoolVarP(&options.DisableUnsignedTemplates, "disable-unsigned-templates", "dut", false, "disable running unsigned templates or templates with mismatched signature"),
|
||||
flagSet.BoolVarP(&options.EnableSelfContainedTemplates, "enable-self-contained", "esc", false, "enable loading self-contained templates"),
|
||||
flagSet.BoolVarP(&options.EnableGlobalMatchersTemplates, "enable-global-matchers", "egm", false, "enable loading global matchers templates"),
|
||||
flagSet.BoolVar(&options.EnableFileTemplates, "file", false, "enable loading file templates"),
|
||||
)
|
||||
|
||||
|
||||
@ -393,6 +393,14 @@ func EnableSelfContainedTemplates() NucleiSDKOptions {
|
||||
}
|
||||
}
|
||||
|
||||
// EnableGlobalMatchersTemplates allows loading/executing global-matchers templates
|
||||
func EnableGlobalMatchersTemplates() NucleiSDKOptions {
|
||||
return func(e *NucleiEngine) error {
|
||||
e.opts.EnableGlobalMatchersTemplates = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// EnableFileTemplates allows loading/executing file protocol templates
|
||||
func EnableFileTemplates() NucleiSDKOptions {
|
||||
return func(e *NucleiEngine) error {
|
||||
|
||||
@ -112,7 +112,8 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Executo
|
||||
// isGlobalMatchersEnabled checks if any of requests in the template
|
||||
// have global matchers enabled. It iterates through all requests and
|
||||
// returns true if at least one request has global matchers enabled;
|
||||
// otherwise, it returns false.
|
||||
// otherwise, it returns false. If global matchers templates are not
|
||||
// enabled in the options, the method will immediately return false.
|
||||
//
|
||||
// Note: This method only checks the `RequestsHTTP`
|
||||
// field of the template, which is specific to http-protocol-based
|
||||
@ -120,6 +121,10 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Executo
|
||||
//
|
||||
// TODO: support all protocols.
|
||||
func (template *Template) isGlobalMatchersEnabled() bool {
|
||||
if !template.Options.Options.EnableGlobalMatchersTemplates {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, request := range template.RequestsHTTP {
|
||||
if request.GlobalMatchers {
|
||||
return true
|
||||
|
||||
@ -383,8 +383,10 @@ type Options struct {
|
||||
EnableCodeTemplates bool
|
||||
// DisableUnsignedTemplates disables processing of unsigned templates
|
||||
DisableUnsignedTemplates bool
|
||||
// EnableSelfContainedTemplates disables processing of self-contained templates
|
||||
// EnableSelfContainedTemplates enables processing of self-contained templates
|
||||
EnableSelfContainedTemplates bool
|
||||
// EnableGlobalMatchersTemplates enables processing of global-matchers templates
|
||||
EnableGlobalMatchersTemplates bool
|
||||
// EnableFileTemplates enables file templates
|
||||
EnableFileTemplates bool
|
||||
// Disables cloud upload
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user