mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 21:25:27 +00:00
Replace error constant with an error type
This commit is contained in:
parent
f5ea35d45c
commit
30f6498fe2
@ -2,7 +2,6 @@ package loader
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/projectdiscovery/gologger"
|
"github.com/projectdiscovery/gologger"
|
||||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||||
@ -139,7 +138,7 @@ func areWorkflowOrTemplatesValid(store *Store, filteredTemplatePaths map[string]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isParsingError(message string, template string, err error) bool {
|
func isParsingError(message string, template string, err error) bool {
|
||||||
if strings.Contains(err.Error(), templates.TemplateExecuterCreationErrorMessage) {
|
if err == templates.ErrCreateTemplateExecutor {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if err == filter.ErrExcluded {
|
if err == filter.ErrExcluded {
|
||||||
|
|||||||
@ -19,10 +19,11 @@ import (
|
|||||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TemplateExecuterCreationErrorMessage = "cannot create template executer"
|
var (
|
||||||
|
ErrCreateTemplateExecutor = errors.New("cannot create template executer")
|
||||||
var parsedTemplatesCache = cache.New()
|
parsedTemplatesCache = cache.New()
|
||||||
var fieldErrorRegexp = regexp.MustCompile(`not found in`)
|
fieldErrorRegexp = regexp.MustCompile(`not found in`)
|
||||||
|
)
|
||||||
|
|
||||||
// Parse parses a yaml request template file
|
// Parse parses a yaml request template file
|
||||||
//nolint:gocritic // this cannot be passed by pointer
|
//nolint:gocritic // this cannot be passed by pointer
|
||||||
@ -142,7 +143,7 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Execute
|
|||||||
template.TotalRequests += template.Executer.Requests()
|
template.TotalRequests += template.Executer.Requests()
|
||||||
}
|
}
|
||||||
if template.Executer == nil && template.CompiledWorkflow == nil {
|
if template.Executer == nil && template.CompiledWorkflow == nil {
|
||||||
return nil, errors.New(TemplateExecuterCreationErrorMessage)
|
return nil, ErrCreateTemplateExecutor
|
||||||
}
|
}
|
||||||
template.Path = filePath
|
template.Path = filePath
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user