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"
|
2024-09-19 18:58:20 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/keys"
|
2021-11-22 17:53:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// TemplatesRepoURL is the URL for files in nuclei-templates repository
|
2023-11-28 22:05:58 +05:30
|
|
|
TemplatesRepoURL = "https://cloud.projectdiscovery.io/public/"
|
2021-11-22 17:53:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TemplatePathURL returns the Path and URL for the provided template
|
2024-09-19 18:58:20 +05:30
|
|
|
func TemplatePathURL(fullPath, templateId, templateVerifier string) (path string, url string) {
|
2023-04-19 21:58:48 +05:30
|
|
|
configData := config.DefaultConfig
|
|
|
|
|
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
|
2024-09-19 18:58:20 +05:30
|
|
|
path = strings.TrimPrefix(strings.TrimPrefix(fullPath, configData.TemplatesDirectory), "/")
|
2021-11-22 17:53:25 +05:30
|
|
|
}
|
2024-09-19 18:58:20 +05:30
|
|
|
if templateVerifier == keys.PDVerifier {
|
|
|
|
|
url = TemplatesRepoURL + templateId
|
|
|
|
|
}
|
|
|
|
|
return
|
2021-11-22 17:53:25 +05:30
|
|
|
}
|