2023-04-19 21:58:48 +05:30
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/Masterminds/semver/v3"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
2023-06-26 14:15:12 +02:00
|
|
|
TemplateConfigFileName = ".templates-config.json"
|
|
|
|
|
NucleiTemplatesDirName = "nuclei-templates"
|
2023-05-28 17:12:23 +05:30
|
|
|
OfficialNucleiTemplatesRepoName = "nuclei-templates"
|
2023-06-26 14:15:12 +02:00
|
|
|
NucleiIgnoreFileName = ".nuclei-ignore"
|
|
|
|
|
NucleiTemplatesIndexFileName = ".templates-index" // contains index of official nuclei templates
|
|
|
|
|
NucleiTemplatesCheckSumFileName = ".checksum"
|
|
|
|
|
NewTemplateAdditionsFileName = ".new-additions"
|
|
|
|
|
CLIConifgFileName = "config.yaml"
|
|
|
|
|
ReportingConfigFilename = "reporting-config.yaml"
|
2023-04-19 21:58:48 +05:30
|
|
|
// Version is the current version of nuclei
|
2023-07-03 18:24:01 +05:30
|
|
|
Version = `v2.9.8`
|
2023-04-19 17:42:52 -04:00
|
|
|
// Directory Names of custom templates
|
|
|
|
|
CustomS3TemplatesDirName = "s3"
|
|
|
|
|
CustomGithubTemplatesDirName = "github"
|
|
|
|
|
CustomAzureTemplatesDirName = "azure"
|
|
|
|
|
CustomGitLabTemplatesDirName = "gitlab"
|
2023-04-19 21:58:48 +05:30
|
|
|
)
|
|
|
|
|
|
2023-05-19 11:36:39 -04:00
|
|
|
// IsOutdatedVersion compares two versions and returns true if the current version is outdated
|
2023-04-19 21:58:48 +05:30
|
|
|
func IsOutdatedVersion(current, latest string) bool {
|
|
|
|
|
if latest == "" {
|
|
|
|
|
// if pdtm api call failed it's assumed that current version is outdated
|
|
|
|
|
// and it will be confirmed while updating from github
|
|
|
|
|
// this fixes `version string empty` errors
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
current = trimDevIfExists(current)
|
|
|
|
|
currentVer, _ := semver.NewVersion(current)
|
|
|
|
|
newVer, _ := semver.NewVersion(latest)
|
|
|
|
|
if currentVer == nil || newVer == nil {
|
|
|
|
|
// fallback to naive comparison
|
|
|
|
|
return current == latest
|
|
|
|
|
}
|
|
|
|
|
return newVer.GreaterThan(currentVer)
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 11:36:39 -04:00
|
|
|
// trimDevIfExists trims `-dev` suffix from version string if it exists
|
2023-04-19 21:58:48 +05:30
|
|
|
func trimDevIfExists(version string) string {
|
|
|
|
|
if strings.HasSuffix(version, "-dev") {
|
|
|
|
|
return strings.TrimSuffix(version, "-dev")
|
|
|
|
|
}
|
|
|
|
|
return version
|
|
|
|
|
}
|