software

package
v0.16.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 36 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

Index

Constants

View Source
const (
	BehaviorServer  = "server"
	BehaviorClient  = "client"
	BehaviorProxy   = "proxy"
	BehaviorScanner = "scanner"
	BehaviorBot     = "bot"
	BehaviorCrawler = "crawler"
	BehaviorUnknown = "unknown"
)

Software behavioral profiles

View Source
const (
	ConfidenceHigh   = "high"
	ConfidenceMedium = "medium"
	ConfidenceLow    = "low"
)

Detection confidence levels

View Source
const (
	SupportActive      = "active"
	SupportMaintenance = "maintenance"
	SupportEOL         = "eol"
	SupportUnknown     = "unknown"
)

Support status values

Variables

View Source
var (
	// UserAgentCache contains parsed user agents at runtime.
	UserAgentCache = make(map[string]*userAgent)

	// RegexGenericVersion is a regular expression for anything that could be a product / version indicator.
	RegexGenericVersion = regexp.MustCompile(`(?m)(?:^)(.*?)(\d+)\.(\d+)\.(\d+)(.*?)(?:$)`)
)
View Source
var (
	// Store SoftwareStore hold all connections.
	Store = &atomicSoftwareMap{
		Items: make(map[string]*AtomicSoftware),
	}

	// UserAgentParserMutex ensures atomic access to the user agent parser.
	UserAgentParserMutex sync.Mutex

	// HashDBMap contains SSH fingerprint digests mapped to software products at runtime.
	HashDBMap map[string][]sshSoftware
)
View Source
var CMSCookies = make(map[string]struct{})

CMSCookies contains the names of identifying cookies for CMSs and frontend frameworks nolint

View Source
var CMSHeaders = make(map[string]struct{})

CMSHeaders cmsHeadersList is the list of identifying headers for Content Management Systems and Web Servers. the header names will be loaded from the CMS JSON db this map is populated once at init and not supposed to change during runtime so it is safe for concurrent access. nolint

View Source
var Decoder = &decoder.AbstractDecoder{
	Type:        types.Type_NC_Software,
	Name:        "Software",
	Description: "A software product that was observed on the network",
	PostInit: func(d *decoder.AbstractDecoder) error {
		var err error
		softwareLog, _, err = logger.InitZapLogger(
			decoderconfig.Instance.Out,
			"software",
			decoderconfig.Instance.Debug,
		)
		if err != nil {
			return err
		}

		data, err := ioutil.ReadFile(filepath.Join(resolvers.DataBaseFolderPath, "hasshdb.json"))
		hasshDB = nil
		if err == nil {
			err = json.Unmarshal(data, &hasshDB)
		}
		if err != nil {
			softwareLog.Warn("SSH fingerprint enrichment disabled", zap.Error(err))
			hasshDB = nil
		}

		HashDBMap = make(map[string][]sshSoftware)

		for _, v := range hasshDB {
			HashDBMap[v.Hash] = v.Software
		}

		softwareLog.Info("loaded SSH fingerprint digests", zap.Int("total", len(HashDBMap)))

		_ = loadCmsDB()
		softwareLog.Warn("legacy CMS dataset inactive; bounded passive webtech advertisements enabled")

		buildCMSHSIndex()

		indexName := db.Path(resolvers.DataBaseFolderPath)
		db.VulnerabilitiesIndex, err = db.Open(indexName)
		if err != nil {

			db.VulnerabilitiesIndex = nil
			softwareLog.Warn("vulnerability lookups disabled", zap.String("path", indexName), zap.Error(err))
		}

		return nil
	},
	DeInit: func(e *decoder.AbstractDecoder) error {
		Store.operations.Lock()
		defer Store.operations.Unlock()
		if softwareState() != nil {
			err := walkStoredSoftware(func(s *types.Software) error { return flushSoftware(e, s) })
			db.Close(db.VulnerabilitiesIndex)
			writeWebtechDiagnostics()
			return errors.Join(err, softwareLog.Sync())
		}

		// flush writer
		var err error

		idents := make([]string, 0, len(Store.Items))
		for ident := range Store.Items {
			idents = append(idents, ident)
		}
		sort.Strings(idents)

		for _, ident := range idents {
			item := Store.Items[ident]
			item.Lock()

			err = errors.Join(err, flushSoftware(e, item.Software))
			if err != nil {
				softwareLog.Error("failed to flush software audit record", zap.Error(err))
			}

			item.Unlock()
		}

		db.Close(db.VulnerabilitiesIndex)
		writeWebtechDiagnostics()

		return errors.Join(err, softwareLog.Sync())
	},
}

