config

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ScanTypeGo indicates Golang files
	ScanTypeGo = "go"
	// ScanTypeYaml indicates YAML files
	ScanTypeYaml = "yaml"
	// ScanTypeJSON indicates JSON files
	ScanTypeJSON = "json"
	// ScanTypeProperties indicates properties files
	ScanTypeProperties = "properties"
	// ScanTypePrivateKey indicates private key files
	ScanTypePrivateKey = "privatekey"
	// ScanTypeXML indicates XML files
	ScanTypeXML = "xml"
	// ScanTypePHP indicates PHP files
	ScanTypePHP = "php"
	// ScanTypeBash indicates Bash files
	ScanTypeBash = "bash"
	// ScanTypeGeneric indicates a file parsable as generic text
	ScanTypeGeneric = "generic"
	// ScanTypeGenericCode indicates a file parsable as generic code
	ScanTypeGenericCode = "generic_code"
	// ScanTypeJavaScript indicates JavaScript files
	ScanTypeJavaScript = "javascript"
	// ScanTypeTypeScript indicates TypeScript files
	ScanTypeTypeScript = "typescript"
	// ScanTypeHTML indicates HTML files
	ScanTypeHTML = "html"
)

Variables

View Source
var (
	//ScanPath is the path which should be scanned
	ScanPath string
)

Functions

This section is empty.

Types

type Config

type Config struct {
	VariableNamePatterns             []string `yaml:"variableNamePatterns,flow"`
	VariableNameExclusionPattern     string   `yaml:"variableNameExclusionPattern"`
	XMLAttributeNameExclusionPattern string   `yaml:"xmlAttributeNameExclusionPattern"`

	ValueMatchPatterns           []ValueMatchPattern `yaml:"valueMatchPatterns,flow"`
	FullTextValueExcludePatterns []string            `yaml:"fullTextValueExcludePatterns,flow"`
	VariableValueExcludePatterns []string            `yaml:"variableValueExcludePatterns,flow"`
	MinPasswordLength            int                 `yaml:"minPasswordLength"`

	ExcludeTests    bool `yaml:"excludeTests"`
	ExcludeComments bool `yaml:"excludeComments"`

	TestDirectories []string `yaml:"testDirectories,flow"`
	IgnoreFiles     []string `yaml:"ignoreFiles,flow"`

	ScanTypes                 []string `yaml:"scanTypes,flow"`
	GenericFileExtensions     []string `yaml:"genericFileExtensions"`
	GenericCodeFileExtensions []string `yaml:"genericCodeFileExtensions"`

	DisableOutputColors bool `yaml:"disableOutputColors"`
	Verbose             bool `yaml:"verbose"`
}

Config contains all the configuration for the credential detector

func LoadConfig

func LoadConfig(configPath, rootConfigPath string) (*Config, error)

LoadConfig loads configuration based on the provided config path and root config path. If rootConfigPath is empty, the default will be used

func MergeConfigs added in v1.17.0

func MergeConfigs(root *Config, additions *Config) *Config

MergeConfigs merges the additions config on top of the root config. Scalar fields are replaced when non-zero; list fields are appended.

func New added in v1.6.0

func New() (*Config, error)

New returns a new configuration

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

ParseConfig parses the given YAML file data into a configuration object

func (Config) IsIgnoreFile added in v1.7.1

func (c Config) IsIgnoreFile(dir string) bool

IsIgnoreFile returns true if the given file/directory matches one of the configured files to ignore

func (Config) IsTestDirectory

func (c Config) IsTestDirectory(dir string) bool

IsTestDirectory returns true if the given directory matches one of the configured test directories

type ValueMatchPattern added in v1.10.0

type ValueMatchPattern struct {
	Name    string `yaml:"name"`
	Pattern string `yaml:"pattern"`
}

ValueMatchPattern is a tuple of pattern and name

Jump to

Keyboard shortcuts

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