mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 03:15:25 +00:00
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
|
|
package config
|
||
|
|
|
||
|
|
import (
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"github.com/Masterminds/semver/v3"
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
TemplateConfigFileName = ".templates-config.json"
|
||
|
|
NucleiTemplatesDirName = "nuclei-templates"
|
||
|
|
CustomS3TemplatesDirName = "s3"
|
||
|
|
CustomGithubTemplatesDirName = "github"
|
||
|
|
OfficialNucleiTeamplatesRepoName = "nuclei-templates"
|
||
|
|
NucleiIgnoreFileName = ".nuclei-ignore"
|
||
|
|
NucleiTemplatesCheckSumFileName = ".checksum"
|
||
|
|
NewTemplateAdditionsFileName = ".new-additions"
|
||
|
|
CLIConifgFileName = "config.yaml"
|
||
|
|
ReportingConfigFilename = "reporting-config.yaml"
|
||
|
|
// Version is the current version of nuclei
|
||
|
|
Version = `v2.9.2-dev`
|
||
|
|
)
|
||
|
|
|
||
|
|
// IsOutdatedVersion compares two versions and returns true
|
||
|
|
// if current version is outdated
|
||
|
|
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)
|
||
|
|
}
|
||
|
|
|
||
|
|
func trimDevIfExists(version string) string {
|
||
|
|
if strings.HasSuffix(version, "-dev") {
|
||
|
|
return strings.TrimSuffix(version, "-dev")
|
||
|
|
}
|
||
|
|
return version
|
||
|
|
}
|