config

package
v0.0.0-...-fda2f5e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	ScanModeConnect = "connect"
	ScanModeSYN     = "syn"
)

Scan modes.

View Source
const (
	EnvLocal              = "local"
	EnvContainer          = "container"
	EnvServerlessJob      = "serverless-job"
	EnvServerlessFunction = "serverless-function"
)

Environment labels recorded in the report.

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

View Source
const EnvPrefix = "FASTRECON_"

EnvPrefix is prepended to every derived environment-variable name.

View Source
const StdoutPath = "-"

StdoutPath is the Output value that selects the stdout sink.

Variables

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

func DetectEnvironment(explicit string, serveMode bool) string

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

func EnvName(flag string) string

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

func NormalizeDomain(d string) (string, error)

NormalizeDomain lowercases a root domain and rejects anything that is not one: a URL, a path, a wildcard, a single label.

func RegisterFlags

func RegisterFlags(fs *pflag.FlagSet)

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

func Load(fs *pflag.FlagSet) (*Config, error)

Load resolves a configuration from parsed flags, the environment and an optional config file, then validates it.

func LoadServe

func LoadServe(fs *pflag.FlagSet) (*Config, error)

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

func (c *Config) Clone() *Config

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

func (c *Config) HasTargets() bool

HasTargets reports whether the run scans a supplied list rather than enumerating.

func (*Config) Sinks

func (c *Config) Sinks() (stdout, file, webhook bool)

Sinks reports which destinations are configured.

func (*Config) Validate

func (c *Config) Validate() error

Validate normalizes the configuration and reports every problem at once, rather than one per run.

Jump to

Keyboard shortcuts

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