2021-11-22 17:53:25 +05:30
|
|
|
package utils
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
2023-10-17 17:44:13 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
|
2021-11-22 17:53:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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/"
|
2021-11-22 17:53:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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) {
|
2021-11-22 17:53:25 +05:30
|
|
|
var templateDirectory string
|
2023-04-19 21:58:48 +05:30
|
|
|
configData := config.DefaultConfig
|
|
|
|
|
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
|
2021-11-22 17:53:25 +05:30
|
|
|
templateDirectory = configData.TemplatesDirectory
|
|
|
|
|
} else {
|
|
|
|
|
return "", ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/")
|
2023-09-01 21:10:55 +03:00
|
|
|
templateURL := TemplatesRepoURL + templateId
|
2021-11-22 17:53:25 +05:30
|
|
|
return finalPath, templateURL
|
|
|
|
|
}
|