nuclei/v2/pkg/utils/template_path.go

28 lines
798 B
Go
Raw Normal View History

package utils
import (
"strings"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
)
const (
// TemplatesRepoURL is the URL for files in nuclei-templates repository
2023-09-01 21:10:55 +03:00
TemplatesRepoURL = "https://templates.nuclei.sh/public/"
)
// TemplatePathURL returns the Path and URL for the provided template
2023-09-01 21:10:55 +03:00
func TemplatePathURL(fullPath, templateId string) (string, string) {
var templateDirectory string
configData := config.DefaultConfig
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
templateDirectory = configData.TemplatesDirectory
} else {
return "", ""
}
finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/")
2023-09-01 21:10:55 +03:00
templateURL := TemplatesRepoURL + templateId
return finalPath, templateURL
}