ingest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffStored added in v0.3.0

func DiffStored(a, b *scanpb.Run) (*scandomain.RunDiff, bool)

DiffStored computes true run-to-run drift between two STORED runs by re-parsing each run's verbatim output (Run.RawXML) into an ephemeral, pre-fold Run and diffing THOSE — rather than diffing the persisted host rows.

Why this is needed: hosts are unified across runs (one shared row per physical host, enriched by host.MergeHost as each scan folds in), and every run that observed a host links that one shared row through run_hosts. So two runs that both saw host X read back with the SAME union of ports — the drift between them has already been merged away in the DB, and scan.DiffRuns over the stored rows reports "no changes" even when the surface genuinely moved. Each run's RawXML, by contrast, is that scan's own untouched observation, so re-ingesting it recovers the per-run snapshot the fold discarded.

It returns (diff, true) only when BOTH runs carry RawXML AND a registered ingestor matches their Scanner; otherwise (nil, false), and the caller should fall back to scan.DiffRuns over whatever host trees it holds (an approximate diff, honest about its limits).

func FindingToResult added in v0.3.0

func FindingToResult(line []byte) (*scandomain.Result, bool)

FindingToResult decodes one nuclei -jsonl finding line into a feeder Result. It is the shared entry point for the live driver, which reads findings line-by-line off nuclei's stdout. A blank or unparseable line yields (nil, false) so the caller can skip it; a decode error other than that is returned so a genuinely malformed stream is not silently swallowed.

func Ingest

func Ingest(name string, raw []byte) (*scanpb.Run, error)

Ingest looks up the named scanner and runs it against raw. It is the one-call entry point the CLI uses; an unknown name yields an error that lists the scanners that are registered.

func Names

func Names() []string

Names returns the sorted list of registered ingestor names (for CLI help/completion).

func Register

func Register(in Ingestor)

Register makes an Ingestor available under its Name(). Adapters call it from init(). A duplicate name panics: that is a programming error and is caught at startup.

Types

type Ingestor

type Ingestor interface {
	// Name is the scanner identifier ("nmap", "zgrab2", ...). It is both the key the
	// Ingestor registers under and the value stamped onto Run.Scanner.
	Name() string

	// Ingest parses one scanner's raw output into a scan.Run. Implementations MUST NOT
	// touch the database: they only build the in-memory Run tree. Deduplication, merge and
	// storage happen downstream via Scans.Create (which folds through host.IngestHosts), so
	// the same identity/merge primitives are shared with every other ingest path.
	Ingest(raw []byte) (*scanpb.Run, error)
}

Ingestor maps one scanner's native output into the shared scan model. Any tool that can emit bytes — nmap XML, masscan/zgrab JSON, a naabu port list — becomes a contributor to the same objects by implementing this one method. nmap.FromXML already has this shape.

func Get

func Get(name string) (Ingestor, bool)

Get returns the Ingestor registered under name, if any.

Jump to

Keyboard shortcuts

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