[BUG] Configuring a custom template path in the sdk
Is there an existing issue for this?
- [x] I have searched the existing issues.
Current Behavior
When I install my own directory on the local location of the nuclei templates in sdk
ne, err := nuclei.NewNucleiEngineCtx(
ctx,
nuclei.WithTemplateFilters(nuclei.TemplateFilters{
Tags: params.Filter.Tags,
Severity: params.Filter.Severity,
IDs: params.Filter.TemplateIDs,
}),
nuclei.WithCatalog(disk.NewCatalog(absPath)),
nuclei.DisableUpdateCheck(),
)
if err != nil {
return fmt.Errorf("failed to create nuclei engine: %w", err)
}
loader.New loads the included and excluded templates slice by slice, which are nil by default, so loader.New loads templates only from the default directory.
store := &Store{
id: cfg.StoreId,
config: cfg,
tagFilter: tagFilter,
pathFilter: filter.NewPathFilter(&filter.PathFilterConfig{
IncludedTemplates: cfg.IncludeTemplates,
ExcludedTemplates: cfg.ExcludeTemplates,
}, cfg.Catalog),
finalTemplates: cfg.Templates,
finalWorkflows: cfg.Workflows,
}
Expected Behavior
It was expected to download templates from the catalog installed for the nuclei engine using the command:
nuclei.WithCatalog(disk.NewCatalog(absPath)),
Steps To Reproduce
absPath, err := filepath.Abs(n.pathToTemplates)
if err != nil {
return fmt.Errorf("get absolute path: %w", err)
}
n.logger.Debug("abs path to templates", slog.String("path", absPath))
ne, err := nuclei.NewNucleiEngineCtx(
ctx,
nuclei.WithTemplateFilters(nuclei.TemplateFilters{
Tags: params.Filter.Tags,
Severity: params.Filter.Severity,
IDs: params.Filter.TemplateIDs,
}),
nuclei.WithCatalog(disk.NewCatalog(absPath)),
nuclei.DisableUpdateCheck(),
)
if err != nil {
return fmt.Errorf("failed to create nuclei engine: %w", err)
}
if err := ne.LoadAllTemplates(); err != nil {
return fmt.Errorf("failed load templates: %w", err)
}
Relevant log output
Environment
- OS: Debian 12 (WSL)
- Nuclei: 3.4.0
- Go: go1.24.2
Anything else?
No response
For the time being you need to set the custom directory in the default config:
config.DefaultConfig.TemplatesDirectory = "/path/to/templates"
This is going to be reworked in https://github.com/projectdiscovery/nuclei/issues/5239 - keep an eye on the issue. Thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!
This issue has been automatically closed due to inactivity. If you think this is a mistake or would like to continue the discussion, please comment or feel free to reopen it.