Documentation
¶
Overview ¶
Package config provides shared configuration types and validation helpers for pipeleek. This package centralizes common configuration patterns across all platform scanners.
Index ¶
- func AutoBindFlags(cmd *cobra.Command, flagMappings map[string]string) error
- func BindCommandFlags(cmd *cobra.Command, baseKey string, overrides map[string]string) error
- func GetBool(key string) bool
- func GetInt(key string) int
- func GetString(key string) string
- func GetStringSlice(key string) []string
- func GetViper() *viper.Viper
- func InitializeViper(configFile string) error
- func ParseMaxArtifactSize(sizeStr string) (int64, error)
- func RequireConfigKeys(keys ...string) error
- func ResetViper()
- func ValidateThreadCount(threads int) error
- func ValidateToken(token string, fieldName string) error
- func ValidateURL(urlStr string, fieldName string) error
- type AzureDevOpsConfig
- type BitBucketConfig
- type CommonConfig
- type CommonScanOptions
- type Config
- type GitHubConfig
- type GitLabConfig
- type GiteaConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoBindFlags ¶ added in v0.50.0
AutoBindFlags automatically binds all flags from a command to Viper using the provided key mappings.
func BindCommandFlags ¶ added in v0.50.0
BindCommandFlags binds a command's flags (including inherited ones) to Viper keys. Keys are derived from the provided baseKey plus the normalized flag name, unless an override is provided in the overrides map (flag name -> viper key).
Example:
BindCommandFlags(cmd, "gitlab.scan", map[string]string{"gitlab": "gitlab.url"})
--threads -> gitlab.scan.threads
--gitlab -> gitlab.url (override)
func GetStringSlice ¶ added in v0.50.0
func InitializeViper ¶ added in v0.50.0
func ParseMaxArtifactSize ¶
ParseMaxArtifactSize parses a human-readable size string (e.g., "500MB", "1GB") into bytes.
func RequireConfigKeys ¶ added in v0.50.0
RequireConfigKeys validates that all required configuration keys have non-empty values. This allows flags to be satisfied by either CLI flags or config file values. Call this after AutoBindFlags to validate required values from any source.
func ResetViper ¶ added in v0.50.0
func ResetViper()
ResetViper resets the global Viper instance for testing
func ValidateThreadCount ¶
ValidateThreadCount validates that the thread count is within acceptable bounds.
func ValidateToken ¶
ValidateToken validates that a token is not empty.
func ValidateURL ¶
ValidateURL validates that a string is a valid URL.
Types ¶
type AzureDevOpsConfig ¶ added in v0.50.0
type AzureDevOpsConfig struct {
URL string `mapstructure:"url"`
Token string `mapstructure:"token"`
}
AzureDevOpsConfig contains Azure DevOps-specific configuration
type BitBucketConfig ¶ added in v0.50.0
type BitBucketConfig struct {
URL string `mapstructure:"url"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
}
BitBucketConfig contains BitBucket-specific configuration
type CommonConfig ¶ added in v0.50.0
type CommonConfig struct {
Threads int `mapstructure:"threads"`
TruffleHogVerification bool `mapstructure:"trufflehog_verification"`
MaxArtifactSize string `mapstructure:"max_artifact_size"`
ConfidenceFilter []string `mapstructure:"confidence_filter"`
HitTimeout string `mapstructure:"hit_timeout"`
}
CommonConfig contains common configuration settings
type CommonScanOptions ¶
type CommonScanOptions struct {
// ConfidenceFilter filters results by confidence level
ConfidenceFilter []string
// MaxScanGoRoutines controls the number of concurrent scanning threads
MaxScanGoRoutines int
// TruffleHogVerification enables/disables TruffleHog credential verification
TruffleHogVerification bool
// Artifacts enables/disables artifact scanning
Artifacts bool
// MaxArtifactSize is the maximum size of artifacts to scan (in bytes)
MaxArtifactSize int64
// Owned filters to only owned repositories
Owned bool
// HitTimeout is the maximum time to wait for hit detection per scan item
HitTimeout time.Duration
}
CommonScanOptions contains configuration fields that are shared across all platform scanners. This helps reduce duplication and ensures consistency in option handling.
func DefaultCommonScanOptions ¶
func DefaultCommonScanOptions() CommonScanOptions
DefaultCommonScanOptions returns sensible default values for common scan options.
type Config ¶ added in v0.50.0
type Config struct {
GitLab GitLabConfig `mapstructure:"gitlab"`
GitHub GitHubConfig `mapstructure:"github"`
BitBucket BitBucketConfig `mapstructure:"bitbucket"`
AzureDevOps AzureDevOpsConfig `mapstructure:"azure_devops"`
Gitea GiteaConfig `mapstructure:"gitea"`
Common CommonConfig `mapstructure:"common"`
}
Config represents the complete configuration structure for pipeleek. It supports configuration for all platforms and common settings.
func UnmarshalConfig ¶ added in v0.50.0
type GitHubConfig ¶ added in v0.50.0
GitHubConfig contains GitHub-specific configuration
type GitLabConfig ¶ added in v0.50.0
type GitLabConfig struct {
URL string `mapstructure:"url"`
Token string `mapstructure:"token"`
Cookie string `mapstructure:"cookie"`
}
GitLabConfig contains GitLab-specific configuration
type GiteaConfig ¶ added in v0.50.0
GiteaConfig contains Gitea-specific configuration