assetdiscovery

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: GPL-3.0 Imports: 13 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 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

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

func IsInternetFacing(a *asset.Asset) bool

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

func (n *Notifier) AssetsDiscovered(ctx context.Context, tenantID shared.ID, assets []*asset.Asset)

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

func (n *Notifier) AssetsExposed(ctx context.Context, tenantID shared.ID, assets []*asset.Asset)

AssetsExposed is the ingest callback for existing assets a re-scan turned internet-facing. They share the tenant's window with new discoveries.

func (*Notifier) Stop

func (n *Notifier) Stop()

Stop cancels open windows and flushes every buffered summary. Call it on graceful shutdown so a pending summary is not dropped.

Jump to

Keyboard shortcuts

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