Documentation
¶
Overview ¶
Package config loads and validates scanner configuration.
Structural settings resolve from built-in defaults, a config file, and command-line flags in increasing precedence. Fields ending in _env name environment variables read at the point of use; Prepare checks that an opted-in LLM key is present without retaining its value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RulesDirBesideExecutable ¶
RulesDirBesideExecutable finds rules/<name> next to the running binary, the fallback when no rules directory is configured. It never looks in the working directory, where a scanned target could plant rules that weaken analysis.
func Secret ¶
Secret reads an API key from the environment variable named by env. Returning the value only here keeps keys out of the config struct, and so out of anything that serializes it.
func ValidateBaseline ¶
ValidateBaseline rejects an accepted finding with no reason recorded. A suppression is an audit decision, and an empty reason makes that decision impossible to review later.
Types ¶
type CiscoConfig ¶
type Config ¶
type Config struct {
// Analyzers to run. Empty means every applicable analyzer in the build
Analyzers []string `yaml:"analyzers,omitempty" json:"analyzers,omitempty"`
// BestEffort analyzers do not block the verdict when they fail
BestEffort []string `yaml:"best_effort,omitempty" json:"best_effort,omitempty"`
FailOn string `yaml:"fail_on,omitempty" json:"fail_on,omitempty"`
BlockingSeverity string `yaml:"blocking_severity,omitempty" json:"blocking_severity,omitempty"`
// TolerateUnknown lets a scan that could not finish pass anyway. Off by
// default: a scan that could not determine an answer is not a pass, and
// exit code 3 exists to say so. Turning it on is a deliberate choice to
// treat an incomplete scan as acceptable.
TolerateUnknown bool `yaml:"tolerate_unknown" json:"tolerate_unknown,omitempty"`
ActiveProbes string `yaml:"active_probes,omitempty" json:"active_probes,omitempty"`
// AllowPrivateNetworks lets the scanner connect to loopback, link-local
// and private-range destinations. Off by default, because the usual
// target is untrusted and the interesting destination for a hostile
// server is the network the scanner runs on. Turn it on to scan a server
// on localhost or inside your own network.
AllowPrivateNetworks bool `yaml:"allow_private_networks" json:"allow_private_networks,omitempty"`
// ReadResources and GetPrompts fetch what a server would hand a model, not only declarations.
// Both make target calls, so they require active_probes safe or higher.
ReadResources bool `yaml:"read_resources" json:"read_resources,omitempty"`
GetPrompts bool `yaml:"get_prompts" json:"get_prompts,omitempty"`
AllowToolCalls []string `yaml:"allow_tool_calls,omitempty" json:"allow_tool_calls,omitempty"`
Timeout Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
AnalyzerTimeout Duration `yaml:"analyzer_timeout,omitempty" json:"analyzer_timeout,omitempty"`
Concurrency int `yaml:"concurrency,omitempty" json:"concurrency,omitempty"`
// AnalyzerOptions holds per-analyzer settings, keyed by analyzer name
AnalyzerOptions map[string]map[string]any `yaml:"analyzer_options,omitempty" json:"analyzer_options,omitempty"`
// Baseline maps accepted finding IDs to the reason they are accepted
Baseline map[string]string `yaml:"baseline,omitempty" json:"baseline,omitempty"`
LLM LLMConfig `yaml:"llm,omitempty" json:"llm"`
Cisco CiscoConfig `yaml:"cisco,omitempty" json:"cisco"`
VT VTConfig `yaml:"virustotal,omitempty" json:"virustotal"`
Runtime RuntimeConfig `yaml:"runtime,omitempty" json:"runtime"`
Rules RulesConfig `yaml:"rules,omitempty" json:"rules"`
}
Config is the on-disk configuration. Operator-facing YAML keeps explicit false switches visible where omitting them would hide resolved behavior.
func Defaults ¶
func Defaults() Config
Defaults returns the configuration used when nothing is specified
type Duration ¶
Duration is a time.Duration that reads "30s" from YAML and JSON
func (Duration) MarshalYAML ¶
type LLMConfig ¶
type LLMConfig struct {
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"` // openai | anthropic | bedrock
Model string `yaml:"model,omitempty" json:"model,omitempty"`
BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
APIKeyEnv string `yaml:"api_key_env,omitempty" json:"api_key_env,omitempty"`
MaxTokens int `yaml:"max_tokens,omitempty" json:"max_tokens,omitempty"`
Timeout Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
// AllowInsecureEndpoint permits a plain http base_url. Off by default: the request carries
// an API key and whatever surface or source text is being analyzed, so plaintext exposes
// both to anything on the path.
AllowInsecureEndpoint bool `yaml:"allow_insecure_endpoint,omitempty" json:"allow_insecure_endpoint,omitempty"`
}
LLMConfig configures the semantic-analysis backend. API keys are read from the environment variable named by APIKeyEnv, never stored in the file, so a config can be committed.
type RulesConfig ¶
type RulesConfig struct {
YARADir string `yaml:"yara_dir,omitempty" json:"yara_dir,omitempty"`
PromptDefenseDir string `yaml:"prompt_defense_dir,omitempty" json:"prompt_defense_dir,omitempty"`
}
RulesConfig points at rule directories
type RuntimeConfig ¶
type RuntimeConfig struct {
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
Backend string `yaml:"backend,omitempty" json:"backend,omitempty"` // docker
Image string `yaml:"image,omitempty" json:"image,omitempty"`
// Network only accepts "deny", which leaves loopback but no external network access
Network string `yaml:"network,omitempty" json:"network,omitempty"` // deny
Timeout Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
MemoryMB int `yaml:"memory_mb,omitempty" json:"memory_mb,omitempty"`
CPUs float64 `yaml:"cpus,omitempty" json:"cpus,omitempty"`
PIDLimit int `yaml:"pid_limit,omitempty" json:"pid_limit,omitempty"`
}
RuntimeConfig configures sandboxed execution
type VTConfig ¶
type VTConfig struct {
APIKeyEnv string `yaml:"api_key_env,omitempty" json:"api_key_env,omitempty"`
Timeout Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
// AllowUpload sends unknown files to VirusTotal. Off by default: the file
// being scanned may be someone's proprietary source.
AllowUpload bool `yaml:"allow_upload,omitempty" json:"allow_upload,omitempty"`
}