Documentation
¶
Overview ¶
Package server is the product's HTTP surface: the JSON API, the embedded UI, the scan runner and the scheduler.
Index ¶
- Variables
- func AuditActionOf(route string) (kind, action string)
- func AuditCoverage(route string) string
- func TLSConfig(certs []tls.Certificate) *tls.Config
- type AcceptResult
- type AnchorCert
- type BulkResult
- type CollectorBinary
- type Config
- type Discoverer
- type DiscoveryOptions
- type FlatFinding
- type Guard
- func (g Guard) CheckDomain(domain string) error
- func (g Guard) CheckIP(ip net.IP) error
- func (g Guard) CheckLiteral(host string) error
- func (g Guard) CheckTarget(ctx context.Context, host string) error
- func (g Guard) Control(_, address string, _ syscall.RawConn) error
- func (g Guard) Dial(ctx context.Context, network, addr string) (net.Conn, error)
- func (g Guard) ForTarget(host string) Guard
- func (g Guard) LookupIP(ctx context.Context, host string) ([]net.IP, error)
- type HostAlgorithm
- type HostCoverage
- type HostLegacy
- type HostSummary
- type Runner
- func (r *Runner) CABundle() []AnchorCert
- func (r *Runner) CRLLookups() bool
- func (r *Runner) Cancel(scanID int64)
- func (r *Runner) Evaluate(rep *tlsprobe.Report, assetID int64) eval.Evaluation
- func (r *Runner) EvaluateSSH(rep *sshprobe.Report) eval.Evaluation
- func (r *Runner) HTTPChecks() bool
- func (r *Runner) Notify()
- func (r *Runner) Reevaluate(scanID int64, why string) (ev eval.Evaluation, err error)
- func (r *Runner) ReevaluateOutdated() int
- func (r *Runner) ReevaluateSystem(systemID int64, why string) int
- func (r *Runner) ScanConfig() ScanConfig
- func (r *Runner) Start(ctx context.Context)
- func (r *Runner) Wait()
- type RunnerOptions
- type ScanConfig
- type Scope
- type SensorCoverage
- type Server
Constants ¶
This section is empty.
Variables ¶
var ErrBlocked = errors.New("target address is not allowed")
ErrBlocked is wrapped by every refusal.
var ErrDiscoveryBusy = errors.New("a discovery is already running; wait for it to finish or cancel it")
ErrDiscoveryBusy means a discovery is already running; one runs at a time.
Functions ¶
func AuditActionOf ¶
AuditActionOf is the object kind and action an audited route records (tests).
func AuditCoverage ¶
AuditCoverage reports, for tests, which table a route is in: "audited", "self" or "".
func TLSConfig ¶
func TLSConfig(certs []tls.Certificate) *tls.Config
TLSConfig is the configuration of the server's own HTTPS listener (PRD-007 REQ-SS-1). It is what this product's own rules call good: TLS 1.2 and 1.3 only; in TLS 1.2 only ECDHE suites with authenticated encryption (no CBC, no RSA key transport, no 64-bit ciphers); in TLS 1.3 Go's suites, and Go's default groups, which offer the hybrid X25519MLKEM768 first. A test scans a listener built from this with the product's own scanner and expects no finding.
Types ¶
type AcceptResult ¶ added in v0.9.0
type AcceptResult struct {
Name string `json:"name"`
Target string `json:"target"`
Status string `json:"status"` // added | duplicate | invalid
Reason string `json:"reason,omitempty"`
}
AcceptResult is the outcome for one endpoint an accepted name became.
type AnchorCert ¶
type AnchorCert struct {
Cert *x509.Certificate
SHA string
}
AnchorCert is a parsed CA certificate accepted as a private anchor.
func ParseAnchors ¶
func ParseAnchors(pemText []byte, max int) ([]AnchorCert, error)
ParseAnchors reads PEM text under the certificate-only rules: any private-key block refuses the whole upload (it is counted, never decoded), and every certificate must be a CA. It returns the certificates or a reason.
type BulkResult ¶
type BulkResult struct {
Line int `json:"line"`
Input string `json:"input"`
Status string `json:"status"` // added | duplicate | invalid
Reason string `json:"reason,omitempty"`
Asset *assetView `json:"asset,omitempty"`
}
BulkResult is the outcome for one line of a bulk add (AC-01.2).
type CollectorBinary ¶
type CollectorBinary struct {
OS string `json:"os"`
Arch string `json:"arch"`
Filename string `json:"filename"`
Size int64 `json:"sizeBytes"`
SHA256 string `json:"sha256"`
// Primary is true for the binary built for the platform this server itself runs on: the
// obvious one to offer first, since it is very likely also the platform of the machine
// being inventoried.
Primary bool `json:"primary"`
// contains filtered or unexported fields
}
CollectorBinary is one collector binary this server found on disk and can serve.
type Config ¶
type Config struct {
Store *store.Store
Runner *Runner
Guard Guard
// Token, if set, is required as a bearer token on every API call. With no
// token the API is unauthenticated and the server must be bound to loopback
// (the caller enforces that), and the Host header is checked to defeat DNS
// rebinding.
Token string
// AllowedHosts are extra Host header values accepted when no token is set.
AllowedHosts []string
// TrustedProxies are the reverse proxies whose X-Forwarded-For header names the real client,
// for rate limits and the sign-in log. A request from any other peer is taken at its word.
TrustedProxies []*net.IPNet
// Sign-in (ADR-0018, UX-REVIEW-008 S3) is off by default and turned on in Settings, which keeps
// the choice in the store. RequireLogin forces it on (--sign-in on) and ForbidLogin forces it
// off (--sign-in off); neither can then be changed in the interface. With sign-in on, every API
// call needs a signed-in session or the automation Token.
RequireLogin bool
ForbidLogin bool
// AllowOpen says sign-in may be off: the server listens on loopback only, or the operator
// accepted an open server on the network (--open-network). Without it, Settings cannot turn
// sign-in off.
AllowOpen bool
// SetupCode is the one-time code that creates the first administrator; printed by serve.
SetupCode string
// SetupCodeExpires is when the setup code stops working (zero: never, for tests).
SetupCodeExpires time.Time
// SecureCookies marks the session cookie Secure on every response. Without it the cookie is
// Secure when the request came over TLS or a proxy sent X-Forwarded-Proto: https.
SecureCookies bool
// SessionIdle and SessionMax end a session after inactivity and in any case (defaults 30 min, 12 h).
SessionIdle, SessionMax time.Duration
Version string
RegistryRetrieved string
EvalVersion string
MaxConcurrentScans int
Log *slog.Logger
Now func() time.Time
// Discovery finds the host names under a domain (PRD-022). Nil leaves its routes answering
// that the feature is not available.
Discovery *Discoverer
// MCP, when set, is served at /mcp behind the same identification as the API (a bearer token
// or a signed-in session; the local operator when sign-in is off). It is the Model Context
// Protocol handler serve --mcp builds (PRD-020); nil leaves the path unregistered.
MCP http.Handler
}
Config configures the HTTP server.
type Discoverer ¶ added in v0.9.0
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer runs discoveries in the background, one at a time.
func NewDiscoverer ¶ added in v0.9.0
func NewDiscoverer(st *store.Store, guard Guard, opts DiscoveryOptions) *Discoverer
NewDiscoverer creates a Discoverer. Call Start before the first run.
func (*Discoverer) Begin ¶ added in v0.9.0
func (d *Discoverer) Begin(domain string, sources, list []string, actor string) (store.Discovery, error)
Begin starts a run and returns its record. Only one runs at a time.
func (*Discoverer) CTAllowed ¶ added in v0.9.0
func (d *Discoverer) CTAllowed() bool
CTAllowed reports whether Settings allows the Certificate Transparency source.
func (*Discoverer) CTService ¶ added in v0.9.0
func (d *Discoverer) CTService() string
CTService names the Certificate Transparency service a run would ask.
func (*Discoverer) Cancel ¶ added in v0.9.0
func (d *Discoverer) Cancel(id int64)
Cancel stops a running discovery.
func (*Discoverer) Start ¶ added in v0.9.0
func (d *Discoverer) Start(ctx context.Context)
Start sets the context every run lives under: when it ends, running discoveries stop.
func (*Discoverer) Wait ¶ added in v0.9.0
func (d *Discoverer) Wait()
Wait blocks until no discovery is running.
type DiscoveryOptions ¶ added in v0.9.0
type DiscoveryOptions struct {
// Resolver answers DNS queries (default: the system resolver).
Resolver namefind.Resolver
// CT searches Certificate Transparency when the setting allows it (default: crt.sh).
CT namefind.CTSearcher
// Timeout bounds one whole run (default 2 hours).
Timeout time.Duration
// QPS limits DNS queries per second (default 50).
QPS int
// Dial replaces the guarded dialer of the port checks (tests).
Dial func(ctx context.Context, address string, port int) (net.Conn, error)
Log *slog.Logger
}
DiscoveryOptions configures the Discoverer.
type FlatFinding ¶
type FlatFinding struct {
AssetID int64 `json:"assetId"`
AssetName string `json:"assetName"`
AssetKind string `json:"assetKind"`
// Key identifies the finding within its asset: a rule ID ("CIPHER.RC4") for
// a TLS finding, or "pqc:<algorithm name>" for a host algorithm verdict.
Key string `json:"key"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Severity string `json:"severity,omitempty"`
Category string `json:"category,omitempty"`
Evidence string `json:"evidence,omitempty"`
Class string `json:"class,omitempty"`
Citations []eval.Citation `json:"citations,omitempty"`
Remediation string `json:"remediation,omitempty"`
Status *store.FindingStatus `json:"status,omitempty"`
}
FlatFinding is one triageable finding, from either a TLS scan's evaluation or a host's CBOM algorithm classification. The two source systems have different shapes — an eval.Finding carries a severity tier; a host's pqc-derived verdict only has a vulnerable/safe class — so this never claims a host finding has a severity it doesn't have: Severity is set only for TLS findings, Class only for host findings.
type Guard ¶
type Guard struct {
AllowLoopback bool
// Public refuses every address that is not on the public internet.
Public bool
// Scope, when set, limits scans further to the operator's --scan-allow list.
Scope *Scope
// contains filtered or unexported fields
}
Guard decides which addresses a scan may connect to. A scanner that dials user-supplied targets is an SSRF vector, so the rule is enforced where it cannot be bypassed: on the actual remote address of every connection, in the dialer's Control hook (after DNS, before connect), which also defeats DNS rebinding.
Refused always: unspecified, multicast, broadcast and link-local addresses (which includes the 169.254.169.254 cloud-metadata endpoint), plus a few well-known metadata addresses outside those ranges. Loopback is refused unless AllowLoopback is set. Private (RFC 1918) ranges are allowed: scanning internal systems is the point of a self-hosted tool.
Public is the stricter profile for a scanner offered to anyone ("tls scan --public"): only addresses on the public internet are allowed. It also refuses loopback (AllowLoopback is ignored), private, carrier-NAT, unique-local, documentation, benchmark and reserved ranges, and judges an IPv6 address that embeds an IPv4 one by the embedded address.
func (Guard) CheckDomain ¶ added in v0.9.0
CheckDomain decides whether names under domain may be looked for (REQ-DD-10). Without a scan scope any domain may. With one, the domain must be inside a scope domain, or the scope must have networks: then each found name is checked against them, and refused when outside.
func (Guard) CheckLiteral ¶
CheckLiteral checks a host that is an IP literal; names are checked when they are resolved and again when connected to.
func (Guard) CheckTarget ¶
CheckTarget decides whether an endpoint may be added (REQ-AC-1, add-time). An address must be allowed by the Guard and, with a scope, be inside it. A name must be under a scope domain or, failing that, resolve only to addresses inside the scope's networks; it is checked again on every connection.
func (Guard) Control ¶
Control is a net.Dialer Control hook that refuses blocked remote addresses at connect time.
type HostAlgorithm ¶
type HostAlgorithm struct {
Name string `json:"name"`
OID string `json:"oid,omitempty"`
Class string `json:"class"`
MatchedBy string `json:"matchedBy"`
Rationale string `json:"rationale"`
Basis []pqc.Reference `json:"basis"`
ProvidedBy []string `json:"providedBy"` // package names; capability, not observed use
}
HostAlgorithm is one algorithm found in a host's CBOM with its verdict.
type HostCoverage ¶
type HostCoverage struct {
OS string `json:"os,omitempty"`
Privilege string `json:"privilege,omitempty"` // user | admin | root
Note string `json:"note,omitempty"`
Sensors []SensorCoverage `json:"sensors"`
NotSeen []string `json:"notSeen"`
Redacted bool `json:"redacted,omitempty"` // the host name is a stable label, not the real one
}
HostCoverage says how complete an uploaded inventory is: which privilege it ran with, what each sensor covered and what none of them could see. Its absence (an older or third-party CBOM) means "not recorded", never "complete".
type HostLegacy ¶
type HostLegacy struct {
Name string `json:"name"`
Status string `json:"status"`
Basis string `json:"basis"`
ProvidedBy []string `json:"providedBy"`
}
HostLegacy is one retired or broken algorithm found on a host.
type HostSummary ¶
type HostSummary struct {
Name string `json:"name"`
Producer string `json:"producer,omitempty"`
Components int `json:"components"`
Packages int `json:"packages"`
Vulnerable int `json:"vulnerable"`
Safe int `json:"safe"`
Unclassified []string `json:"unclassified"`
Algorithms []HostAlgorithm `json:"algorithms"`
Timestamp string `json:"timestamp,omitempty"`
// Coverage is how complete the inventory is; nil when the CBOM does not say.
Coverage *HostCoverage `json:"coverage,omitempty"`
// Legacy lists algorithms the CBOM marks as retired or broken for classical
// reasons, each with the source it cites. This is separate from the post-quantum
// verdict: MD5 is not "quantum-vulnerable", it is unsafe against today's computers.
Legacy []HostLegacy `json:"legacy"`
}
HostSummary is the analysis of an uploaded CBOM.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes queued scans and triggers scheduled ones.
func NewRunner ¶
func NewRunner(st *store.Store, guard Guard, opts RunnerOptions) *Runner
NewRunner creates a runner. Call Start to begin work.
func (*Runner) CABundle ¶
func (r *Runner) CABundle() []AnchorCert
CABundle returns the server-wide private CA bundle.
func (*Runner) CRLLookups ¶ added in v0.4.1
CRLLookups reports whether this runner's scans fetch the CRLs certificates name: the effective value, Settings over the command line.
func (*Runner) Cancel ¶
Cancel stops a running scan. (A queued scan is simply marked canceled in the store.)
func (*Runner) EvaluateSSH ¶
func (r *Runner) EvaluateSSH(rep *sshprobe.Report) eval.Evaluation
EvaluateSSH judges an SSH report with the server's clock.
func (*Runner) HTTPChecks ¶
HTTPChecks reports whether this runner's scans send the HTTP-layer check (HSTS): the effective value, Settings over the command line.
func (*Runner) Reevaluate ¶
Reevaluate recomputes a completed scan's evaluation from its stored report with the current anchors, reference data and time. The report is untouched.
A panic while evaluating is returned as an error: this runs at startup over every stored report, and one report the rules choke on must not keep the server from starting.
func (*Runner) ReevaluateOutdated ¶
ReevaluateOutdated re-evaluates the latest completed scan of every endpoint whose stored evaluation was made by an earlier rule set, so the current view never shows a conclusion the current rules would not draw. Older scans keep the evaluation they were given (history shows what was concluded then). It returns how many changed.
func (*Runner) ReevaluateSystem ¶
ReevaluateSystem re-evaluates the latest completed scan of every endpoint of a system (after its anchors change). It returns how many were re-evaluated.
func (*Runner) ScanConfig ¶ added in v0.5.1
func (r *Runner) ScanConfig() ScanConfig
ScanConfig is the effective scan configuration, for the API.
type RunnerOptions ¶
type RunnerOptions struct {
// Workers is how many scans may run at once (default 2).
Workers int
// Scan holds the per-scan limits (timeout, connection concurrency and budget).
Scan tlsprobe.Options
// SchedulerInterval is how often due scheduled scans are looked for (default 10s).
SchedulerInterval time.Duration
// ScanTimeout bounds one whole scan (default 10 minutes).
ScanTimeout time.Duration
// MaintenanceInterval is how often derived data is repaired (store.Maintain): a graph
// left stale by a failed projection is rebuilt and orphans are swept (default 5 minutes).
MaintenanceInterval time.Duration
Now func() time.Time
// CABundle is the server-wide private CA bundle (--ca-bundle), applied to
// every evaluation as "your CA bundle" (REQ-TTRS-2).
CABundle []AnchorCert
// CRLPrivate is the command line's --revocation-private: whether CRL lookups may reach
// private and loopback addresses. Settings can override it (scansettings.go).
CRLPrivate bool
// Log receives what the runner could not do: a store write that failed, a scan that
// panicked. Default: discarded.
Log *slog.Logger
}
RunnerOptions configures the scan runner.
type ScanConfig ¶ added in v0.5.1
type ScanConfig struct {
HTTPChecks bool `json:"httpChecks"`
CRL bool `json:"crlLookups"`
CRLPrivate bool `json:"crlPrivate"`
// Defaults are the command line's values, shown so "reset" is meaningful.
Defaults struct {
HTTPChecks bool `json:"httpChecks"`
CRL bool `json:"crlLookups"`
CRLPrivate bool `json:"crlPrivate"`
} `json:"defaults"`
// Overridden names the values Settings changed from the command line.
Overridden []string `json:"overridden"`
}
ScanConfig is the effective scan configuration and where each value comes from.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope limits what may be scanned beyond the Guard's fixed rules (PRD-007 REQ-AC-1): the operator's --scan-allow list of networks (a CIDR or a single address) and domains (a name and every name under it). An empty scope allows everything the Guard allows.
A target is in scope when its name is under one of the domains, or when every address it connects to is inside one of the networks. The networks are enforced where the Guard is, on the real remote address of every connection, so a name that is changed to point elsewhere after it was added is refused when the scan connects.
func ParseScope ¶
ParseScope reads --scan-allow entries: "10.0.0.0/8", "192.0.2.7", "example.com" or ".example.com" (the two domain forms mean the same).
type SensorCoverage ¶
type SensorCoverage struct {
Sensor string `json:"sensor"`
Status string `json:"status"` // complete | partial | unsupported | failed
Reason string `json:"reason,omitempty"`
Denied int `json:"denied,omitempty"`
Scope string `json:"scope,omitempty"`
}
SensorCoverage is what one sensor covered on the host, as the collector recorded it.
Source Files
¶
- accounts.go
- api.go
- audit.go
- certificates.go
- coverage.go
- discovery.go
- downloads.go
- estate.go
- evaluate.go
- findings.go
- guard.go
- imports.go
- ingest.go
- inventory.go
- inventory_dashboard.go
- links.go
- m2302.go
- openapi.go
- pdfreports.go
- runner.go
- scansettings.go
- scripts.go
- server.go
- settings.go
- ssh.go
- standards.go
- systems.go
- target.go
- tlsconfig.go
- trust.go
- x509.go