removing err

This commit is contained in:
mzack 2024-03-15 13:36:57 +01:00
parent d988de45f6
commit 2dd8c8c5ae
9 changed files with 10 additions and 24 deletions

View File

@ -100,8 +100,6 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
ratelimiter := ratelimit.New(context.Background(), 150, time.Second) ratelimiter := ratelimit.New(context.Background(), 150, time.Second)
defer ratelimiter.Stop() defer ratelimiter.Stop()
parser, _ := templates.NewParser()
executerOpts := protocols.ExecutorOptions{ executerOpts := protocols.ExecutorOptions{
Output: outputWriter, Output: outputWriter,
Options: defaultOpts, Options: defaultOpts,
@ -113,7 +111,7 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
HostErrorsCache: cache, HostErrorsCache: cache,
Colorizer: aurora.NewAurora(true), Colorizer: aurora.NewAurora(true),
ResumeCfg: types.NewResumeCfg(), ResumeCfg: types.NewResumeCfg(),
Parser: parser, Parser: templates.NewParser(),
} }
engine := core.New(defaultOpts) engine := core.New(defaultOpts)
engine.SetExecuterOptions(executerOpts) engine.SetExecuterOptions(executerOpts)

View File

@ -150,10 +150,7 @@ func New(options *types.Options) (*Runner, error) {
} }
} }
parser, err := templates.NewParser() parser := templates.NewParser()
if err != nil {
return nil, err
}
if options.Validate { if options.Validate {
parser.ShouldValidate = true parser.ShouldValidate = true

View File

@ -114,11 +114,7 @@ func (e *NucleiEngine) init() error {
e.httpClient = httpclient e.httpClient = httpclient
} }
if parser, err := templates.NewParser(); err != nil { e.parser = templates.NewParser()
return err
} else {
e.parser = parser
}
_ = protocolstate.Init(e.opts) _ = protocolstate.Init(e.opts)
_ = protocolinit.Init(e.opts) _ = protocolinit.Init(e.opts)

View File

@ -31,7 +31,6 @@ func setup() {
options := testutils.DefaultOptions options := testutils.DefaultOptions
testutils.Init(options) testutils.Init(options)
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0) progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
parser, _ = templates.NewParser()
executerOpts = protocols.ExecutorOptions{ executerOpts = protocols.ExecutorOptions{
Output: testutils.NewMockOutputWriter(options.OmitTemplate), Output: testutils.NewMockOutputWriter(options.OmitTemplate),
@ -42,7 +41,7 @@ func setup() {
Browser: nil, Browser: nil,
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory), Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second), RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
Parser: parser, Parser: templates.NewParser(),
} }
workflowLoader, err := workflow.NewLoader(&executerOpts) workflowLoader, err := workflow.NewLoader(&executerOpts)
if err != nil { if err != nil {

View File

@ -37,7 +37,6 @@ func setup() {
options := testutils.DefaultOptions options := testutils.DefaultOptions
testutils.Init(options) testutils.Init(options)
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0) progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
parser, _ := templates.NewParser()
executerOpts = protocols.ExecutorOptions{ executerOpts = protocols.ExecutorOptions{
Output: testutils.NewMockOutputWriter(options.OmitTemplate), Output: testutils.NewMockOutputWriter(options.OmitTemplate),
@ -48,7 +47,7 @@ func setup() {
Browser: nil, Browser: nil,
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory), Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second), RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
Parser: parser, Parser: templates.NewParser(),
} }
workflowLoader, err := workflow.NewLoader(&executerOpts) workflowLoader, err := workflow.NewLoader(&executerOpts)
if err != nil { if err != nil {

View File

@ -24,13 +24,13 @@ type Parser struct {
compiledTemplatesCache *Cache compiledTemplatesCache *Cache
} }
func NewParser() (*Parser, error) { func NewParser() *Parser {
p := &Parser{ p := &Parser{
parsedTemplatesCache: NewCache(), parsedTemplatesCache: NewCache(),
compiledTemplatesCache: NewCache(), compiledTemplatesCache: NewCache(),
} }
return p, nil return p
} }
// LoadTemplate returns true if the template is valid and matches the filtering criteria. // LoadTemplate returns true if the template is valid and matches the filtering criteria.

View File

@ -14,8 +14,7 @@ import (
func TestLoadTemplate(t *testing.T) { func TestLoadTemplate(t *testing.T) {
catalog := disk.NewCatalog("") catalog := disk.NewCatalog("")
p, err := NewParser() p := NewParser()
require.Nil(t, err)
tt := []struct { tt := []struct {
name string name string

View File

@ -25,7 +25,6 @@ func setup() {
options := testutils.DefaultOptions options := testutils.DefaultOptions
testutils.Init(options) testutils.Init(options)
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0) progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
parser, _ := templates.NewParser()
executerOpts = protocols.ExecutorOptions{ executerOpts = protocols.ExecutorOptions{
Output: testutils.NewMockOutputWriter(options.OmitTemplate), Output: testutils.NewMockOutputWriter(options.OmitTemplate),
@ -36,7 +35,7 @@ func setup() {
Browser: nil, Browser: nil,
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory), Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second), RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
Parser: parser, Parser: templates.NewParser(),
} }
workflowLoader, err := workflow.NewLoader(&executerOpts) workflowLoader, err := workflow.NewLoader(&executerOpts)
if err != nil { if err != nil {

View File

@ -25,7 +25,6 @@ func setup() {
options := testutils.DefaultOptions options := testutils.DefaultOptions
testutils.Init(options) testutils.Init(options)
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0) progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
parser, _ := templates.NewParser()
executerOpts = protocols.ExecutorOptions{ executerOpts = protocols.ExecutorOptions{
Output: testutils.NewMockOutputWriter(options.OmitTemplate), Output: testutils.NewMockOutputWriter(options.OmitTemplate),
@ -36,7 +35,7 @@ func setup() {
Browser: nil, Browser: nil,
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory), Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second), RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
Parser: parser, Parser: templates.NewParser(),
} }
workflowLoader, err := workflow.NewLoader(&executerOpts) workflowLoader, err := workflow.NewLoader(&executerOpts)
if err != nil { if err != nil {