Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update template url #4110

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions v2/pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func NewStandardWriter(options *types.Options) (*StandardWriter, error) {
func (w *StandardWriter) Write(event *ResultEvent) error {
// Enrich the result event with extra metadata on the template-path and url.
if event.TemplatePath != "" {
event.Template, event.TemplateURL = utils.TemplatePathURL(types.ToString(event.TemplatePath))
event.Template, event.TemplateURL = utils.TemplatePathURL(types.ToString(event.TemplatePath), types.ToString(event.TemplateID))
}
event.Timestamp = time.Now()

Expand Down Expand Up @@ -327,7 +327,7 @@ func (w *StandardWriter) WriteFailure(wrappedEvent *InternalWrappedEvent) error
// if no results were found, manually create a failure event
event := wrappedEvent.InternalEvent

templatePath, templateURL := utils.TemplatePathURL(types.ToString(event["template-path"]))
templatePath, templateURL := utils.TemplatePathURL(types.ToString(event["template-path"]), types.ToString(event["template-id"]))
var templateInfo model.Info
if event["template-info"] != nil {
templateInfo = event["template-info"].(model.Info)
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (m *MockOutputWriter) WriteFailure(wrappedEvent *output.InternalWrappedEven
if m.WriteCallback != nil {
// create event
event := wrappedEvent.InternalEvent
templatePath, templateURL := utils.TemplatePathURL(types.ToString(event["template-path"]))
templatePath, templateURL := utils.TemplatePathURL(types.ToString(event["template-path"]), types.ToString(event["template-id"]))
var templateInfo model.Info
if ti, ok := event["template-info"].(model.Info); ok {
templateInfo = ti
Expand Down
6 changes: 3 additions & 3 deletions v2/pkg/utils/template_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

const (
// TemplatesRepoURL is the URL for files in nuclei-templates repository
TemplatesRepoURL = "https://github.com/projectdiscovery/nuclei-templates/blob/main/"
TemplatesRepoURL = "https://templates.nuclei.sh/public/"
)

// TemplatePathURL returns the Path and URL for the provided template
func TemplatePathURL(fullPath string) (string, string) {
func TemplatePathURL(fullPath, templateId string) (string, string) {
var templateDirectory string
configData := config.DefaultConfig
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
Expand All @@ -22,6 +22,6 @@ func TemplatePathURL(fullPath string) (string, string) {
}

finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/")
templateURL := TemplatesRepoURL + finalPath
templateURL := TemplatesRepoURL + templateId
return finalPath, templateURL
}
Loading