Skip to content

Commit

Permalink
Fix mis-spellings and other comment cleanup (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
kchason authored May 19, 2023
1 parent 280d9d8 commit 42a5918
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions v2/internal/installer/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (t *TemplateManager) installTemplatesAt(dir string) error {
return errorutil.NewWithErr(err).Msgf("failed to create directory at %s", dir)
}
}
ghrd, err := updateutils.NewghReleaseDownloader(config.OfficialNucleiTeamplatesRepoName)
ghrd, err := updateutils.NewghReleaseDownloader(config.OfficialNucleiTemplatesRepoName)
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to install templates at %s", dir)
}
Expand All @@ -116,7 +116,7 @@ func (t *TemplateManager) updateTemplatesAt(dir string) error {
oldchecksums = make(map[string]string)
}

ghrd, err := updateutils.NewghReleaseDownloader(config.OfficialNucleiTeamplatesRepoName)
ghrd, err := updateutils.NewghReleaseDownloader(config.OfficialNucleiTemplatesRepoName)
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to install templates at %s", dir)
}
Expand Down
20 changes: 10 additions & 10 deletions v2/pkg/catalog/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
)

const (
TemplateConfigFileName = ".templates-config.json"
NucleiTemplatesDirName = "nuclei-templates"
OfficialNucleiTeamplatesRepoName = "nuclei-templates"
NucleiIgnoreFileName = ".nuclei-ignore"
NucleiTemplatesCheckSumFileName = ".checksum"
NewTemplateAdditionsFileName = ".new-additions"
CLIConifgFileName = "config.yaml"
ReportingConfigFilename = "reporting-config.yaml"
TemplateConfigFileName = ".templates-config.json"
NucleiTemplatesDirName = "nuclei-templates"
OfficialNucleiTemplatesRepoName = "nuclei-templates"
NucleiIgnoreFileName = ".nuclei-ignore"
NucleiTemplatesCheckSumFileName = ".checksum"
NewTemplateAdditionsFileName = ".new-additions"
CLIConfigFileName = "config.yaml"
ReportingConfigFilename = "reporting-config.yaml"
// Version is the current version of nuclei
Version = `v2.9.4-dev`

Expand All @@ -25,8 +25,7 @@ const (
CustomGitLabTemplatesDirName = "gitlab"
)

// IsOutdatedVersion compares two versions and returns true
// if current version is outdated
// IsOutdatedVersion compares two versions and returns true if the 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
Expand All @@ -44,6 +43,7 @@ func IsOutdatedVersion(current, latest string) bool {
return newVer.GreaterThan(currentVer)
}

// trimDevIfExists trims `-dev` suffix from version string if it exists
func trimDevIfExists(version string) string {
if strings.HasSuffix(version, "-dev") {
return strings.TrimSuffix(version, "-dev")
Expand Down
30 changes: 14 additions & 16 deletions v2/pkg/catalog/config/nucleiconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var DefaultConfig *Config
type Config struct {
TemplatesDirectory string `json:"nuclei-templates-directory,omitempty"`

// customtemplates exists in templates directory with the name of custom-templates provider
// below custom paths are absolute paths to respecitive custom-templates directories
// custom-xxx-templates exists in templates directory with the name of custom-templates provider
// below custom paths are absolute paths to respective custom-templates directories
CustomS3TemplatesDirectory string `json:"custom-s3-templates-directory"`
CustomGithubTemplatesDirectory string `json:"custom-github-templates-directory"`
CustomGitLabTemplatesDirectory string `json:"custom-gitlab-templates-directory"`
Expand All @@ -46,10 +46,10 @@ type Config struct {
}

// WriteVersionCheckData writes version check data to config file
func (c *Config) WriteVersionCheckData(ignorehash, nucleiVersion, templatesVersion string) error {
func (c *Config) WriteVersionCheckData(ignoreHash, nucleiVersion, templatesVersion string) error {
updated := false
if ignorehash != "" && c.LatestNucleiIgnoreHash != ignorehash {
c.LatestNucleiIgnoreHash = ignorehash
if ignoreHash != "" && c.LatestNucleiIgnoreHash != ignoreHash {
c.LatestNucleiIgnoreHash = ignoreHash
updated = true
}
if nucleiVersion != "" && c.LatestNucleiVersion != nucleiVersion {
Expand Down Expand Up @@ -82,7 +82,7 @@ func (c *Config) NeedsTemplateUpdate() bool {
return !c.disableUpdates && (c.TemplateVersion == "" || IsOutdatedVersion(c.TemplateVersion, c.LatestNucleiTemplatesVersion) || !fileutil.FolderExists(c.TemplatesDirectory))
}

// NeedsIngoreFileUpdate returns true if Ignore file hash is different (aka ignore file is outdated)
// NeedsIgnoreFileUpdate returns true if Ignore file hash is different (aka ignore file is outdated)
func (c *Config) NeedsIgnoreFileUpdate() bool {
return c.NucleiIgnoreHash == "" || c.NucleiIgnoreHash != c.LatestNucleiIgnoreHash
}
Expand Down Expand Up @@ -123,18 +123,18 @@ func (c *Config) GetIgnoreFilePath() string {
return filepath.Join(c.configDir, NucleiIgnoreFileName)
}

// GetTemplatesConfigFilePath returns checksum file path of nuclei templates
// GetChecksumFilePath returns checksum file path of nuclei templates
func (c *Config) GetChecksumFilePath() string {
return filepath.Join(c.TemplatesDirectory, NucleiTemplatesCheckSumFileName)
}

// GetCLIOptsConfigFilePath returns the nuclei cli config file path
// GetFlagsConfigFilePath returns the nuclei cli config file path
func (c *Config) GetFlagsConfigFilePath() string {
return filepath.Join(c.configDir, CLIConifgFileName)
return filepath.Join(c.configDir, CLIConfigFileName)
}

// GetNewAdditions returns new template additions in current template release
// if .new-additions file is not present empty slice is returned
// GetNewAdditions returns new template additions in current template release if .new-additions file is not present
// empty slice is returned
func (c *Config) GetNewAdditions() []string {
arr := []string{}
newAdditionsPath := filepath.Join(c.TemplatesDirectory, NewTemplateAdditionsFileName)
Expand All @@ -153,8 +153,7 @@ func (c *Config) GetNewAdditions() []string {
return arr
}

// SetConfigDir sets the nuclei configuration directory
// and appropriate changes are made to the config
// SetConfigDir sets the nuclei configuration directory and appropriate changes are made to the config
func (c *Config) SetConfigDir(dir string) {
c.configDir = dir
if err := c.createConfigDirIfNotExists(); err != nil {
Expand Down Expand Up @@ -252,8 +251,7 @@ func (c *Config) createConfigDirIfNotExists() error {
return nil
}

// copyIgnoreFile copies the nuclei ignore file default config directory
// to the current config directory
// copyIgnoreFile copies the nuclei ignore file default config directory to the current config directory
func (c *Config) copyIgnoreFile() {
if err := c.createConfigDirIfNotExists(); err != nil {
gologger.Error().Msgf("Could not create nuclei config directory at %s: %s", c.configDir, err)
Expand Down Expand Up @@ -308,7 +306,7 @@ func getDefaultConfigDir() string {
return filepath.Join(userCfgDir, "nuclei")
}

// Add Default Config adds default when .templates-config.json file is not present
// applyDefaultConfig adds default when .templates-config.json file is not present
func applyDefaultConfig() {
DefaultConfig.TemplatesDirectory = filepath.Join(DefaultConfig.homeDir, NucleiTemplatesDirName)
// updates all necessary paths
Expand Down
4 changes: 2 additions & 2 deletions v2/pkg/external/customtemplates/templates_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewCustomTemplatesManager(options *types.Options) (*CustomTemplatesManager,
return ctm, nil
}

// Add github providers
// Add GitHub providers
githubProviders, err := NewGithubProviders(options)
if err != nil {
return nil, errorutil.NewWithErr(err).Msgf("could not create github providers for custom templates")
Expand All @@ -49,7 +49,7 @@ func NewCustomTemplatesManager(options *types.Options) (*CustomTemplatesManager,
ctm.providers = append(ctm.providers, v)
}

// Add Aws S3 providers
// Add AWS S3 providers
s3Providers, err := NewS3Providers(options)
if err != nil {
return nil, errorutil.NewWithErr(err).Msgf("could not create s3 providers for custom templates")
Expand Down

0 comments on commit 42a5918

Please sign in to comment.