Documentation
¶
Overview ¶
Package assetdiscovery turns attack-surface growth into tenant notifications: newly discovered internet-facing assets, and existing assets a re-scan turned internet-facing. Each notice is one in-app `asset_discovered` notification plus one `new_asset` outbox event (fanned out to the tenant's Slack/Teams/email/webhook/SIEM integrations that opted into it).
A single recon run can create thousands of assets across many ingest batches, so notifications are coalesced per tenant with a throttle:
- The first internet-facing discovery for a tenant notifies immediately (leading edge) and opens a cool-down window.
- Discoveries arriving during the window are buffered (deduplicated by asset id) and sent as ONE summary when the window closes (trailing edge), which opens the next window.
- An empty window closes quietly and the tenant is back to idle.
So a tenant receives at most one notification per window however large the run, and none is lost while the process is up. State is in-memory and per-process: with N API replicas a tenant can get up to N per window, and a buffered summary is lost on a hard stop (Stop flushes on graceful shutdown). The authoritative record is the `appeared` state history the ingest pipeline writes, which the "What changed" view reads.
Index ¶
Constants ¶
const ( // DefaultWindow is the per-tenant cool-down between two notifications. DefaultWindow = 15 * time.Minute // ChangesURL is the UI "What changed" page (Discovery > What changed). ChangesURL = "/assets/changes" )
Variables ¶
This section is empty.
Functions ¶
func IsInternetFacing ¶
IsInternetFacing reports whether an asset is reachable from the internet.
Types ¶
type Enqueuer ¶
type Enqueuer interface {
Enqueue(ctx context.Context, params outbox.EnqueueParams) error
}
Enqueuer is the slice of outbox.Service the notifier needs.
type InAppNotifier ¶
type InAppNotifier interface {
Notify(ctx context.Context, params notification.NotificationParams) error
}
InAppNotifier is the slice of the in-app notification service it needs.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier coalesces internet-facing discoveries into throttled notifications.
func NewNotifier ¶
func NewNotifier(o Enqueuer, inApp InAppNotifier, window time.Duration, log *logger.Logger) *Notifier
NewNotifier builds a notifier. Either sink may be nil (that channel is then skipped); window <= 0 uses DefaultWindow.
func (*Notifier) AssetsDiscovered ¶
AssetsDiscovered is the ingest callback for newly created assets: it keeps the internet-facing ones and either notifies now (tenant idle) or buffers them for the end-of-window summary.
func (*Notifier) AssetsExposed ¶
AssetsExposed is the ingest callback for existing assets a re-scan turned internet-facing. They share the tenant's window with new discoveries.