Documentation ¶
Index ¶
- Constants
- Variables
- func GetNucleiTemplatesIndex() (map[string]string, error)
- func GetSupportTemplateFileExtensions() []string
- func GetTemplateIDFromReader(data io.Reader, filename string) (string, error)
- func IsOutdatedVersion(current, latest string) bool
- func IsTemplate(filename string) bool
- type AppMode
- type Config
- func (c *Config) CanCheckForUpdates() bool
- func (c *Config) DisableUpdateCheck()
- func (c *Config) GetAllCustomTemplateDirs() []string
- func (c *Config) GetCacheDir() string
- func (c *Config) GetChecksumFilePath() string
- func (c *Config) GetConfigDir() string
- func (c *Config) GetFlagsConfigFilePath() string
- func (c *Config) GetIgnoreFilePath() string
- func (c *Config) GetKeysDir() string
- func (c *Config) GetNewAdditions() []string
- func (c *Config) GetReportingConfigFilePath() string
- func (c *Config) GetTemplateDir() string
- func (c *Config) GetTemplateIndexFilePath() string
- func (c *Config) IsCustomTemplate(templatePath string) bool
- func (c *Config) IsDebugArgEnabled(arg string) bool
- func (c *Config) NeedsIgnoreFileUpdate() bool
- func (c *Config) NeedsTemplateUpdate() bool
- func (c *Config) ReadTemplatesConfig() error
- func (c *Config) SetConfigDir(dir string)
- func (c *Config) SetTemplatesDir(dirPath string)
- func (c *Config) SetTemplatesVersion(version string) error
- func (c *Config) UpdateNucleiIgnoreHash() error
- func (c *Config) WriteTemplatesConfig() error
- func (c *Config) WriteTemplatesIndex(index map[string]string) error
- func (c *Config) WriteVersionCheckData(ignorehash, nucleiVersion, templatesVersion string) error
- type IgnoreFile
- type TemplateFormat
Constants ¶
const ( TemplateConfigFileName = ".templates-config.json" NucleiTemplatesDirName = "nuclei-templates" OfficialNucleiTemplatesRepoName = "nuclei-templates" NucleiIgnoreFileName = ".nuclei-ignore" NucleiTemplatesIndexFileName = ".templates-index" // contains index of official nuclei templates NucleiTemplatesCheckSumFileName = ".checksum" NewTemplateAdditionsFileName = ".new-additions" CLIConfigFileName = "config.yaml" ReportingConfigFilename = "reporting-config.yaml" // Version is the current version of nuclei Version = `v3.3.7` // Directory Names of custom templates CustomS3TemplatesDirName = "s3" CustomGitHubTemplatesDirName = "github" CustomAzureTemplatesDirName = "azure" CustomGitLabTemplatesDirName = "gitlab" BinaryName = "nuclei" FallbackConfigFolderName = ".nuclei-config" NucleiConfigDirEnv = "NUCLEI_CONFIG_DIR" )
const ( // DebugArgHostErrorStats is used to print host error stats // when it is closed DebugArgHostErrorStats = "host-error-stats" // DebugExportReqURLPattern is used to export request URL pattern DebugExportURLPattern = "req-url-pattern" )
similar to go pattern of enabling debug related features we add custom/extra switches for debugging purposes
Variables ¶
var ( // Global Var to control behaviours specific to cli or library // maybe this should be moved to utils ?? // this is overwritten in cmd/nuclei/main.go CurrentAppMode = AppModeLibrary )
Functions ¶
func GetNucleiTemplatesIndex ¶
GetTemplatesIndexFile returns map[template-id]: template-file-path
func GetSupportTemplateFileExtensions ¶
func GetSupportTemplateFileExtensions() []string
GetSupportedTemplateFileExtensions returns all supported template file extensions
func GetTemplateIDFromReader ¶
GetTemplateIDFromReader returns template id from reader
func IsOutdatedVersion ¶
IsOutdatedVersion compares two versions and returns true if the current version is outdated
func IsTemplate ¶
isTemplate is a callback function used by goflags to decide if given file should be read if it is not a nuclei-template file only then file is read
Types ¶
type 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 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"` CustomAzureTemplatesDirectory string `json:"custom-azure-templates-directory"` TemplateVersion string `json:"nuclei-templates-version,omitempty"` NucleiIgnoreHash string `json:"nuclei-ignore-hash,omitempty"` LogAllEvents bool `json:"-"` // when enabled logs all events (more than verbose) HideTemplateSigWarning bool `json:"-"` // when enabled disables template signature warning // LatestXXX are not meant to be used directly and is used as // local cache of nuclei version check endpoint // these fields are only update during nuclei version check // TODO: move these fields to a separate unexported struct as they are not meant to be used directly LatestNucleiVersion string `json:"nuclei-latest-version"` LatestNucleiTemplatesVersion string `json:"nuclei-templates-latest-version"` LatestNucleiIgnoreHash string `json:"nuclei-latest-ignore-hash,omitempty"` // contains filtered or unexported fields }
var DefaultConfig *Config
DefaultConfig is the default nuclei configuration all config values and default are centralized here
func (*Config) CanCheckForUpdates ¶
CanCheckForUpdates returns true if update check is enabled
func (*Config) DisableUpdateCheck ¶
func (c *Config) DisableUpdateCheck()
DisableUpdateCheck disables update check and template updates
func (*Config) GetAllCustomTemplateDirs ¶
GetAllCustomTemplateDirs returns all custom template directories
func (*Config) GetCacheDir ¶
GetCacheDir returns the nuclei cache directory with new version of nuclei cache directory is changed instead of saving resume files in nuclei config directory they are saved in nuclei cache directory
func (*Config) GetChecksumFilePath ¶
GetChecksumFilePath returns checksum file path of nuclei templates
func (*Config) GetConfigDir ¶
GetConfigDir returns the nuclei configuration directory
func (*Config) GetFlagsConfigFilePath ¶
GetFlagsConfigFilePath returns the nuclei cli config file path
func (*Config) GetIgnoreFilePath ¶
GetIgnoreFilePath returns the nuclei ignore file path
func (*Config) GetKeysDir ¶
GetKeysDir returns the nuclei signer keys directory
func (*Config) GetNewAdditions ¶
GetNewAdditions returns new template additions in current template release if .new-additions file is not present empty slice is returned
func (*Config) GetReportingConfigFilePath ¶
GetReportingConfigFilePath returns the nuclei reporting config file path
func (*Config) GetTemplateDir ¶
GetTemplateDir returns the nuclei templates directory absolute path
func (*Config) GetTemplateIndexFilePath ¶
func (*Config) IsCustomTemplate ¶
IsCustomTemplate determines whether a given template is custom-built or part of the official Nuclei templates. It checks if the template's path matches any of the predefined custom template directories (such as S3, GitHub, GitLab, and Azure directories). If the template resides in any of these directories, it is considered custom. Additionally, if the template's path does not start with the main Nuclei TemplatesDirectory, it is also considered custom. This function assumes that template paths are either absolute or relative to the same base as the paths configured in DefaultConfig.
func (*Config) IsDebugArgEnabled ¶
IsDebugArgEnabled checks if debug arg is enabled this could be a feature specific to debugging like PPROF or printing stats of max host error etc
func (*Config) NeedsIgnoreFileUpdate ¶
NeedsIgnoreFileUpdate returns true if Ignore file hash is different (aka ignore file is outdated)
func (*Config) NeedsTemplateUpdate ¶
NeedsTemplateUpdate returns true if template installation/update is required
func (*Config) ReadTemplatesConfig ¶
ReadTemplatesConfig reads the nuclei templates config file
func (*Config) SetConfigDir ¶
SetConfigDir sets the nuclei configuration directory and appropriate changes are made to the config
func (*Config) SetTemplatesDir ¶
SetTemplatesDir sets the new nuclei templates directory
func (*Config) SetTemplatesVersion ¶
SetTemplatesVersion sets the new nuclei templates version
func (*Config) UpdateNucleiIgnoreHash ¶
UpdateNucleiIgnoreHash updates the nuclei ignore hash in config
func (*Config) WriteTemplatesConfig ¶
WriteTemplatesConfig writes the nuclei templates config file
func (*Config) WriteTemplatesIndex ¶
WriteTemplatesIndex writes the nuclei templates index file
func (*Config) WriteVersionCheckData ¶
WriteVersionCheckData writes version check data to config file
type IgnoreFile ¶
IgnoreFile is an internal nuclei template blocking configuration file
func ReadIgnoreFile ¶
func ReadIgnoreFile() IgnoreFile
ReadIgnoreFile reads the nuclei ignore file returning blocked tags and paths
type TemplateFormat ¶
type TemplateFormat uint8
TemplateFormat
const ( YAML TemplateFormat = iota JSON Unknown )
func GetTemplateFormatFromExt ¶
func GetTemplateFormatFromExt(filePath string) TemplateFormat
GetTemplateFormatFromExt returns template format