Skip to main content

DataContext API

Interface for reading and writing shared scan data.

DataContext Interface​

type DataContext interface {
// Generic accessors
Get(key string) (interface{}, error)
Set(key string, value interface{}) error
Has(key string) bool
Keys() []string

// Typed accessors
GetTargets(key string) ([]Target, error)
GetHosts(key string) ([]Host, error)
GetPorts(key string) ([]Port, error)
GetBanners(key string) ([]Banner, error)
GetFingerprints(key string) ([]Fingerprint, error)
}

Standard Keys​

KeyTypeDescription
targets[]TargetParsed targets
discovered_hosts[]HostLive hosts
open_ports[]PortOpen ports
banners[]BannerService banners
service_fingerprints[]FingerprintService IDs
asset_profiles[]AssetProfileAsset info
vulnerabilities[]VulnerabilityCVEs

Usage Example​

func (m *Module) Execute(ctx context.Context, data DataContext) error {
// Read
hosts, err := data.GetHosts("discovered_hosts")
if err != nil {
return err
}

// Process
var results []Result
for _, host := range hosts {
result := m.process(host)
results = append(results, result)
}

// Write
return data.Set("custom_results", results)
}

See Module Interface for complete API.