Decoder for protocol analysis and writing audit records to disk.

Functions

func CheckVulnerabilities

func CheckVulnerabilities(s *types.Software, hasVulns bool)

CheckVulnerabilities sets the HasKnownVulnerabilities flag This should be called after vulnerability lookup

func EnhanceSoftwareRecord

func EnhanceSoftwareRecord(s *types.Software)

EnhanceSoftwareRecord adds detection context and behavioral fields to a Software record

func InitializeWebtech

func InitializeWebtech() webtech.Status

InitializeWebtech snapshots optional data before capture workers start.

func InitializeWebtechWith

func InitializeWebtechWith(root string, trust ed25519.PublicKey, now time.Time) webtech.Status

func LookupUserAgent added in v0.16.9

func LookupUserAgent(raw string) *userAgent

LookupUserAgent caches parser results under a bounded encoded-size budget.

func ObserveWebtech

func ObserveWebtech(o webtech.Observation, body io.Reader, encoding, authority, flow, cid string, ts int64) webtech.Report

ObserveWebtech is called on a paired response before payload disposal. No raw HTML, header value, cookie, URL query or external dependency is retained.

func ParseUserAgent

func ParseUserAgent(ua string) *userAgent

ParseUserAgent processes a raw user agent string and returned a structured instance.

func RenderWebtech

func RenderWebtech(m webtech.Result, authority, flow, cid string, ts int64) *types.Software

func ResetCaches

func ResetCaches()

ResetCaches clears all global caches to prevent memory accumulation between multi-file processing runs. CRITICAL: This must be called between file processing to prevent unbounded memory growth.

func StorePassiveSoftware added in v0.16.9

func StorePassiveSoftware(records []*types.Software) int

StorePassiveSoftware retains observations that do not authorize CVE lookups.

func WebtechDiagnostics

func WebtechDiagnostics() (webtech.Status, map[string]uint64)

WebtechDiagnostics contains counts and catalogue identity, never body/cookies.

func WriteHTTPSoftware added in v0.16.9

func WriteHTTPSoftware(items []*AtomicSoftware, flow, communityID string)

WriteHTTPSoftware appends observed flow memberships without decoding old lists.

func WriteSoftware

func WriteSoftware(software []*AtomicSoftware, update func(s *AtomicSoftware))

WriteSoftware can be used to write software to the software audit record writer.

Types

type AtomicSoftware

type AtomicSoftware struct {
	sync.Mutex
	*types.Software
}

AtomicSoftware wraps a types.Software to provide atomic access.

func WhatSoftwareHTTP

func WhatSoftwareHTTP(flowIdent string, h *types.HTTP) (s []*AtomicSoftware)

WhatSoftwareHTTP TODO: pass in the device profile.

type CMSHyperscanBuildStats

type CMSHyperscanBuildStats struct {
	HeaderPatterns          int `json:"header_patterns"`
	HeaderRejections        int `json:"header_rejections"`
	CookiePatterns          int `json:"cookie_patterns"`
	CookieRejections        int `json:"cookie_rejections"`
	HeaderProductCandidates int `json:"header_product_candidates"`
	CookieProductCandidates int `json:"cookie_product_candidates"`
}

CMSHyperscanBuildStats describes the outcome of buildCMSHSIndex.

Re-exported in stub builds so the web UI handler can render the same schema regardless of how netcap was compiled.

type CMSHyperscanStatus

type CMSHyperscanStatus struct {
	Enabled       bool                   `json:"enabled"`
	LibVersion    string                 `json:"lib_version"`
	Build         CMSHyperscanBuildStats `json:"build"`
	BuildError    string                 `json:"build_error,omitempty"`
	HeaderScans   uint64                 `json:"header_scans"`
	HeaderMatches uint64                 `json:"header_matches"`
	HeaderErrors  uint64                 `json:"header_errors"`
	CookieScans   uint64                 `json:"cookie_scans"`
	CookieMatches uint64                 `json:"cookie_matches"`
	CookieErrors  uint64                 `json:"cookie_errors"`
	ScanFallbacks uint64                 `json:"scan_fallbacks"`
}

CMSHyperscanStatus is the JSON-friendly snapshot of the CMS Hyperscan integration. In stub builds, Enabled is false and counters are zero.

func GetCMSHyperscanStatus

func GetCMSHyperscanStatus() CMSHyperscanStatus

GetCMSHyperscanStatus returns a "disabled" snapshot.

Jump to

Keyboard shortcuts

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