Documentation
¶
Overview ¶
Package config resolves the run configuration.
Every option is settable three ways and the precedence is always the same:
CLI flag > environment variable > config file > built-in default
The names are mechanically related: a flag named "http-timeout" reads the environment variable FASTRECON_HTTP_TIMEOUT and the config-file key "http-timeout". That rule is what lets a serverless job be configured entirely through environment variables without a config file.
Index ¶
Constants ¶
const ( ScanModeConnect = "connect" ScanModeSYN = "syn" )
Scan modes.
const ( EnvLocal = "local" EnvContainer = "container" EnvServerlessJob = "serverless-job" EnvServerlessFunction = "serverless-function" )
Environment labels recorded in the report.
const AutoConfig = "auto"
AutoConfig is the --config value that opts into the user config directory. Without it nothing outside the explicitly given paths is read, so a container run never depends on what happens to be in $HOME.
const EnvPrefix = "FASTRECON_"
EnvPrefix is prepended to every derived environment-variable name.
const StdoutPath = "-"
StdoutPath is the Output value that selects the stdout sink.
Variables ¶
var RequiredSources = []string{"chaos", "securitytrails", "c99", "crt"}
RequiredSources is the default source selection: the sources a run is expected to use. The keyed ones report themselves as skipped when no credential is configured, rather than being silently dropped.
chaos ProjectDiscovery Chaos key required securitytrails SecurityTrails key required c99 c99.nl key required crt crt.name key optional
Functions ¶
func DetectEnvironment ¶
DetectEnvironment labels the runtime for the report.
Only local and container are detectable from inside the process: a serverless job looks like a plain container, so the job and function labels come from the deployment setting --environment (FASTRECON_ENVIRONMENT), as the manifests in deploy/ do. Guessing from undocumented platform variables would mislabel runs the day the platform renames one.
func EnvName ¶
EnvName derives the environment variable for a flag: "http-timeout" becomes FASTRECON_HTTP_TIMEOUT. The mapping is mechanical on purpose — there is no per-option table to fall out of sync with the flag set.
func NormalizeDomain ¶
NormalizeDomain lowercases a root domain and rejects anything that is not one: a URL, a path, a wildcard, a single label.
func RegisterFlags ¶
RegisterFlags defines the full option surface. Defaults live here and nowhere else, so `--help` is the reference for what a run does by default.
Types ¶
type Config ¶
type Config struct {
// Target
Domain string
// Targets replaces enumeration: the run scans exactly these hosts. It is
// the only shape in which a missing answer means something.
Targets []string
TargetsFile string
TargetsURL string
TargetsHeader []string
Exclude []string
ExcludeFile string
ExcludeStrictWildcard bool
ReportExcluded bool
// Pipeline
Scope stage.Scope
Timeout time.Duration
// OutputMargin is the fraction of the total budget reserved for building
// and delivering the report, so a deadline yields a truncated report
// instead of a killed process.
OutputMargin float64
// Enumeration
ProviderConfig string
Sources []string
ExcludeSources []string
AllSources bool
SourceTimeout time.Duration
// Resolution
Resolvers []string
ResolversFile string
ResolversURL string
ValidateResolvers bool
ResolverHealthBudget time.Duration
ResolverConcurrency int
ResolverRetries int
ResolverTimeout time.Duration
WildcardProbes int
// Port scan
ScanMode string
Ports string
ExcludePorts string
SkipCDN bool
ScanConcurrency int
ScanRate int
ScanTimeout time.Duration
ScanRetries int
// HTTP probe
ProbeSPKI bool
ProbeConcurrency int
ProbeRate int
ProbeRetries int
ProbeTimeout time.Duration
ProbeFollowRedirects bool
ProbeMaxRedirects int
ProbeUserAgent string
ProbeHeaders []string
// Output
Output string
Format report.Format
WebhookURL string
WebhookMethod string
WebhookHeaders []string
WebhookTimeout time.Duration
WebhookRetries int
// Process
LogLevel string
LogFormat string
Environment string
ConfigFile string
// Serve mode
Listen string
APIToken string
// Warnings collected while resolving, surfaced in the report so a config
// typo is not silently ignored.
Warnings []string
// Degraded carries machine-readable codes for conditions settled before
// the run starts, alongside Warnings.
Degraded []string
}
Config is the fully resolved configuration of a single run.
func Load ¶
Load resolves a configuration from parsed flags, the environment and an optional config file, then validates it.
func LoadServe ¶
LoadServe is Load for the HTTP handler, where the domain is not known at startup: it arrives with each request and is validated then, by the same rules.
func (*Config) Clone ¶
Clone deep-copies the configuration.
A served request overlays its fields onto the process configuration, so the copy must be independent: a shared slice would leak one request's exclusions into the next.
func (*Config) HasTargets ¶
HasTargets reports whether the run scans a supplied list rather than enumerating.