config

package
v3.2.7-fix1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
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.2.7`
	// Directory Names of custom templates
	CustomS3TemplatesDirName     = "s3"
	CustomGitHubTemplatesDirName = "github"
	CustomAzureTemplatesDirName  = "azure"
	CustomGitLabTemplatesDirName = "gitlab"
	BinaryName                   = "nuclei"
	FallbackConfigFolderName     = ".nuclei-config"
	NucleiConfigDirEnv           = "NUCLEI_CONFIG_DIR"
)

Variables

View Source
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

func GetNucleiTemplatesIndex() (map[string]string, error)

GetTemplatesIndexFile returns map[template-id]: template-file-path

func GetSupportTemplateFileExtensions

func GetSupportTemplateFileExtensions() []string

GetSupportedTemplateFileExtensions returns all supported template file extensions

func GetTemplateIDFromReader

func GetTemplateIDFromReader(data io.Reader, filename string) (string, error)

GetTemplateIDFromReader returns template id from reader

func IsOutdatedVersion

func IsOutdatedVersion(current, latest string) bool

IsOutdatedVersion compares two versions and returns true if the current version is outdated

func IsTemplate

func IsTemplate(filename string) bool

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 AppMode

type AppMode string
const (
	AppModeLibrary AppMode = "library"
	AppModeCLI     AppMode = "cli"
)

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

func (c *Config) CanCheckForUpdates() bool

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

func (c *Config) GetAllCustomTemplateDirs() []string

GetAllCustomTemplateDirs returns all custom template directories

func (*Config) GetCacheDir

func (c *Config) GetCacheDir() string

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

func (c *Config) GetChecksumFilePath() string

GetChecksumFilePath returns checksum file path of nuclei templates

func (*Config) GetConfigDir

func (c *Config) GetConfigDir() string

GetConfigDir returns the nuclei configuration directory

func (*Config) GetFlagsConfigFilePath

func (c *Config) GetFlagsConfigFilePath() string

GetFlagsConfigFilePath returns the nuclei cli config file path

func (*Config) GetIgnoreFilePath

func (c *Config) GetIgnoreFilePath() string

GetIgnoreFilePath returns the nuclei ignore file path

func (*Config) GetKeysDir

func (c *Config) GetKeysDir() string

GetKeysDir returns the nuclei signer keys directory

func (*Config) GetNewAdditions

func (c *Config) GetNewAdditions() []string

GetNewAdditions returns new template additions in current template release if .new-additions file is not present empty slice is returned

func (*Config) GetReportingConfigFilePath

func (c *Config) GetReportingConfigFilePath() string

GetReportingConfigFilePath returns the nuclei reporting config file path

func (*Config) GetTemplateDir

func (c *Config) GetTemplateDir() string

GetTemplateDir returns the nuclei templates directory absolute path

func (*Config) GetTemplateIndexFilePath

func (c *Config) GetTemplateIndexFilePath() string

func (*Config) IsCustomTemplate

func (c *Config) IsCustomTemplate(templatePath string) bool

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) NeedsIgnoreFileUpdate

func (c *Config) NeedsIgnoreFileUpdate() bool

NeedsIgnoreFileUpdate returns true if Ignore file hash is different (aka ignore file is outdated)

func (*Config) NeedsTemplateUpdate

func (c *Config) NeedsTemplateUpdate() bool

NeedsTemplateUpdate returns true if template installation/update is required

func (*Config) ReadTemplatesConfig

func (c *Config) ReadTemplatesConfig() error

ReadTemplatesConfig reads the nuclei templates config file

func (*Config) SetConfigDir

func (c *Config) SetConfigDir(dir string)

SetConfigDir sets the nuclei configuration directory and appropriate changes are made to the config

func (*Config) SetTemplatesDir

func (c *Config) SetTemplatesDir(dirPath string)

SetTemplatesDir sets the new nuclei templates directory

func (*Config) SetTemplatesVersion

func (c *Config) SetTemplatesVersion(version string) error

SetTemplatesVersion sets the new nuclei templates version

func (*Config) UpdateNucleiIgnoreHash

func (c *Config) UpdateNucleiIgnoreHash() error

UpdateNucleiIgnoreHash updates the nuclei ignore hash in config

func (*Config) WriteTemplatesConfig

func (c *Config) WriteTemplatesConfig() error

WriteTemplatesConfig writes the nuclei templates config file

func (*Config) WriteTemplatesIndex

func (c *Config) WriteTemplatesIndex(index map[string]string) error

WriteTemplatesIndex writes the nuclei templates index file

func (*Config) WriteVersionCheckData

func (c *Config) WriteVersionCheckData(ignorehash, nucleiVersion, templatesVersion string) error

WriteVersionCheckData writes version check data to config file

type IgnoreFile

type IgnoreFile struct {
	Tags  []string `yaml:"tags"`
	Files []string `yaml:"files"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL