Skip to content

Commit

Permalink
update template url (#4110)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir authored Sep 1, 2023
1 parent 388c1e8 commit 680fc55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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
}

0 comments on commit 680fc55

Please sign in to comment.