Documentation
¶
Overview ¶
Package tlsinspect connects to TLS endpoints (directly or via STARTTLS), inspects the negotiated session and certificate chain, and combines the raw-probe scanner results into a full scan report.
Index ¶
- Constants
- func DiffSnapshots(a, b Snapshot) []certificate.Change
- func LooksLikeTarget(s string) bool
- type ChainCert
- type Connector
- func (c *Connector) Addr() string
- func (c *Connector) Certificates(ctx context.Context) ([]*x509.Certificate, error)
- func (c *Connector) Dial(ctx context.Context) (net.Conn, error)
- func (c *Connector) Inspect(ctx context.Context, o InspectOptions) (*Result, error)
- func (c *Connector) Prober(concurrency int) *scanner.Prober
- func (c *Connector) Scan(ctx context.Context, o ScanOptions) (*ScanResult, error)
- func (c *Connector) Transcript() []string
- type Finding
- type InspectOptions
- type OCSPInfo
- type Options
- type Result
- type ScanOptions
- type ScanResult
- type SessionInfo
- type Snapshot
- type SummaryItem
- type Target
- type Validation
Constants ¶
const ( Critical = "critical" High = "high" Medium = "medium" Low = "low" Info = "info" )
Severity levels for scan findings, following common vulnerability reporting practice. There is no aggregate score.
Variables ¶
This section is empty.
Functions ¶
func DiffSnapshots ¶
func DiffSnapshots(a, b Snapshot) []certificate.Change
DiffSnapshots compares two observations. Version and cipher lists are only compared when both observations are full scans.
func LooksLikeTarget ¶
LooksLikeTarget reports whether s is a network target rather than a file: it contains a URL scheme or a host:port.
Types ¶
type ChainCert ¶
type ChainCert struct {
Position int `json:"position"`
Subject string `json:"subject"`
Issuer string `json:"issuer"`
NotAfter time.Time `json:"not_after"`
SHA256 string `json:"sha256"`
Key string `json:"key"`
Signature string `json:"signature_algorithm"`
IsCA bool `json:"is_ca"`
SelfSigned bool `json:"self_signed"`
IssuedByNext bool `json:"issued_by_next"` // chain order check
}
ChainCert is one certificate as presented by the server.
type Connector ¶
type Connector struct {
Target Target
Adapter protocol.Adapter
Detection protocol.Detection
SNI string
IPs []string // resolved addresses (empty when using a proxy)
// contains filtered or unexported fields
}
Connector opens connections that are ready for a ClientHello.
func NewConnector ¶
NewConnector resolves the target and determines how to reach TLS.
func (*Connector) Certificates ¶
Certificates fetches the presented chain (used by `cert import host:port`).
func (*Connector) Scan ¶
func (c *Connector) Scan(ctx context.Context, o ScanOptions) (*ScanResult, error)
Scan runs inspection plus version, cipher, group and behaviour probes.
func (*Connector) Transcript ¶
Transcript returns the plaintext negotiation of the first connection.
type Finding ¶
type Finding struct {
ID string `json:"id"`
Severity string `json:"severity"`
What string `json:"what"`
Why string `json:"why"`
Evidence string `json:"evidence"`
Reference string `json:"reference,omitempty"`
}
Finding is one factual scan observation with its rationale.
type InspectOptions ¶
type InspectOptions struct {
Roots *x509.CertPool // nil = system trust store
TrustStoreName string // for display
Hostname string // name to validate; default SNI or host
ALPN []string // default depends on protocol
Resumption bool // test session resumption (one extra handshake)
Now time.Time
WarningDays int
}
InspectOptions control Inspect.
type OCSPInfo ¶
type OCSPInfo struct {
Stapled bool `json:"stapled"`
Status string `json:"status,omitempty"` // good, revoked, unknown
ProducedAt time.Time `json:"produced_at,omitempty"`
ThisUpdate time.Time `json:"this_update,omitempty"`
NextUpdate time.Time `json:"next_update,omitempty"`
RevokedAt time.Time `json:"revoked_at,omitempty"`
Error string `json:"error,omitempty"`
Responders []string `json:"responders,omitempty"`
MustStaple bool `json:"must_staple"`
}
OCSPInfo describes a stapled OCSP response.
type Options ¶
type Options struct {
Dialer netdial.Dialer
Protocol string // explicit --protocol
SNI string // override; "" = host (omitted for IP targets)
IP string // connect to this address instead of resolving
Timeout time.Duration // per connection
}
Options control how endpoints are reached.
type Result ¶
type Result struct {
Target string `json:"target"`
Host string `json:"host"`
Port int `json:"port"`
SNI string `json:"sni,omitempty"`
IPs []string `json:"resolved_ips,omitempty"`
ConnectedTo string `json:"connected_to"`
Protocol protocol.Detection `json:"protocol"`
Transcript []string `json:"starttls_transcript,omitempty"`
TLS SessionInfo `json:"tls"`
Certificate *certificate.Info `json:"certificate,omitempty"`
Chain []ChainCert `json:"chain"`
Validation Validation `json:"validation"`
OCSP *OCSPInfo `json:"ocsp,omitempty"`
Findings []certificate.Finding `json:"certificate_findings"`
Duration string `json:"duration"`
Error string `json:"error,omitempty"` // handshake error when only partial data is available
}
Result is the JSON schema of `tls inspect`.
type ScanOptions ¶
type ScanOptions struct {
Inspect InspectOptions
Concurrency int
SkipCiphers bool
}
ScanOptions control Scan.
type ScanResult ¶
type ScanResult struct {
Connection *Result `json:"connection"`
Versions []scanner.VersionResult `json:"versions"`
Ciphers []scanner.CipherResult `json:"ciphers,omitempty"`
Groups scanner.GroupResult `json:"groups"`
Behaviour scanner.Extras `json:"behaviour"`
Summary []SummaryItem `json:"summary"`
Findings []Finding `json:"findings"`
ScannedAt time.Time `json:"scanned_at"`
Duration string `json:"duration"`
}
ScanResult is the JSON schema of `tls scan`.
func (*ScanResult) AllSuites ¶
func (r *ScanResult) AllSuites() []scanner.AcceptedSuite
AllSuites returns every accepted suite across versions.
func (*ScanResult) UniqueSuites ¶
func (r *ScanResult) UniqueSuites() ([]scanner.AcceptedSuite, map[uint16][]string)
UniqueSuites returns each accepted suite once, with the versions that accept it.
type SessionInfo ¶
type SessionInfo struct {
Version string `json:"version"`
Cipher string `json:"cipher"`
CipherStrength string `json:"cipher_strength"`
KeyExchangeGroup string `json:"key_exchange_group,omitempty"`
ALPN string `json:"alpn,omitempty"`
OfferedALPN []string `json:"offered_alpn,omitempty"`
HelloRetryRequest bool `json:"hello_retry_request"`
OCSPStapled bool `json:"ocsp_stapled"`
SCTsInHandshake int `json:"scts_in_handshake"`
SessionResumption *bool `json:"session_resumption,omitempty"`
Handshake string `json:"handshake"` // go (full handshake) or probe (certificate only)
}
SessionInfo describes the negotiated session.
type Snapshot ¶
type Snapshot struct {
Kind string `json:"kind"` // inspect or scan
Target string `json:"target"`
Protocol string `json:"protocol"`
ScannedAt time.Time `json:"scanned_at"`
LeafSHA256 string `json:"leaf_sha256"`
Subject string `json:"subject"`
Issuer string `json:"issuer"`
SANs []string `json:"sans"`
NotAfter time.Time `json:"not_after"`
Key string `json:"key"`
Trusted bool `json:"trusted"`
Negotiated string `json:"negotiated_version"`
Cipher string `json:"negotiated_cipher"`
Versions []string `json:"versions,omitempty"` // scan only
Suites []string `json:"cipher_suites,omitempty"`
}
Snapshot is the compact record of one observation kept in history. It holds exactly the properties whose changes are worth detecting.
type SummaryItem ¶
type SummaryItem struct {
Check string `json:"check"`
Status string `json:"status"` // PASS, FAIL, WARN, ENABLED, DISABLED, NONE, ...
Level string `json:"level"` // good, warn, bad, info: how to read the status
Detail string `json:"detail,omitempty"`
}
SummaryItem is one line of the scan summary table.
type Target ¶
type Target struct {
Host string
Port int
Protocol string // from a URL scheme or --protocol; "" = autodetect
}
Target is a parsed endpoint specification.
func ParseTarget ¶
ParseTarget accepts host, host:port, [v6]:port and scheme://host[:port][/path].
type Validation ¶
type Validation struct {
Trusted bool `json:"trusted"`
TrustStore string `json:"trust_store"`
HostnameValid bool `json:"hostname_valid"`
Hostname string `json:"hostname"`
ChainOrdered bool `json:"chain_ordered"`
VerifiedChain []string `json:"verified_chain,omitempty"`
Missing []string `json:"missing_intermediates,omitempty"` // supplied by the verifier, not the server
Error string `json:"error,omitempty"`
Reason string `json:"reason,omitempty"`
}
Validation summarises trust.