Documentation
¶
Overview ¶
Package inventory is the inventory module: the list of devices and software on the network, declared by hand, imported from CSV, or fed by sensors and agents through core/observe, with a source and a confidence on every value (S-INV-1, 2, 3, 5). Service is the only writer of the inv_* tables (INV-2).
Index ¶
- Constants
- Variables
- func CardVendor(source string) bool
- func DisplayName(f NameFacts) string
- func ImportTemplate() io.Reader
- func NamingOS(value, source, basis string) string
- func OSProduct(os string) string
- func PrivateMAC(mac string) bool
- func ReadDeviceIDs(ctx context.Context, q *sql.DB) ([]string, error)
- func ReadIgnoredIDs(ctx context.Context, q *sql.DB) ([]string, error)
- func SafetyVersion(st Settings) string
- func SoftwareWords(v string) ([]string, error)
- type ActiveWindow
- type AddInput
- type AddResult
- type Address
- type Adjustment
- type AgentFact
- type AgentToken
- type AlsoSeen
- type AssetCore
- type AssetEvent
- type BoxInfo
- type BoxPackages
- type Catalog
- type CatalogItem
- type CatalogResult
- type Changed
- type ChecksInput
- type Config
- type CorrectedFrom
- type Counts
- type Detail
- type DetailAsset
- type Device
- type DeviceFilter
- type DeviceList
- type DeviceMatch
- type DeviceRef
- type DeviceSourcesView
- type Differs
- type EmbeddedKEV
- type Event
- type FindingCounter
- type Handlers
- func (h *Handlers) InventoryDeleteInventoryDevicesID(ctx context.Context, params oas.InventoryDeleteInventoryDevicesIDParams) error
- func (h *Handlers) InventoryDeleteInventoryDevicesIDSoftwareSid(ctx context.Context, ...) error
- func (h *Handlers) InventoryGetInventoryCatalog(ctx context.Context, params oas.InventoryGetInventoryCatalogParams) (*oas.InventoryGetInventoryCatalogOK, error)
- func (h *Handlers) InventoryGetInventoryDevices(ctx context.Context, p oas.InventoryGetInventoryDevicesParams) (*oas.InventoryGetInventoryDevicesOK, error)
- func (h *Handlers) InventoryGetInventoryDevicesID(ctx context.Context, params oas.InventoryGetInventoryDevicesIDParams) (*oas.InventoryGetInventoryDevicesIDOK, error)
- func (h *Handlers) InventoryGetInventoryDevicesIDMergePreview(ctx context.Context, ...) (*oas.InventoryGetInventoryDevicesIDMergePreviewOK, error)
- func (h *Handlers) InventoryGetInventoryDevicesIDSources(ctx context.Context, params oas.InventoryGetInventoryDevicesIDSourcesParams) (*oas.InventoryGetInventoryDevicesIDSourcesOK, error)
- func (h *Handlers) InventoryGetInventoryExportCsv(ctx context.Context, p oas.InventoryGetInventoryExportCsvParams) (oas.InventoryGetInventoryExportCsvOK, error)
- func (h *Handlers) InventoryGetInventoryImportTemplateCsv(ctx context.Context) (oas.InventoryGetInventoryImportTemplateCsvOK, error)
- func (h *Handlers) InventoryGetInventoryPossibleSame(ctx context.Context) (*oas.InventoryGetInventoryPossibleSameOK, error)
- func (h *Handlers) InventoryGetInventorySettings(ctx context.Context) (*oas.InventoryGetInventorySettingsOK, error)
- func (h *Handlers) InventoryPatchInventoryDevicesID(ctx context.Context, req *oas.InventoryPatchInventoryDevicesIDReq, ...) (*oas.InventoryPatchInventoryDevicesIDOK, error)
- func (h *Handlers) InventoryPatchInventoryDevicesIDSoftwareSid(ctx context.Context, req *oas.InventoryPatchInventoryDevicesIDSoftwareSidReq, ...) (*oas.InventoryPatchInventoryDevicesIDSoftwareSidOK, error)
- func (h *Handlers) InventoryPostInventoryBoxCheck(ctx context.Context) (*oas.InventoryPostInventoryBoxCheckOK, error)
- func (h *Handlers) InventoryPostInventoryDevices(ctx context.Context, req *oas.InventoryPostInventoryDevicesReq) (*oas.InventoryPostInventoryDevicesCreated, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDApprove(ctx context.Context, params oas.InventoryPostInventoryDevicesIDApproveParams) (*oas.InventoryPostInventoryDevicesIDApproveOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDDiffersFieldKeep(ctx context.Context, ...) (*oas.InventoryPostInventoryDevicesIDDiffersFieldKeepOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDDiffersFieldUse(ctx context.Context, ...) (*oas.InventoryPostInventoryDevicesIDDiffersFieldUseOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDIgnore(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDIgnoreReq, ...) (*oas.InventoryPostInventoryDevicesIDIgnoreOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDKeepSeparate(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDKeepSeparateReq, ...) (*oas.InventoryPostInventoryDevicesIDKeepSeparateOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDMerge(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDMergeReq, ...) (*oas.InventoryPostInventoryDevicesIDMergeOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDSoftware(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSoftwareReq, ...) (*oas.InventoryPostInventoryDevicesIDSoftwareCreated, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDSplit(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSplitReq, ...) (*oas.InventoryPostInventoryDevicesIDSplitOK, error)
- func (h *Handlers) InventoryPostInventoryDevicesIDSuspicious(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSuspiciousReq, ...) (*oas.InventoryPostInventoryDevicesIDSuspiciousOK, error)
- func (h *Handlers) InventoryPostInventoryImport(ctx context.Context, req *oas.InventoryPostInventoryImportReq) (*oas.InventoryPostInventoryImportOK, error)
- func (h *Handlers) InventoryPutInventoryDevicesIDSources(ctx context.Context, req *oas.InventoryPutInventoryDevicesIDSourcesReq, ...) (*oas.InventoryPutInventoryDevicesIDSourcesOK, error)
- func (h *Handlers) InventoryPutInventoryNotifyNew(ctx context.Context, req *oas.InventoryPutInventoryNotifyNewReq) (*oas.InventoryPutInventoryNotifyNewOK, error)
- func (h *Handlers) InventoryPutInventorySettings(ctx context.Context, req *oas.InventoryPutInventorySettingsReq) (*oas.InventoryPutInventorySettingsOK, error)
- type ImportError
- type ImportResult
- type KEV
- type KEVIndex
- type KEVProduct
- type KevRef
- type KindDevice
- type LineRef
- type LineState
- type ListPage
- type ListRow
- type ManualDevice
- type MatchDevice
- type MatchEvent
- type MatchSoftware
- type MergeChoice
- type MergeField
- type MergeMoves
- type MergePreview
- type MergeRefusal
- type MergeSide
- type MergeValue
- type ModuleGate
- type NameFacts
- type OSCorrection
- type ObservationRow
- type Observed
- type Patch
- type PossibleSame
- type ProductQuery
- type Publisher
- type PublisherFunc
- type RangeAdd
- type Reading
- type Refused
- type Resolution
- type Risk
- type RiskSource
- type SNMPFact
- type SafetyInput
- type SamePair
- type SamePairs
- type SameRef
- type SavedSettings
- type ScanDecision
- type ScopeCost
- type Service
- func (s *Service) AddDevice(ctx context.Context, actor string, in AddInput) (AddResult, error)
- func (s *Service) AddExclusion(ctx context.Context, actor, raw string) (SavedSettings, error)
- func (s *Service) AddManualDevice(ctx context.Context, tx *sql.Tx, actor string, in ManualDevice) (string, error)
- func (s *Service) AddRange(ctx context.Context, actor string, in RangeAdd) (SavedSettings, error)
- func (s *Service) AddServices(ctx context.Context, hint observe.AssetHint, source observe.Source, ...) error
- func (s *Service) AddSoftware(ctx context.Context, actor, assetID string, in AddInput) (kevCVEs int, err error)
- func (s *Service) AddressInUse(ctx context.Context, ip string) (bool, error)
- func (s *Service) AddressMap(ctx context.Context) (map[string]string, error)
- func (s *Service) AgentDevice(ctx context.Context, id string) (observe.AgentDevice, bool, error)
- func (s *Service) AllDevices(ctx context.Context) ([]Device, error)
- func (s *Service) Approve(ctx context.Context, actor, id string) error
- func (s *Service) ApproveEnrolled(ctx context.Context, hint observe.AssetHint, nodeMAC, reason string, ...) (bool, error)
- func (s *Service) AssetIDs(ctx context.Context) ([]string, error)
- func (s *Service) BoxIPs(ctx context.Context) ([]netip.Addr, error)
- func (s *Service) BoxName(ctx context.Context) (hostname, ip string, ok bool, err error)
- func (s *Service) BoxOwnedSkipped() int
- func (s *Service) Catalog(ctx context.Context) (*Catalog, error)
- func (s *Service) ChangeSources(ctx context.Context, actor, id string, ch SourcesChange) (Sources, error)
- func (s *Service) CheckBox(ctx context.Context, actor string) (DeviceSourcesView, error)
- func (s *Service) DeleteDevice(ctx context.Context, actor, id string) error
- func (s *Service) Detail(ctx context.Context, id string) (Detail, error)
- func (s *Service) DetailPage(ctx context.Context, id string) (Detail, error)
- func (s *Service) Device(ctx context.Context, id string) (Device, error)
- func (s *Service) DeviceCounts(ctx context.Context) (total, pending int, err error)
- func (s *Service) DeviceRefs(ctx context.Context, ids []string) (map[string]DeviceRef, error)
- func (s *Service) DeviceSources(ctx context.Context, id string) (DeviceSourcesView, error)
- func (s *Service) Devices(ctx context.Context) (DeviceList, error)
- func (s *Service) DevicesOfKind(ctx context.Context, kinds []string) ([]KindDevice, error)
- func (s *Service) DevicesPage(ctx context.Context, f DeviceFilter) (DeviceList, error)
- func (s *Service) DevicesRunning(ctx context.Context, products []ProductQuery) (map[string][]DeviceMatch, error)
- func (s *Service) EarnReview(ctx context.Context, id string) error
- func (s *Service) EditSoftware(ctx context.Context, actor, assetID, softwareID string, e SoftwareEdit) error
- func (s *Service) EnsureBox(ctx context.Context, info BoxInfo) (string, error)
- func (s *Service) ExportCSV(ctx context.Context, actor string, f DeviceFilter) (io.Reader, error)
- func (s *Service) ForgetBoxOwned(ctx context.Context, since map[netip.Addr]time.Time) (int, error)
- func (s *Service) FragileCount(ctx context.Context) (int, error)
- func (s *Service) HasDevice(ctx context.Context, kinds []string, vendor string) (bool, error)
- func (s *Service) IgnoredIDs(ctx context.Context) ([]string, error)
- func (s *Service) Import(ctx context.Context, actor, filename, text string) (ImportResult, error)
- func (s *Service) InScope(ctx context.Context, ip netip.Addr) (bool, error)
- func (s *Service) IsIgnored(ctx context.Context, id string) (bool, error)
- func (s *Service) KeepEntered(ctx context.Context, actor, id, field, detected string) error
- func (s *Service) KeepSeparate(ctx context.Context, actor, id, other string) error
- func (s *Service) KevKeysByCPE(ctx context.Context) func(cpe string) []string
- func (s *Service) KnownMACs(ctx context.Context) ([]string, error)
- func (s *Service) LineRefs(ctx context.Context, ids []string) (map[string]LineRef, error)
- func (s *Service) MarkFirstScan(ctx context.Context, assetID string) error
- func (s *Service) MatchInput(ctx context.Context, id string) (d MatchDevice, ok bool, err error)
- func (s *Service) Merge(ctx context.Context, actor, into, from string) error
- func (s *Service) MergeMany(ctx context.Context, actor, into string, from []string, choice MergeChoice) error
- func (s *Service) MergePreview(ctx context.Context, into string, from []string) (MergePreview, error)
- func (s *Service) Names(ctx context.Context) (map[string]string, error)
- func (s *Service) NotifyNew(ctx context.Context) (bool, error)
- func (s *Service) PatchDevice(ctx context.Context, actor, id string, p Patch) error
- func (s *Service) PendingGentleScans(ctx context.Context) ([]string, error)
- func (s *Service) PortReadTimes(ctx context.Context, assetID string, source observe.Source) (map[int]time.Time, error)
- func (s *Service) PossibleSameAs(ctx context.Context, id string) ([]PossibleSame, error)
- func (s *Service) PossibleSamePairs(ctx context.Context) (SamePairs, error)
- func (s *Service) ProtectedIPs(ctx context.Context) ([]netip.Addr, error)
- func (s *Service) PruneAgentSoftware(ctx context.Context) error
- func (s *Service) PruneServices(ctx context.Context) (int, error)
- func (s *Service) RecomputeAsset(ctx context.Context, tx *sql.Tx, assetID string) (bool, error)
- func (s *Service) ReconcileDeclaredOS(ctx context.Context) error
- func (s *Service) Record(ctx context.Context, batch []observe.Observation) error
- func (s *Service) RecordObservation(ctx context.Context, o observe.Observation) error
- func (s *Service) RefreshBoxPackages(ctx context.Context) error
- func (s *Service) RefreshBoxServices(ctx context.Context) error
- func (s *Service) ReidentifyLines(ctx context.Context) error
- func (s *Service) ReleaseAgents(ctx context.Context, agents []string) error
- func (s *Service) RematchAll(ctx context.Context) (int, error)
- func (s *Service) RematchCVE(ctx context.Context, cve, vendor, product string) (int, error)
- func (s *Service) RematchCVEExcept(ctx context.Context, cve, vendor, product string, ...) (int, error)
- func (s *Service) RematchMany(ctx context.Context, refs []KevRef) (int, error)
- func (s *Service) RemoveSoftware(ctx context.Context, actor, assetID, softwareID string) error
- func (s *Service) ReplaceServices(ctx context.Context, hint observe.AssetHint, source observe.Source, ...) error
- func (s *Service) ReplaceSoftware(ctx context.Context, hint observe.AssetHint, source observe.Source, ...) error
- func (s *Service) SNMPKnown(ctx context.Context) (read, on []string, err error)
- func (s *Service) SNMPPolicy(ctx context.Context, assetID string) (ScanDecision, error)
- func (s *Service) SaveChecks(ctx context.Context, tx *sql.Tx, actor string, in ChecksInput) error
- func (s *Service) SaveSafety(ctx context.Context, actor string, in SafetyInput) (SavedSettings, error)
- func (s *Service) SaveSettings(ctx context.Context, actor string, in SettingsInput) (SavedSettings, error)
- func (s *Service) ScanPolicy(ctx context.Context, assetID string) (ScanDecision, error)
- func (s *Service) SearchCatalog(ctx context.Context, q string) (CatalogResult, error)
- func (s *Service) SetDiscovery(ctx context.Context, actor string, enabled bool) error
- func (s *Service) SetIgnored(ctx context.Context, actor, id string, ignored bool) error
- func (s *Service) SetNotifyNew(ctx context.Context, actor string, enabled bool) error
- func (s *Service) SetScopeCost(fn func(ctx context.Context, st Settings) ScopeCost)
- func (s *Service) SetSoftwareVersion(ctx context.Context, actor, assetID, softwareID, version string) error
- func (s *Service) SetSources(ctx context.Context, actor, id string, scan, snmp *string) (Sources, error)
- func (s *Service) SetSuspicious(ctx context.Context, actor, id string, suspicious bool) error
- func (s *Service) Settings(ctx context.Context) (Settings, error)
- func (s *Service) Settle(ctx context.Context, tx *sql.Tx, committed bool)
- func (s *Service) SetupScope(ctx context.Context, tx *sql.Tx, actor string, ranges []string, confirmed bool) error
- func (s *Service) SoftwareLines(ctx context.Context, assetID string) ([]SoftwareLine, error)
- func (s *Service) Split(ctx context.Context, actor, id, address string) (string, error)
- func (s *Service) ToReviewIDs(ctx context.Context) ([]string, error)
- func (s *Service) UpsertSoftware(ctx context.Context, assetID string, items []SoftwareItem, source string) error
- func (s *Service) UseDetected(ctx context.Context, actor, id, field, detected string) error
- func (s *Service) VulnScanPolicies(ctx context.Context, assetIDs []string, explicit bool) (map[string]ScanDecision, error)
- func (s *Service) VulnScanPolicy(ctx context.Context, assetID string, explicit bool) (ScanDecision, error)
- type ServiceRow
- type Settings
- type SettingsEvent
- type SettingsInput
- type Software
- type SoftwareCorrection
- type SoftwareDetected
- type SoftwareEdit
- type SoftwareItem
- type SoftwareLine
- type SoftwareName
- type SourceRow
- type Sources
- type SourcesChange
- type Summary
- type TLSRefusal
- type TopSoftware
Constants ¶
const ( RowScan = "scan" RowSNMP = "snmp" RowAgent = "agent" )
Source rows, in the order the page shows them.
const ( StateModuleOff = "module_off" // the module behind the source is off StateNoAddress = "no_address" // the device has no address to send to (scan, SNMP) StateOff = "off" // a person turned the source off for this device StateWaiting = "waiting" // on, nothing read yet (scan: the first check is the next window's; SNMP: no read yet; agent: a token was made for the device, no agent reads it yet) StateWorking = "working" // on and it read the device (scan), it answers (SNMP) StateNotApproved = "not_approved" // SNMP reads only approved devices StateNotSetUp = "not_set_up" // SNMP: no settings for this device StateNotAnswering = "not_answering" // SNMP: the last read got no answer StateNone = "none" // agent: no agent of this box reads the device StateReporting = "reporting" // agent: it reports on its rhythm StateQuiet = "quiet" // agent: silent for more than three of its own rhythm (agent-intake NodeHealth) StateNeverReported = "never_reported" // agent: enrolled, never sent its data StateReplaced = "replaced" // agent: a newer enrolment of the same machine took over StateCertChanged = "cert_changed" // agent: its agent pins a certificate authority the box no longer has (a reinstall or a data purge made a new one) StateBox = "box" // the Vedette box itself: it reads its own packages and ports; it is not scanned or read over SNMP StateIgnored = "ignored" // a person ignored the device: the box does not scan or read it until they stop ignoring it )
States of a source row. A row says one of them; the page words it.
const ( DotGreen = "green" DotAmber = "amber" DotRed = "red" DotGrey = "grey" )
Dots of a source row: what the state means at a glance.
const ( ActionTurnOnModule = "turn_on_module" // turn the module on (Settings › Modules, in place) ActionScanNow = "scan_now" // check the device now instead of waiting for the window ActionApprove = "approve" // approve the device (SNMP reads approved devices only) ActionSetUp = "set_up" // set up SNMP for this device ActionCheckNow = "check_now" // SNMP Check now (POST /inventory/snmp/devices/{id}/check) ActionCreateToken = "create_token" // no agent and no token made for this device: create an agent token for it ActionShowSetup = "show_setup" // a token made for this device and no agent yet, or enrolled but never reported: the token and the install command again ActionCheck = "check" // the agent reported at least once: the troubleshooting steps ActionBoxCheck = "box_check" // the box's own agent: read its packages and ports now (POST /inventory/box/check) )
Buttons of a source row.
const ( AgentOsquery = "osquery" AgentWazuh = "wazuh" AgentBox = "box" // the Vedette box itself reads its own packages AgentNone = "none" )
Agents an agent row names.
const ( AgentSoftwareRetention = 30 * 24 * time.Hour // RemovedSoftwareRetention is how long a removed software line is kept (findings keep pointing at it, the device history // names it) before it is deleted. Its history rows stay. RemovedSoftwareRetention = 400 * 24 * time.Hour )
Retention of agent software (DATA_MODEL inv_software; deferred sweep item 9): software an agent (osquery, Wazuh) has not reported for 30 days is deleted. Services have their own retention (PruneServices, INV-23). It is a normal job, not Housekeeping: while the inventory is off nothing is observed, so silence must not count (the agent-intake precedent). The time counts only while the job runs unbroken, and only while agent-intake is on too: agent-intake promises that turning it off keeps what it delivered. An agent that keeps reporting an empty list (or a Wazuh server that stays unreachable) delivers nothing, so its last list goes after 30 days: it is no longer reported. ponytail: the unbroken run is kept in memory (a restart starts the count again); upgrade path: persist when the modules were last on.
const ( ReasonSameMAC = "same_mac" // both were seen with one MAC, never online at once ReasonMACBlock = "mac_block" // burned-in MACs of one maker's block on network gear: the interfaces of one box (INV-57) ReasonSameNameCards = "same_name_cards" // one host name on two cards with burned-in MACs: Wi-Fi and cable, two ports (INV-57) ReasonRotatingName = "rotating_name" // one name, a private Wi-Fi address, never online at once ReasonRotatingModel = "rotating_model" // one stated model, a private Wi-Fi address, never online at once ReasonMACAtAddedDevice = "mac_at_added_device" // a MAC seen at the address of a device added by hand ReasonSameOS = "same_os" // a device added by hand without an address runs the OS the only found device running that release runs )
The reasons two devices are offered as possibly the same machine (PossibleSame.Reason), strongest first. An open vocabulary: the page shows Why, and may key an icon or a hint on the code.
const ( ReasonOK = "ok" ReasonFirstGentleScan = "first_gentle_scan" // One scan at the lowest speed, then passive only ReasonDeclaredByHand = "declared_by_hand" // INV-5 ReasonNoIP = "no_ip" ReasonScanningOff = "scanning_off" // active.enabled is false ReasonScopeNotConfirmed = "scope_not_confirmed" // INV-7 ReasonOutOfScope = "out_of_scope" // outside lan_ranges or in the exclusions ReasonFragilePassiveOnly = "fragile_passive_only" // fragile, after the first scan // ReasonUnclassifiedPassiveOnly: the kind is still unknown after the first scan, so the device may be // fragile; nothing heavier than the gentle scan until passive data, the gentle scan's results or a person // set its kind. ReasonUnclassifiedPassiveOnly = "unclassified_passive_only" // ReasonBox: the machine Vedette runs on is not scanned on its own: never by sensor-active (discovery, sweeps) nor by a // schedule or a KEV rescan; only a person's pick in Scan now scans it (VulnScanPolicy explicit). ReasonBox = "box" // ReasonRegularScanNever: a person chose "never" for this device, for any kind: after the one gentle scan // it is passive only (conservative, like a per-asset "do not scan" in OT scanners). ReasonRegularScanNever = "regular_scan_never" // ReasonSNMPOff: a person turned SNMP off for this device on its Sources card. SNMPPolicy only: ScanPolicy answers a // network scan turned off as ReasonRegularScanNever, the words every reader of a scan refusal already shows. ReasonSNMPOff = "snmp_off" // ReasonExcluded: the address is on the exclusion list, which nothing active ever touches. SNMPPolicy only: SNMP is not bound by // lan_ranges, so its refusal names the exclusions alone; ScanPolicy answers ReasonOutOfScope for both. ReasonExcluded = "excluded" )
Reasons of a ScanDecision.
const ( SourceOn = "on" SourceOff = "off" )
The per-device setting of one active source (inv_asset.scan_source, snmp_source). "" is the default: on for a device a sensor found, off for one added by hand.
const ( DefaultCheckRate = 5 // the scan module's default (scan migration 0001) MaxCheckRate = 20 // scan INV-5 MaxExclusions = 200 )
Limits of the vulnerability checks' speed and of the shared exclusions (#850, INV-32).
const ( MaxImportBytes = 200_000 MaxImportRows = 500 MaxLANRanges = 16 MaxListed = 2000 // GET /inventory/devices (API_CONVENTIONS 4) MaxCatalogHits = 30 )
Limits (INV-4, INV-13).
const ( EventAssetDiscovered = "inventory.asset.discovered" EventAssetUpdated = "inventory.asset.updated" EventAssetDeleted = "inventory.asset.deleted" EventAssetApproved = "inventory.asset.approved" // a person approved a discovered device (B9b) EventAssetIgnored = "inventory.asset.ignored" // a person ignored a device: {asset_id, actor} EventAssetUnignored = "inventory.asset.unignored" // a person stopped ignoring a device: {asset_id, actor} EventSoftwareChanged = "inventory.software.changed" EventMatchChanged = "inventory.match.changed" EventSettingsChanged = "inventory.settings.changed" )
Event names (CONTRACT "Events").
const ( RiskUnderAttack = "under_attack" RiskExploited = "exploited" RiskPublicExploit = "public_exploit" RiskCriticalEdge = "critical_edge" RiskUpdate = "update_recommended" RiskNeedsInput = "needs_input" RiskNone = "none" )
The device badge words (contract.ts DEVICE_STATUSES) and "none" for a device without a badge (the Devices search's filter).
const BoxEvery = time.Hour
BoxEvery is how often the box reads its own packages and ports again (cmd/vedette's inventory job "box"); its agent row says when the next read is from it.
const LearningWindow = 36 * time.Hour
LearningWindow is how long a source learns the network after its first report to this box: a device it finds meanwhile is announced with AssetEvent.Learning, like Darktrace's and Zeek's learning periods, so notify folds the first sweep into one summary.
const MakerDevice = " device"
MakerDevice ends the name of a device known only by the maker of its network card ("Fortinet device").
const MaxPolicyBatch = 4096
MaxPolicyBatch is the most ids VulnScanPolicies takes; more is refused (ErrInvalid), not truncated.
const NoDevice = " (no device)"
NoDevice ends the name of a device added by hand that has neither a name nor an IP: it is only a product someone declared ("Microsoft Office (no device)"), never a nameless row.
const NotInstalledMark = " (not installed)"
NotInstalledMark ends a line a person said is not installed in a text list of a device's software (the export).
const ( // ServiceRetention is how long a service no source reports again is kept (DATA_MODEL); PruneServices removes older rows. ServiceRetention = 90 * 24 * time.Hour )
Bounds of a list of open ports (INV-23).
Variables ¶
var ErrInvalid = errors.New("inventory: invalid input")
ErrInvalid is wrapped by errors about data a sensor or agent sent (SYS-2, SYS-6). Errors about what a person typed are *apierr.Error with their own code.
var ErrNotFound = errors.New("inventory: not found")
ErrNotFound is returned when a device or software row does not exist.
var Kinds = devicetypes.Kinds
Kinds are the 13 kinds behaviour is keyed on: the fragile and regular-scan settings list them, and every device type acts as one of them (devicetypes.ActsAs). The device types themselves are devicetypes.IDs (contract.ts AssetKind).
var Migrations = mustSub(migrationFiles, "migrations/sqlite")
Migrations holds the SQLite migrations of the module, rooted at the directory that contains the NNNN_*.sql files. Pass it to store.Migrate(ctx, db, "inventory", inventory.Migrations).
var RiskLevels = []string{RiskUnderAttack, RiskExploited, RiskPublicExploit, RiskCriticalEdge, RiskUpdate, RiskNeedsInput, RiskNone}
RiskLevels are the words of the badge filter, most urgent first.
var SourceWords = []string{"manual", "passive", "scan", "snmp", "osquery", "wazuh"}
SourceWords are the words of the search's source: filter and of DeviceRow.sources, in this order (contract.ts DeviceSource). scan is nmap or a vulnerability scan. osquery and Wazuh both write source agent: osquery is the device its node key is bound to (inv_asset.agent_key), Wazuh a device at an address or MAC the saved Wazuh connection delivered to (Config.WazuhAgents).
Functions ¶
func CardVendor ¶
CardVendor says a vendor observation of this source names only the maker of the network card: a network scan and the passive sensor read it from the MAC's IEEE prefix. SNMP, an agent and a person state the device's own maker.
func DisplayName ¶
DisplayName is the one naming rule of every page and module (web/src/features/inventory/nameOf.ts is the same): the name a person gave the device in Vedette whenever it is set; then the host name (a name typed when the device was added by hand is one); then a device added by hand is named after its first product, with NoDevice when it has no IP either; any other device after its make and model, unless the maker is only its network card's and no model is known; then the product of the OS or firmware it states (OSProduct: "VMware ESXi"); then "<card maker> device" (MakerDevice); then its IP. "" when none of these is known: the caller adds the kind, the IP placeholder or the id.
func ImportTemplate ¶
ImportTemplate is the sample file offered next to the import button.
func NamingOS ¶
NamingOS is the OS text the naming rule may use (NameFacts.OS): "" for a network scan's fingerprint guess (basis guess) and for the OS row a person declared (source declared), else value.
func OSProduct ¶
OSProduct is the product an OS or firmware text names, without its release: the words before the first one that starts with a digit or a bracket ("VMware ESXi 8.0 Update 3 (build 24022510)" is "VMware ESXi", "MikroTik RouterOS 7.2 - 7.5" is "MikroTik RouterOS", "JUNOS 15.1R7.9" is "JUNOS"). "" when the text starts with its release.
func PrivateMAC ¶
PrivateMAC reports a locally administered MAC that a device picks for itself and changes (a private Wi-Fi address): the locally administered bit is set and the prefix is not one of stablePrefixes. mac is normalised (lower case, colons).
func ReadDeviceIDs ¶
ReadDeviceIDs lists every device, ordered by id, no cap, on a handle of the box's database, for a reader without the service: the selfcheck counts the rows of other modules that name a device that is gone, through this list instead of reading inv_asset (FORBID-4). A read error is an error, never a short list.
func ReadIgnoredIDs ¶
ReadIgnoredIDs is IgnoredIDs on a handle of the box's database, for a reader without the service: the selfcheck of findings' urgency layers runs on its own read-only handle and leaves the ignored devices out, as the urgency pass does.
func SafetyVersion ¶
SafetyVersion names the safety block's stored values (INV-32): the ranges and their attestation, the switch of active discovery (review #860 r2 L1: a stale Settings › Scanning › Safety save would turn it back on), the window, both speeds, the exclusions and the fragile types. The merge stamp is not part of it. Equal values give the same version, so a version names what a person saw, not when.
func SoftwareWords ¶
SoftwareWords reads the software filter: comma-separated words, lower case, each once, at most 80 characters each.
Types ¶
type ActiveWindow ¶
type ActiveWindow struct {
Enabled bool `json:"enabled"`
Days []int `json:"days"` // 1 = Monday ... 7 = Sunday
From string `json:"from"`
To string `json:"to"` // earlier than From means the window crosses midnight
Rate int `json:"rate"`
Exclusions []string `json:"exclusions"` // IPv4 or CIDR
// CheckRate is the speed of the vulnerability checks (nuclei) on LAN devices, in requests per second (1..MaxCheckRate). 0:
// nobody saved it yet, read as DefaultCheckRate. Not part of GET/PUT
// /inventory/settings (the handlers leave it out): /scanning/safety and /scans/config carry it.
CheckRate int `json:"check_rate,omitempty"`
}
ActiveWindow is when and how fast the box may scan actively (INV-7). Since #850 it is the one store of the safety settings every LAN engine shares (INV-32): the window and the exclusions bind the vulnerability checks of the scan module too, and CheckRate is their speed.
func (ActiveWindow) Checks ¶
func (a ActiveWindow) Checks() int
Checks is the check rate, DefaultCheckRate until it was stored.
type AddInput ¶
type AddInput struct {
CatalogID string
Vendor string
Product string
Version string
Name string
IP string
UserName string // the name in Vedette: only CSV import sets it, from its name_in_vedette column
}
AddInput is what a person gives to declare a device or software (contract.ts AddDeviceInput): a product from the catalog (CatalogID) or a vendor and product typed by hand.
type AddResult ¶
type AddResult struct {
ID string `json:"id"`
Display string `json:"display"`
KevCVEs int `json:"kev_cves"`
}
AddResult is POST /inventory/devices.
type Address ¶
type Address struct {
IP *string `json:"ip"`
MAC *string `json:"mac"`
// Main is the device's main address: the one lists show and every scan and read of the device goes to.
Main bool `json:"main"`
// Source is what last tied the address to the device: the sensor that last saw it there, "merge" for one a person's merge
// brought that nothing has seen since, "manual" for the address a person typed.
Source string `json:"source"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
// Agent marks the address the device's agent reports from (an osquery node bound to the device, a Wazuh agent): it cannot be
// split off (409 agent_address), the agent's machine keeps it.
Agent bool `json:"agent"`
}
Address is one address of a device as GET /inventory/devices/{id} shows it.
type Adjustment ¶
Adjustment says a range was written with host bits and was reduced to its network ("10.142.0.5/24" to "10.142.0.0/24"); the response of PUT /inventory/settings lists them (SettingsSaved.adjusted, as the mock does).
type AgentFact ¶
type AgentFact struct {
Agent string // AgentOsquery, AgentWazuh, AgentBox or AgentNone
// State is agent-intake's NodeHealth of the agent: osquery reporting, quiet, never_reported or replaced; Wazuh reporting or quiet;
// "" for the others. LastSeen is the time it judged by (osquery: the last call; Wazuh: the last pull that delivered the device), so the
// row never shows a recent time beside quiet.
State string
LastSeen time.Time
Token *AgentToken // the token Show setup shows: the one its agent enrolled with, else the newest made for this device; nil when none
}
AgentFact is what agent-intake says of the agent that reads a device (Config.AgentOf).
type AgentToken ¶
type AgentToken struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Last4 string `json:"last4"`
CreatedAt string `json:"created_at"`
CreatedBy *string `json:"created_by"`
LastReceived *string `json:"last_received"`
Hosts int `json:"hosts"`
ExpiresAt *string `json:"expires_at"`
DeviceID *string `json:"device_id"`
}
AgentToken is an agent enrolment token as the agent row shows it (contract.ts AgentToken): never its secret.
type AlsoSeen ¶
type AlsoSeen struct {
ID string `json:"id"` // the line's id: a reading is not a row of its own
Source string `json:"source"`
Version string `json:"version"`
PkgVersion string `json:"pkg_version"`
SeenAt string `json:"seen_at"`
SameRelease bool `json:"same_release"` // the effective release with more or less detail (10.2, 10.2p1, 10.2_p1-r1)
}
AlsoSeen is another reading of a software line.
type AssetCore ¶
type AssetCore struct {
ID string `json:"id"`
Site string `json:"site"`
IP string `json:"ip"` // "—" when unknown
MAC *string `json:"mac"`
Hostname *string `json:"hostname"` // the host name the network reports (observations), never a person's name for the device
// UserName is the name a person gave the device in Vedette; nil = none, the naming rule names it (DisplayName).
UserName *string `json:"name"`
Kind string `json:"kind"`
KindSource *string `json:"kind_source"` // the source of the kind's observation; nil for the default unknown
// Guess is what the identification rules say the device most likely is, only while Kind is unknown. It is never the kind:
// nothing behaves on it; a person confirms it by setting the kind.
Guess *devicetypes.Guess `json:"guess"`
Vendor *Observed `json:"vendor"`
Model *Observed `json:"model"`
OS *Observed `json:"os"`
Services []ServiceRow `json:"services"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
Approved bool `json:"approved"`
Fragile bool `json:"fragile"`
Origin string `json:"origin"`
Notes *string `json:"notes,omitempty"`
IsBox bool `json:"is_box"`
FirstScanAt *string `json:"first_scan_at"`
ApprovedAt *string `json:"approved_at"` // when a person (or osquery enrolment) approved it; nil when not approved, added by hand, or approved before approval times were recorded
RegularScan string `json:"regular_scan"`
// ScanSource and SNMPSource say whether the box's network scan and its SNMP reads are on for this device ("on" or "off", the
// default resolved: on for a device a sensor found, off for one added by hand).
ScanSource string `json:"scan_source"`
SNMPSource string `json:"snmp_source"`
// IgnoredAt is when a person ignored the device: known, not watched. nil = watched.
IgnoredAt *string `json:"ignored_at"`
// PrivateMAC: its MAC is a private (randomised) address the device picks for itself and changes, not one a maker burned in or a
// stable virtual one (PrivateMAC).
PrivateMAC bool `json:"private_mac"`
// Quiet: not approved, but not in To review either: a private-address device with no open service that has not stayed past
// a day (INV-49). It is listed with the approved devices and moves to To review when it earns a look.
Quiet bool `json:"quiet"`
}
AssetCore is what a device row and a device detail share. The JSON names are the wire names.
func (AssetCore) NameOrHost ¶
NameOrHost is for the readers that name a device by its host name, else its address or model (response, AI, MCP, honeypot, the CVE page): the name a person gave it in Vedette wins, else the host name; nil when neither is known.
type AssetEvent ¶
type AssetEvent struct {
AssetID string `json:"asset_id"`
Notify bool `json:"notify,omitempty"` // on discovered: the new-device setting was on; on updated: the device now deserves its new-device notice (it was quiet, INV-49)
// Match is set when what the findings matcher reads of the device besides its software changed: the folded OS,
// the model, or the OS the device states itself (MatchDevice.StatedOS). Only observations set it.
Match bool `json:"match,omitempty"`
// Learning is set on discovered events when the source that found the device (passive sensor, active scan, SNMP, agent, vulnerability
// scan) first reported to this box less than LearningWindow ago (MK-1): notify folds such devices into one summary.
Learning bool `json:"learning,omitempty"`
// ScanOn is set on inventory.asset.updated when a person turned the device's network scan on: sensor-active queues it for
// the next window, as a newly discovered device.
ScanOn bool `json:"scan_on,omitempty"`
// Actor is the person who approved (inventory.asset.approved), ignored (inventory.asset.ignored) or deleted
// (inventory.asset.deleted) the device; "" for the system.
Actor string `json:"actor,omitempty"`
// NoAddress is set on inventory.asset.discovered when the device has no IPv4 address when the write commits (a switch an LLDP
// frame named, a device added by hand without one): nothing can be sent to it. It is published for the network-check side to
// skip such a device until it gets an address; the inventory itself queues nothing.
NoAddress bool `json:"no_address,omitempty"`
}
AssetEvent is the data of the asset and software events. Notify is set on discovered events: the notify_new setting at that moment (INV-9), so notify need not read inventory settings.
type BoxInfo ¶
type BoxInfo struct {
Hostname string
IP string // IPv4, "" when unknown
OS string // "" when unknown
// ContainerOnly: the box is a container-only install (no vedette-host); its model then says so instead of appliance.
ContainerOnly bool
}
BoxInfo says what the box knows about itself.
type BoxPackages ¶
type BoxPackages interface {
Packages(ctx context.Context) ([]SoftwareItem, error)
}
BoxPackages lists the packages installed on the box itself (dpkg, confidence 1.0). cmd/vedette implements it with vedette-host's GET /v1/state/packages on an appliance; a container-only install has none. A nil list means "no list from this host" (kept as is), never "no packages".
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is the list of products a person can pick when declaring a device (INV-12): curated products by commercial name plus every vendor/product pair of KEV. It is a port of web/.../catalog.ts; content/catalog/search-golden.json keeps the two giving the same answers.
func NewCatalog ¶
func NewCatalog(curatedJSON []byte, kev []KEVProduct) (*Catalog, error)
NewCatalog builds the catalog from the curated JSON and the KEV pairs.
func (*Catalog) Curated ¶
func (c *Catalog) Curated() []SoftwareItem
Curated is the software row a person adds by picking each curated entry (manual.go: its vendor, product and KEV keys; no version), in the catalog's order. findings' KEV reachability audit reads it (#910, cmd/vedette reachRows).
func (*Catalog) Search ¶
func (c *Catalog) Search(q string) CatalogResult
Search returns at most MaxCatalogHits items and the number of matches (INV-12). An empty query lists the curated products in popularity order.
type CatalogItem ¶
type CatalogItem struct {
ID string `json:"id"`
Display string `json:"display"`
Hint string `json:"hint"`
Category string `json:"category"`
Vendor string `json:"vendor"`
Product string `json:"product"`
Kind string `json:"kind"`
VersionHint string `json:"version_hint"`
KevCVEs int `json:"kev_cves"`
}
CatalogItem is one search hit (contract.ts CatalogItem).
type CatalogResult ¶
type CatalogResult struct {
Items []CatalogItem `json:"items"`
Total int `json:"total"`
}
CatalogResult is GET /inventory/catalog.
type Changed ¶
Changed refuses a write built on values that changed since the person read them (409 safety_changed or scope_changed, review #860 H1/M1): nothing was stored. Current is the block as it is now, for the page to show again. It unwraps to its *apierr.Error.
type ChecksInput ¶
type ChecksInput struct {
Days []int
From, To string
CheckRate int
Exclusions []string // IPv4 or CIDR; host bits are dropped (the scan module accepted them)
// Version is the version of the safety block the page read (GET /scans/config version); "" = none given, no check (the page
// of #850 replaces this one). Another one is 409 safety_changed (review #860 M1).
Version string
}
ChecksInput is the part of the shared block PUT /scans/config still writes (#850): the window, the check rate and the exclusions.
type Config ¶
type Config struct {
// Zone is the organization's time zone the days in notes people read are written in (orgtime); nil: UTC.
Zone orgtime.Source
DB *store.DB
Audit *audit.Log
Events Publisher
KEV KEV
Box BoxPackages
Findings FindingCounter
// Risk says which devices carry risk: their open exploited findings and their Recommended updates, owned by findings; nil
// means none (no marker, every device "clean").
Risk RiskSource
Modules ModuleGate // to tell whether notify is on (notify_available)
// BoxOwnedIPs lists the addresses the box itself answers on besides its own device (the decoy addresses of the
// honeypot). Nothing observed at one of them is a device: Record and ReplaceSoftware ignore such an
// observation (counted, BoxOwnedSkipped) and ProtectedIPs lists the address. nil means none.
BoxOwnedIPs func(ctx context.Context) []netip.Addr
// BoxOwnedMACs lists the box's own MAC addresses: its cards and the decoys' macvlan links (vedette-host state/net). An
// observation at a box-owned address is the box only when it carries no MAC or one of these; a foreign MAC there is a
// device sitting on the decoy's address, and is recorded, so the honeypot sees the conflict and pulls the
// decoy (INV-6). nil, or an error (the host has not answered yet), means unknown: everything at the address is dropped.
// fresh asks for an answer newer than the cache (a decoy added a moment ago has a MAC the cached answer lacks); the provider
// bounds how often that reaches the host. A MAC the cached answer does not hold is asked again with fresh before it counts.
BoxOwnedMACs func(ctx context.Context, fresh bool) ([]string, error)
// BoxDecoyMACs says, per box-owned address, the MAC its decoy has or will have (vedette-host state/net, completed by the
// honeypot's ExpectedMACs); "" = being added, its MAC not known yet: any MAC there is the box for that moment (B2 lab: a Trap
// IP added a second ago became a device and then a conflict of itself). At a box-owned address only no MAC, a box MAC or this
// one is the box; any other MAC is a machine on the address. nil = not known: the rule of BoxOwnedMACs alone.
BoxDecoyMACs func(ctx context.Context, fresh bool) (map[netip.Addr]string, error)
// Gateway is the box's IPv4 default gateway (vedette-host state/net), one signal of the identification rules: the
// zero address when it is not known (no host, or the host did not answer). nil means never known.
Gateway func(ctx context.Context) netip.Addr
// WazuhAgents lists the addresses and MACs of the agents the saved Wazuh connection delivered (agent-intake): a device at one of
// them with data of source agent is reported by Wazuh (#849 DeviceRow.sources). nil means none; an error is logged and means none.
WazuhAgents func(ctx context.Context) (ips, macs []string, err error)
// BoxPorts lists the ports the box itself listens on from outside (vedette-host GET /v1/state/ports): its device's open services,
// source agent (INV-3, INV-23). A nil list (a host older than the read) keeps what is stored. nil: none (a container-only install).
BoxPorts func(ctx context.Context) ([]observe.Service, error)
// DeclaredOS is the matcher's choice of the device's OS among the rows a person declared as one (findings.DeclaredOSRow, INV-45):
// of candidates (row ids, the preferred first) the one it reads as the device's OS and its version as it reads it; "" when none.
// The device page shows that choice, so it never names another OS than the one findings are decided on. nil: a declared row only
// fills an OS no source gives. It is asked only when a source the matcher may prefer reads the device (outranking); an error
// leaves the device with what its sources read.
DeclaredOS func(d MatchDevice, candidates []string) (id, version string, err error)
// OSVersion reads a declared version as the matcher does (findings.OSVersion: "v7.2.13" -> "7.2.13"), for a row the matcher is not
// asked about. nil: trimmed.
OSVersion func(v string) string
// SNMPOf is what sensor-active says of a device's SNMP (its state and last answer), for the device's source rows. nil: not known
// (the row says unavailable); an error is logged and says the same.
SNMPOf func(ctx context.Context, id string) (SNMPFact, error)
// AgentOf is what agent-intake says of the agent that reads a device, for the device's source rows. nil: not known.
AgentOf func(ctx context.Context, id string) (AgentFact, error)
// TLSRefusals is what the box heard from an address since its start: handshakes that ended because the client pins another
// certificate authority than the box's (an agent installed before a reinstall or a data purge made a new one). nil: none known.
TLSRefusals func(ip string) TLSRefusal
// TrustSince is when the certificate authority agents pin now began (the box CA's NotBefore); zero when not known. An osquery agent
// silent since before it cannot trust the box any more. nil: not known.
TrustSince func(ctx context.Context) time.Time
// AskAgent asks the device's agent to send its data now, after a person turned the agent on again (ChangeSources): best effort,
// after the commit, the actor is the person. nil: the agent's next report brings it.
AskAgent func(ctx context.Context, actor, id string)
// Lifecycle are the other modules' parts of a device merge or delete, called inside the inventory's write (core/lifecycle). nil:
// none (the inventory alone).
Lifecycle *lifecycle.Hooks
Clock func() time.Time
Log *slog.Logger
}
Config is what New needs. DB and Audit are required; everything else is optional and degrades: no Events means nothing is announced, no KEV means the catalog has only curated products and no CVE matching, no Findings means findings_count is 0.
type CorrectedFrom ¶
type CorrectedFrom struct {
Source string `json:"source"`
Version string `json:"version"`
PkgVersion string `json:"pkg_version"`
}
CorrectedFrom is what a source reads of a line a person gave another version: its source and version.
type Counts ¶
type Counts struct {
All int `json:"all"`
Pending int `json:"pending"`
Fragile int `json:"fragile"`
Manual int `json:"manual"`
Ignored int `json:"ignored"`
}
Counts are the numbers behind the filter chips of the device list. Every count but Ignored leaves the ignored devices out.
type Detail ¶
type Detail struct {
Asset DetailAsset `json:"asset"`
Suspicious bool `json:"suspicious"`
FindingsCount int `json:"findings_count"`
Risk *Risk `json:"risk"` // the device's risk marker, nil when clean, for the box, or when not read
// RiskUnavailable: the marker could not be read (findings failed).
Observations []ObservationRow `json:"observations"`
Kinds []string `json:"kinds"`
PossibleSame []PossibleSame `json:"possible_same"` // devices that may be the same machine
// ManualAt is when a person last entered or changed something on the device (INV-46, manualAt); nil when nothing was.
ManualAt *string `json:"manual_at"`
// DetectedDiffers are the fields where a trusted source reads something other than what a person entered (INV-47); empty when none.
DetectedDiffers []Differs `json:"detected_differs"`
// Addresses are every address of the device, the main one first (INV-57).
Addresses []Address `json:"addresses"`
}
Detail is GET /inventory/devices/{id} (contract.ts DeviceDetail).
type DetailAsset ¶
type DetailAsset struct {
AssetCore
Software []SoftwareLine `json:"software"`
// OSCorrection is the OS a person set (INV-41), with what the sources read now; absent when none.
OSCorrection *OSCorrection `json:"os_correction,omitempty"`
}
DetailAsset is the asset of a device detail.
type Device ¶
type Device struct {
AssetCore
Software []Software `json:"software"`
Suspicious bool `json:"suspicious"`
FindingsCount int `json:"findings_count"`
Risk *Risk `json:"risk"` // the device's risk marker, nil when clean
Summary *Summary `json:"summary"`
Sources []string `json:"sources"` // what feeds the device, in the words of the Devices search (#849, SourceWords); set by DevicesPage only
// contains filtered or unexported fields
}
Device is a row of the device list (contract.ts DeviceRow).
type DeviceFilter ¶
type DeviceFilter struct {
Approved, Fragile, HasFindings *bool
// Ignored keeps only the ignored devices (true) or leaves them out (false); nil keeps both. ParseDeviceFilter, the query of
// the page and the export, never leaves it nil: an ignored device is out of the Devices list unless asked for.
Ignored *bool
Types []string // device type ids; a type also matches the types that act as it
Sources []string // SourceWords
Risks []string // RiskLevels
Q string // free text: name, IP, MAC (any notation), vendor, model
// Software keeps the devices with a software line whose "name vendor product" holds one of these words (lower case): the
// search's software: (SoftwareWords). GET /inventory/devices then lists the matching lines of each row.
Software []string
}
DeviceFilter is the query of the Devices search. Every set field narrows the list (AND); a list matches any of its values (OR). The zero filter keeps every device (Devices, for the other modules: the honeypot names an ignored device too).
func ParseDeviceFilter ¶
func ParseDeviceFilter(approved, fragile, hasFindings, ignored, types, sources, q string) (DeviceFilter, error)
ParseDeviceFilter checks the query of GET /inventory/devices: approved, fragile and has_findings are "true", "false" or empty; type and source are comma-separated lists of known words (a type id of content/devicetypes, SourceWords). Anything else is 400 bad_filter. The schema already bounds the lengths and the boolean words (400 invalid); this is the same check for a caller that does not go through it. ignored is "true" (only the ignored devices) or "false"/empty (leave them out).
func ParseDeviceSearch ¶
func ParseDeviceSearch(approved, fragile, hasFindings, ignored, types, sources, risks, q string) (DeviceFilter, error)
ParseDeviceSearch is ParseDeviceFilter with the risk filter: a comma-separated list of RiskLevels.
type DeviceList ¶
type DeviceList struct {
Items []Device `json:"items"`
Counts Counts `json:"counts"`
NotifyNew bool `json:"notify_new"`
NotifyAvailable bool `json:"notify_available"`
RiskUnavailable bool `json:"risk_unavailable"`
}
DeviceList is GET /inventory/devices.
type DeviceMatch ¶
DeviceMatch is a device that runs a product (Exact) or may run it (a "Multiple products" entry that only the vendor matches).
type DeviceRef ¶
type DeviceRef struct {
ID string
Hostname *string // the host name the network reports (observations)
UserName *string // the name a person gave the device in Vedette; nil = none
IsBox bool // the Vedette box itself (never given a risk marker)
IP string // "—" when unknown, like the API
MAC string // "" when unknown
Vendor string // the current vendor value, "" when none
// VendorSource is the source of the vendor observation; nmap and passive name the network card's maker only (CardVendor).
VendorSource string
Kind string
Display string // the first software's display name, else the kind (DisplayName's product of a declared device, notify)
OS string // the current operating system value ("Microsoft Windows Server 2025 10.0.26100.1742"), "" when unknown (#905)
// OSSource is the source of the OS observation the ranking chose for OS (INV-44: manual, agent, snmp, passive, nmap, scan); ""
// when there is none. "nmap" means the page shows the scan's OS guess; any other source means a better one won over it.
OSSource string
OSBasis string // how Vedette knows that OS, as the device page says it (osBasis): "stated" (its LLDP statement), "guess" (nmap's fingerprint), ""
Approved bool // a person approved it, or osquery enrolment did (sensor-active sends SNMP credentials only to approved devices)
Ignored bool // a person ignored it (INV-38): its findings are hidden under Findings > Ignored
Model string // the current model value, "" when none (notify names a device without inv.Device)
Origin string // "discovered" or "manual"
// ApprovedAt is when a person or osquery enrolment approved it; nil when not approved, declared by hand, or approved before approval times were recorded.
ApprovedAt *time.Time
}
DeviceRef is a device as other modules name it.
func (DeviceRef) NameFacts ¶
NameFacts is what the naming rule reads of the device (DisplayName), with product as its first software.
func (DeviceRef) NameOrHost ¶
NameOrHost is AssetCore.NameOrHost of a DeviceRef.
type DeviceSourcesView ¶
type DeviceSourcesView struct {
Rows []SourceRow `json:"rows"` // scan, snmp, agent, in this order
// Only names what feeds the device when it is neither of the rows: "passive" (only heard on the network) or "manual" (only what a
// person entered); nil otherwise.
Only *string `json:"only"`
ManualAt *string `json:"manual_at"` // when a person last entered or changed something on the device (Detail.ManualAt)
}
DeviceSourcesView is GET /inventory/devices/{id}/sources (contract.ts DeviceSources).
type Differs ¶
type Differs struct {
Field string `json:"field"`
Entered string `json:"entered"`
Detected string `json:"detected"`
// Source is where the detected value comes from: agent, snmp, or passive (a device's own LLDP statement, Basis "stated").
Source string `json:"source"`
Basis string `json:"basis,omitempty"`
SeenAt string `json:"seen_at"`
}
Differs is a field where what a person entered and what a trusted source reads are two different things (contract.ts DetectedDiffers). The person's value is the one shown everywhere.
type EmbeddedKEV ¶
type EmbeddedKEV struct{}
EmbeddedKEV is the KEV stand-in until feeds implements KEV: the vendor/product pairs come from content/catalog/kev-products.json, and no CVE ids are known, so nothing is matched (deferred).
func (EmbeddedKEV) CVEIndex ¶
func (EmbeddedKEV) CVEIndex(context.Context) (KEVIndex, error)
CVEIndex implements KEV: no CVE is known.
func (EmbeddedKEV) Products ¶
func (EmbeddedKEV) Products(context.Context) (string, []KEVProduct, error)
Products implements KEV.
type Event ¶
Event is what Service publishes after a transaction commits. core/events.Bus takes the same two fields; cmd/vedette adapts (see Publisher).
type FindingCounter ¶
FindingCounter says how many findings are attached to devices (owned by findings; inventory may not read fnd_* tables). nil means zero.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers implements the 21 operations of the inventory module. Embed it in the composite handler of cmd/vedette. The role of each route comes from the route table, so nothing here checks roles.
ogen generates a separate struct per operation for the same schema, so the answers are built from the domain types (their JSON names are the wire names) and decoded into the generated ones.
func NewHandlers ¶
NewHandlers returns the handlers of the module.
func (*Handlers) InventoryDeleteInventoryDevicesID ¶
func (h *Handlers) InventoryDeleteInventoryDevicesID(ctx context.Context, params oas.InventoryDeleteInventoryDevicesIDParams) error
InventoryDeleteInventoryDevicesID implements DELETE /inventory/devices/{id} (operator).
func (*Handlers) InventoryDeleteInventoryDevicesIDSoftwareSid ¶
func (h *Handlers) InventoryDeleteInventoryDevicesIDSoftwareSid(ctx context.Context, params oas.InventoryDeleteInventoryDevicesIDSoftwareSidParams) error
InventoryDeleteInventoryDevicesIDSoftwareSid implements DELETE /inventory/devices/{id}/software/{sid} (operator).
func (*Handlers) InventoryGetInventoryCatalog ¶
func (h *Handlers) InventoryGetInventoryCatalog(ctx context.Context, params oas.InventoryGetInventoryCatalogParams) (*oas.InventoryGetInventoryCatalogOK, error)
InventoryGetInventoryCatalog implements GET /inventory/catalog (viewer).
func (*Handlers) InventoryGetInventoryDevices ¶
func (h *Handlers) InventoryGetInventoryDevices(ctx context.Context, p oas.InventoryGetInventoryDevicesParams) (*oas.InventoryGetInventoryDevicesOK, error)
InventoryGetInventoryDevices implements GET /inventory/devices (viewer): the devices the search keeps (#849).
func (*Handlers) InventoryGetInventoryDevicesID ¶
func (h *Handlers) InventoryGetInventoryDevicesID(ctx context.Context, params oas.InventoryGetInventoryDevicesIDParams) (*oas.InventoryGetInventoryDevicesIDOK, error)
InventoryGetInventoryDevicesID implements GET /inventory/devices/{id} (viewer).
func (*Handlers) InventoryGetInventoryDevicesIDMergePreview ¶
func (h *Handlers) InventoryGetInventoryDevicesIDMergePreview(ctx context.Context, params oas.InventoryGetInventoryDevicesIDMergePreviewParams) (*oas.InventoryGetInventoryDevicesIDMergePreviewOK, error)
InventoryGetInventoryDevicesIDMergePreview implements GET /inventory/devices/{id}/merge-preview (admin).
func (*Handlers) InventoryGetInventoryDevicesIDSources ¶
func (h *Handlers) InventoryGetInventoryDevicesIDSources(ctx context.Context, params oas.InventoryGetInventoryDevicesIDSourcesParams) (*oas.InventoryGetInventoryDevicesIDSourcesOK, error)
InventoryGetInventoryDevicesIDSources implements GET /inventory/devices/{id}/sources (viewer): the device's three source rows.
func (*Handlers) InventoryGetInventoryExportCsv ¶
func (h *Handlers) InventoryGetInventoryExportCsv(ctx context.Context, p oas.InventoryGetInventoryExportCsvParams) (oas.InventoryGetInventoryExportCsvOK, error)
InventoryGetInventoryExportCsv implements GET /inventory/export.csv (viewer): the devices the search keeps, as the page shows them.
func (*Handlers) InventoryGetInventoryImportTemplateCsv ¶
func (h *Handlers) InventoryGetInventoryImportTemplateCsv(ctx context.Context) (oas.InventoryGetInventoryImportTemplateCsvOK, error)
InventoryGetInventoryImportTemplateCsv implements GET /inventory/import-template.csv (viewer).
func (*Handlers) InventoryGetInventoryPossibleSame ¶
func (h *Handlers) InventoryGetInventoryPossibleSame(ctx context.Context) (*oas.InventoryGetInventoryPossibleSameOK, error)
InventoryGetInventoryPossibleSame implements GET /inventory/possible-same (viewer).
func (*Handlers) InventoryGetInventorySettings ¶
func (h *Handlers) InventoryGetInventorySettings(ctx context.Context) (*oas.InventoryGetInventorySettingsOK, error)
InventoryGetInventorySettings implements GET /inventory/settings (admin).
func (*Handlers) InventoryPatchInventoryDevicesID ¶
func (h *Handlers) InventoryPatchInventoryDevicesID(ctx context.Context, req *oas.InventoryPatchInventoryDevicesIDReq, params oas.InventoryPatchInventoryDevicesIDParams) (*oas.InventoryPatchInventoryDevicesIDOK, error)
InventoryPatchInventoryDevicesID implements PATCH /inventory/devices/{id} (operator).
func (*Handlers) InventoryPatchInventoryDevicesIDSoftwareSid ¶
func (h *Handlers) InventoryPatchInventoryDevicesIDSoftwareSid(ctx context.Context, req *oas.InventoryPatchInventoryDevicesIDSoftwareSidReq, params oas.InventoryPatchInventoryDevicesIDSoftwareSidParams) (*oas.InventoryPatchInventoryDevicesIDSoftwareSidOK, error)
InventoryPatchInventoryDevicesIDSoftwareSid implements PATCH /inventory/devices/{id}/software/{sid} (operator, INV-41).
func (*Handlers) InventoryPostInventoryBoxCheck ¶
func (h *Handlers) InventoryPostInventoryBoxCheck(ctx context.Context) (*oas.InventoryPostInventoryBoxCheckOK, error)
InventoryPostInventoryBoxCheck implements POST /inventory/box/check (operator): the box's own agent reads its packages and ports now.
func (*Handlers) InventoryPostInventoryDevices ¶
func (h *Handlers) InventoryPostInventoryDevices(ctx context.Context, req *oas.InventoryPostInventoryDevicesReq) (*oas.InventoryPostInventoryDevicesCreated, error)
InventoryPostInventoryDevices implements POST /inventory/devices (operator).
func (*Handlers) InventoryPostInventoryDevicesIDApprove ¶
func (h *Handlers) InventoryPostInventoryDevicesIDApprove(ctx context.Context, params oas.InventoryPostInventoryDevicesIDApproveParams) (*oas.InventoryPostInventoryDevicesIDApproveOK, error)
InventoryPostInventoryDevicesIDApprove implements POST /inventory/devices/{id}/approve (operator).
func (*Handlers) InventoryPostInventoryDevicesIDDiffersFieldKeep ¶
func (h *Handlers) InventoryPostInventoryDevicesIDDiffersFieldKeep(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDDiffersFieldKeepReq, params oas.InventoryPostInventoryDevicesIDDiffersFieldKeepParams) (*oas.InventoryPostInventoryDevicesIDDiffersFieldKeepOK, error)
InventoryPostInventoryDevicesIDDiffersFieldKeep implements POST /inventory/devices/{id}/differs/{field}/keep (operator).
func (*Handlers) InventoryPostInventoryDevicesIDDiffersFieldUse ¶
func (h *Handlers) InventoryPostInventoryDevicesIDDiffersFieldUse(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDDiffersFieldUseReq, params oas.InventoryPostInventoryDevicesIDDiffersFieldUseParams) (*oas.InventoryPostInventoryDevicesIDDiffersFieldUseOK, error)
InventoryPostInventoryDevicesIDDiffersFieldUse implements POST /inventory/devices/{id}/differs/{field}/use (operator).
func (*Handlers) InventoryPostInventoryDevicesIDIgnore ¶
func (h *Handlers) InventoryPostInventoryDevicesIDIgnore(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDIgnoreReq, params oas.InventoryPostInventoryDevicesIDIgnoreParams) (*oas.InventoryPostInventoryDevicesIDIgnoreOK, error)
InventoryPostInventoryDevicesIDIgnore implements POST /inventory/devices/{id}/ignore (operator).
func (*Handlers) InventoryPostInventoryDevicesIDKeepSeparate ¶
func (h *Handlers) InventoryPostInventoryDevicesIDKeepSeparate(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDKeepSeparateReq, params oas.InventoryPostInventoryDevicesIDKeepSeparateParams) (*oas.InventoryPostInventoryDevicesIDKeepSeparateOK, error)
InventoryPostInventoryDevicesIDKeepSeparate implements POST /inventory/devices/{id}/keep-separate (admin).
func (*Handlers) InventoryPostInventoryDevicesIDMerge ¶
func (h *Handlers) InventoryPostInventoryDevicesIDMerge(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDMergeReq, params oas.InventoryPostInventoryDevicesIDMergeParams) (*oas.InventoryPostInventoryDevicesIDMergeOK, error)
InventoryPostInventoryDevicesIDMerge implements POST /inventory/devices/{id}/merge (admin): every device of body.from goes into id.
func (*Handlers) InventoryPostInventoryDevicesIDSoftware ¶
func (h *Handlers) InventoryPostInventoryDevicesIDSoftware(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSoftwareReq, params oas.InventoryPostInventoryDevicesIDSoftwareParams) (*oas.InventoryPostInventoryDevicesIDSoftwareCreated, error)
InventoryPostInventoryDevicesIDSoftware implements POST /inventory/devices/{id}/software (operator).
func (*Handlers) InventoryPostInventoryDevicesIDSplit ¶
func (h *Handlers) InventoryPostInventoryDevicesIDSplit(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSplitReq, params oas.InventoryPostInventoryDevicesIDSplitParams) (*oas.InventoryPostInventoryDevicesIDSplitOK, error)
InventoryPostInventoryDevicesIDSplit implements POST /inventory/devices/{id}/split (admin): the address becomes a device of its own.
func (*Handlers) InventoryPostInventoryDevicesIDSuspicious ¶
func (h *Handlers) InventoryPostInventoryDevicesIDSuspicious(ctx context.Context, req *oas.InventoryPostInventoryDevicesIDSuspiciousReq, params oas.InventoryPostInventoryDevicesIDSuspiciousParams) (*oas.InventoryPostInventoryDevicesIDSuspiciousOK, error)
InventoryPostInventoryDevicesIDSuspicious implements POST /inventory/devices/{id}/suspicious (operator).
func (*Handlers) InventoryPostInventoryImport ¶
func (h *Handlers) InventoryPostInventoryImport(ctx context.Context, req *oas.InventoryPostInventoryImportReq) (*oas.InventoryPostInventoryImportOK, error)
InventoryPostInventoryImport implements POST /inventory/import (operator).
func (*Handlers) InventoryPutInventoryDevicesIDSources ¶
func (h *Handlers) InventoryPutInventoryDevicesIDSources(ctx context.Context, req *oas.InventoryPutInventoryDevicesIDSourcesReq, params oas.InventoryPutInventoryDevicesIDSourcesParams) (*oas.InventoryPutInventoryDevicesIDSourcesOK, error)
InventoryPutInventoryDevicesIDSources implements PUT /inventory/devices/{id}/sources (admin).
func (*Handlers) InventoryPutInventoryNotifyNew ¶
func (h *Handlers) InventoryPutInventoryNotifyNew(ctx context.Context, req *oas.InventoryPutInventoryNotifyNewReq) (*oas.InventoryPutInventoryNotifyNewOK, error)
InventoryPutInventoryNotifyNew implements PUT /inventory/notify-new (operator).
func (*Handlers) InventoryPutInventorySettings ¶
func (h *Handlers) InventoryPutInventorySettings(ctx context.Context, req *oas.InventoryPutInventorySettingsReq) (*oas.InventoryPutInventorySettingsOK, error)
InventoryPutInventorySettings implements PUT /inventory/settings (admin).
type ImportError ¶
ImportError is one rejected row, by row number (INV-13).
type ImportResult ¶
type ImportResult struct {
Created int `json:"created"`
Skipped int `json:"skipped"`
Errors []ImportError `json:"errors"`
// Notes are rows that were added but need a word: a public IP, or an IP outside the saved network ranges.
Notes []ImportError `json:"notes"`
}
ImportResult is POST /inventory/import.
type KEV ¶
type KEV interface {
// Products lists every vendor/product pair ever in KEV; Version changes when the list does.
Products(ctx context.Context) (version string, list []KEVProduct, err error)
// CVEIndex reads the exploited lists once and returns their CVE ids by match key. A caller reads it once per request (a device
// page, an agent report, a rematch) and looks up every software line in it.
CVEIndex(ctx context.Context) (KEVIndex, error)
}
KEV is the view of the feeds module the inventory needs (INV-10, INV-12). feeds implements it; until then cmd/vedette passes EmbeddedKEVProducts and no CVE source.
type KEVIndex ¶
KEVIndex returns the CVE ids exploited for any of the keys ("vendorproject|product", lower-case); a "multiple products" entry of a vendor matches every key of that vendor. It only reads memory and is safe for concurrent use.
type KEVProduct ¶
type KEVProduct struct {
Vendor string `json:"vendor"`
Product string `json:"product"`
Count int `json:"kev_count"`
}
KEVProduct is one vendor/product pair of CISA KEV with the number of exploited CVEs.
type KevRef ¶
type KevRef struct{ CVE, Vendor, Product string }
KevRef names a CISA entry by its CVE and its vendor and product.
type KindDevice ¶
type KindDevice struct {
ID string
Hostname *string
UserName *string // the name a person gave the device in Vedette; nil = none
IP string // "—" when unknown, like the API
MAC *string // lower case aa:bb:cc:dd:ee:ff
Kind string
// Approved: a person approved the device. KindSource is the source of the observation the kind came from ("" when the kind
// has none: the default unknown). Passive-only kinds (SSDP, LLDP, DHCP, mDNS) are self-announced hints: see TrustedKind.
Approved bool
KindSource string
}
KindDevice is a device of one of the kinds asked for in DevicesOfKind: who it is and the addresses it answers on.
func (KindDevice) NameOrHost ¶
func (k KindDevice) NameOrHost() *string
NameOrHost is AssetCore.NameOrHost of a KindDevice.
func (KindDevice) TrustedKind ¶
func (d KindDevice) TrustedKind() bool
TrustedKind says whether the kind may feed a safety list (the never-touch gateways): a person or an agent set it, or the device is approved and SNMP or nmap set it. A kind that only a passive frame claimed (SSDP, LLDP, DHCP, mDNS) is a hint any host on the wire can send; nmap runs in the untrusted scan container and its guess is shaped by the target (an SSDP claim earns the host an -O scan, and a drop box answers like a router), so an unapproved device's nmap or snmp kind is not enough either. An approved device whose kind is still a passive frame's claim is not trusted: the operator vouches for it by picking its kind by hand.
type LineRef ¶
type LineRef struct {
ID, AssetID, Display, ProductKey string
Version string // "" when the line has no version
}
LineRef is a software line as a list of findings names it: its device, display name, the version it runs now and its product.
type LineState ¶
LineState is what a line holds besides its readings: its state and when a person marked it not installed.
type ListPage ¶
type ListPage struct {
Items []ListRow `json:"items"`
Counts Counts `json:"counts"`
NotifyNew bool `json:"notify_new"`
NotifyAvailable bool `json:"notify_available"`
TopSoftware TopSoftware `json:"top_software"`
}
ListPage is GET /inventory/devices (contract.ts DevicesResponse).
type ListRow ¶
type ListRow struct {
AssetCore
SoftwareCount int `json:"software_count"`
ServiceCount int `json:"service_count"` // open services; the device page lists them
// Services hides AssetCore.Services from the row (a nil slice is left out): the list sends service_count instead.
Services []ServiceRow `json:"services,omitempty"`
// Product is a hand-added device's first installed line by name (what names it, and what Settings › Declared software lists).
Product *Software `json:"product"`
// MatchedSoftware is set only with a software filter: the lines that hold one of its words.
MatchedSoftware []Software `json:"matched_software,omitempty"`
Suspicious bool `json:"suspicious"`
FindingsCount int `json:"findings_count"`
Risk *Risk `json:"risk"`
Summary *Summary `json:"summary"`
Sources []string `json:"sources"`
}
ListRow is a row of GET /inventory/devices (contract.ts DeviceRow).
type ManualDevice ¶
type ManualDevice struct {
Kind string // a hint; anything that is not a device kind is ignored
Vendor string
Product string
Display string // the name people recognise; empty keeps "vendor product"
Key string // lower(vendor)|lower(product), must be that of Vendor and Product
}
ManualDevice is the device "I have it" declares (feeds, S-FEED-2): one device that runs the product.
type MatchDevice ¶
type MatchDevice struct {
ID string
Name string // DisplayName, else the id
OS string // the current operating system ("Ubuntu 26.04.1 LTS", LLDP "JUNOS 15.1R7.9"), "" when unknown
Model string // the current model ("EX4200-48T"), "" when unknown (the Juniper series of a Junos flaw)
// StatedOS is the newest OS the device states itself (an LLDP or SNMP system description, source passive or snmp),
// even when nmap's guess won OS; "" when none.
StatedOS string
// AgentOS is the newest OS the device's own agent reports (source agent: osquery, Wazuh, the box's own reading), even when a
// person's value won OS; "" when no agent reported one (the platform of an agent's software rows, findings INV-16).
AgentOS string
// SNMPOS is the newest OS the device stated to Vedette's own SNMP read of its address (source snmp), "" when none (unlike
// LLDP, which any host can send with another device's MAC).
SNMPOS string
// StatedOSAt and SNMPOSAt are when the device last stated StatedOS and SNMPOS (the observation's seen_at, RFC 3339), "" when none:
// findings says when the device gave the version of its network OS.
StatedOSAt, SNMPOSAt string
// MAC is the device's MAC when it has an IP (the MAC it answers with at that address), "" otherwise: findings reads its OUI before an
// LLDP statement of Junos counts for the device's scan-seen rows.
MAC string
// ManualOS is the OS a person set on the device (INV-41), "" when none: findings reads it as the platform of every row.
ManualOS string
Software []MatchSoftware
// OSCorrection names a person's corrected OS for the findings history ("it@acme.example set the OS to Alpine Linux 3.23 on 17 Nov
// 2026", INV-41); "" when none.
OSCorrection string
// StaleCorrections is nil: a person's entry holds or lapses (INV-52), it never rests. Kept for the findings port.
StaleCorrections []string
// NotInstalled are the lines a person said are not installed on the device (INV-41 (6)): matching leaves them out (they are not in
// Software), and findings closes the open findings only they produce. Each is the line as its strongest source reads it, with
// Correction naming the person ("op@example.com said OpenSSH 10.2 (nmap) is not installed on 17 Nov 2026"); nil when none.
NotInstalled []MatchSoftware
}
MatchDevice is a device with its software, for the matcher of findings.
type MatchEvent ¶
type MatchEvent struct {
AssetID string `json:"asset_id"`
CVE string `json:"cve"`
Basis string `json:"basis"` // "product" (version needs affected ranges from feeds); never "confirmed"
}
MatchEvent is the data of inventory.match.changed: the asset now matches an exploited CVE by product.
type MatchSoftware ¶
type MatchSoftware struct {
ID, Display, Vendor, Product, Version, CPE string
KevKeys []string
// Source is the class of who read it (MK-2): "agent" (osquery, Wazuh, the box's package list), "manual" (a person's entry),
// "scan" (the vulnerability scan), or a sensor ("nmap", "snmp", "passive").
Source string
// Packaged: an agent's reading from the operating system's package database (deb/rpm/apk), so the distribution ships its fixes.
Packaged bool
// PkgVersion and PkgSource: a packaged reading's full package release and source package, "" otherwise; on a person's entry, the
// package release the person gave or kept (INV-41).
PkgVersion, PkgSource string
// ReportedSource is, on a person's entry (Source "manual", INV-41), the class of the strongest source that reads the line, so the
// matcher keeps that source's distribution and platform rules; "" otherwise. Correction names the person's entry for the findings
// history: who, from what, to what, when.
ReportedSource, Correction string
// Superseded is "" (an entry holds or lapses; it never rests). Kept for the findings port.
Superseded string
// Key is the line's id on its effective reading and on a line of MatchDevice.NotInstalled; on another reading, the line's id,
// source and instance joined by char(31).
Key string
// MarkedAt is, on a line of MatchDevice.NotInstalled, when the person said it is not installed (RFC 3339); "" otherwise. MarkedBy
// is who said it ("" when unknown).
MarkedAt, MarkedBy string
// SeenAt is when the reading's source last read it (RFC 3339): for an agent's reading, the time of the list the version comes from.
SeenAt string
// ShadowedBy is "" on every row MatchInput returns. Kept for the findings port.
ShadowedBy string
// Guess: the reading is a sensor's guess (observe.Software.Guess, stored as nmap's os_guess instance: an OS fingerprint, an ESXi
// build the build table does not list), never matched.
Guess bool
// SetBy is the person who entered the version or last changed it (a person's entry, Source "manual"); "" for a reading of an
// agent, a scan or a sensor. Findings names this person when the version they set closes or reopens a finding.
SetBy string
}
MatchSoftware is one reading of a software line the matcher compares, with the line's match keys: the line's effective reading, or another reading the resolver keeps for matching (the same ID).
type MergeChoice ¶
type MergeChoice struct {
Name, Kind, OS *string
}
MergeChoice is what a person chose for the kept device where the merged devices differ (POST /inventory/devices/{id}/merge fields): its name in Vedette, its type and its OS. nil leaves the merge's own result. A value must be one the merge preview listed for that field (one of the devices' own).
type MergeField ¶
type MergeField struct {
Field string `json:"field"`
Values []MergeValue `json:"values"` // the kept device's first, then the others in the order given; a device without a value is left out
// Kept is the value the kept device has after the merge unless the person picks another: the merge's own rules (the person's
// name of the kept device first; the strongest source's reading for the others).
Kept string `json:"kept"`
Choosable bool `json:"choosable"` // name, kind and os: the merge takes a choice (fields)
// Missing are the devices that have no value of the field (type and OS only): a type or OS only one of the devices states is
// listed too, so the person sees what the merged device ends with.
Missing []string `json:"missing"`
}
MergeField is a field the devices of a merge state differently.
type MergeMoves ¶
type MergeMoves struct {
Addresses int `json:"addresses"` // addresses that become the kept device's (each with what a scan read there)
SoftwareNew int `json:"software_new"` // software lines the kept device does not have
Readings int `json:"readings"` // software readings that move (none is dropped)
OpenPorts int `json:"open_ports"`
Findings int `json:"findings"` // findings that move, with their history and decisions (one CVE of one line is folded into one)
Exploited int `json:"exploited"` // distinct exploited CVEs among them (the badge of the devices taken)
}
MergeMoves is what the merge moves to the kept device, over every device taken.
type MergePreview ¶
type MergePreview struct {
Into MergeSide `json:"into"`
From []MergeSide `json:"from"`
Moves MergeMoves `json:"moves"`
Differs []MergeField `json:"differs"`
Refusal *MergeRefusal `json:"refusal"`
}
MergePreview is GET /inventory/devices/{id}/merge-preview: what a merge of from into the device would do, so the dialog says it before the person confirms.
type MergeRefusal ¶
MergeRefusal is why the merge cannot go ahead, as the merge itself would answer (409).
type MergeSide ¶
type MergeSide struct {
ID string `json:"id"`
Name string `json:"name"`
Approved bool `json:"approved"`
Ignored bool `json:"ignored"`
Agent bool `json:"agent"`
Addresses []Address `json:"addresses"`
Software int `json:"software"` // software lines present
OpenPorts int `json:"open_ports"` // open port rows
Findings int `json:"findings"`
Risk *Risk `json:"risk"`
LastSeen string `json:"last_seen"`
}
MergeSide is one device of a merge preview.
type MergeValue ¶
type MergeValue struct {
Device string `json:"device"`
Value string `json:"value"`
// Guess: a type the identification rules give a device whose type is unknown (AssetCore.Guess), offered so a person can pick
// it for the merged device; kind only.
Guess bool `json:"guess,omitempty"`
}
MergeValue is one device's value of a field.
type ModuleGate ¶
ModuleGate says whether another module is on (modreg.Registry implements it).
type NameFacts ¶
type NameFacts struct {
UserName string // the name a person gave the device in Vedette
Hostname string
// Vendor and Model are the device's current maker and model. CardVendor says the maker is only the one of its network card: the
// IEEE prefix of its MAC, which a network scan and the passive sensor report (CardVendor). That names who made the card, not what
// the device is: an ESXi host on an HPE server card, a firewall and a switch of one maker.
Vendor, Model string
CardVendor bool
// OS is the operating system or firmware the device states, or that an agent, SNMP or a person's correction gives (NamingOS):
// never a network scan's fingerprint guess, never the OS row a person declared.
OS string
IP string
Origin string
Product string // the first software a device added by hand runs
}
NameFacts is what the naming rule (DisplayName) reads of a device.
type OSCorrection ¶
type OSCorrection struct {
Value string `json:"value"`
SetAt string `json:"set_at"`
// Detected is the OS the device's sources read without the correction (the value that would win), nil when none read one.
Detected *Observed `json:"detected"`
// Disagrees: the sources read another OS than the person's ("You set X on <date>; the last scan reads Y").
Disagrees bool `json:"disagrees"`
}
OSCorrection is the OS a person set on a device (contract.ts OsCorrection), with what the sources read now.
type ObservationRow ¶
type ObservationRow struct {
ID string `json:"id"`
Field string `json:"field"`
Value string `json:"value"`
Source string `json:"source"`
Confidence float64 `json:"confidence"`
SeenAt string `json:"seen_at"`
Current bool `json:"current"`
// ContradictsType: an nmap OS guess the device's type rules out (osguess.go): kept and shown, never the device's OS.
ContradictsType bool `json:"contradicts_type,omitempty"`
Basis string `json:"basis,omitempty"` // Observed.Basis, of an OS or model observation
}
ObservationRow is one observation of a device detail (contract.ts Observation).
type Observed ¶
type Observed struct {
Value string `json:"value"`
Source string `json:"source"`
Confidence float64 `json:"confidence"`
SeenAt string `json:"seen_at"`
// Basis is how Vedette knows the value besides its source (INV-44): "stated" (the device announced it over LLDP on its own
// vendor's card: the OS, and the model of the same frame), "guess" (nmap's OS fingerprint) or "" (the source and confidence
// say it all).
Basis string `json:"basis,omitempty"`
// SoftwareID names the software row the value is read from: the OS or firmware row a person declared (INV-45); "" when an
// observation gives it.
SoftwareID string `json:"software_id,omitempty"`
}
Observed is a value with where it came from (contract.ts Observed).
type Patch ¶
type Patch struct {
Kind *string
Fragile *bool
RegularScan *string
Notes *string
Name *string // the name in Vedette: trimmed; "" clears it, back to the naming rule
OS *string // the person's OS (INV-41): trimmed; "" clears the correction, back to what the sources read
}
Patch is PATCH /inventory/devices/{id}; a nil field is left alone.
type PossibleSame ¶
type PossibleSame struct {
ID string `json:"id"`
Name string `json:"name"`
Why string `json:"why"`
// Reason is what the two share, as a code the page may key on: one of the Reason* constants.
Reason string `json:"reason"`
Approved bool `json:"approved"`
// Ignored: a person ignored the other device; the Merge dialog says which watch state the kept device ends with.
Ignored bool `json:"ignored"`
LastSeen string `json:"last_seen"`
// NeverSeen: the other device was added by hand and nothing has seen it since (SameRef.NeverSeen).
NeverSeen bool `json:"never_seen"`
}
PossibleSame is another device that may be the same machine as the one read: GET /inventory/devices/{id} possible_same.
type ProductQuery ¶
type ProductQuery struct{ Vendor, Product string }
ProductQuery is a vendor and product pair of KEV.
func (ProductQuery) Key ¶
func (p ProductQuery) Key() string
Key is the matching key (lower(vendor)|lower(product)) of the pair.
type Publisher ¶
Publisher announces events. The real implementation is core/events.Bus; a nil Publisher drops events.
type PublisherFunc ¶
PublisherFunc adapts a function to Publisher.
type RangeAdd ¶
type RangeAdd struct {
Range string
Shown []string // the ranges listed (safety.scope.lan_ranges as read)
ShownConfirmedAt *string // the confirmation shown (safety.scope.confirmed_at as read); nil: shown as not confirmed
Confirmed bool // the tick
}
RangeAdd is POST /scanning/safety/ranges: the range, and what the dialog showed beside the tick.
type Reading ¶
type Reading struct {
Source, Instance string
Display, Version, PkgVersion string
PkgSource, CPE, SetBy string
Packaged bool
Confidence float64
FirstSeen, SeenAt string // fixed-width UTC times: text order is time order
// Addr is the address a network scan read it at: "" for the device's main address and for every source that reads the whole
// machine, else the id of one of the device's other addresses (INV-57). Two interfaces of one device read by one scan are two
// readings.
Addr string
}
Reading is what one source reads now of one software line (inv_software_reading).
type Refused ¶
type Refused struct {
Since string `json:"since"`
Last string `json:"last"`
Count int `json:"count"`
}
Refused is how an agent refused the box's certificate (contract.ts AgentRefused).
type Resolution ¶
type Resolution struct {
// Effective is the line's value; meaningful only when Live (a line without readings keeps the value it had).
Effective Reading
Live bool
// Lapsed is the person's entry a newer reading outgrew (the caller deletes it), By that reading; nil when none lapsed.
Lapsed, LapsedBy *Reading
// Matched are the other readings that feed matching besides Effective (rule 4); Differs is len(Matched) > 0.
Matched []Reading
Differs bool
// State is the line's state after the readings; Unmarked says a "not installed" mark ended (rule 5).
State string
Unmarked bool
}
Resolution is the resolver's answer for one line.
func Resolve ¶
func Resolve(line LineState, readings []Reading) Resolution
Resolve applies the rules above to the readings of one line.
type Risk ¶
type Risk struct {
Code string `json:"code"` // one of RiskLevels but none
Count int `json:"count"` // distinct CVEs at that status; for needs_input the items waiting for a person
}
Risk is the badge of a device in every list (contract.ts DeviceBadge): nil when it has none.
type RiskSource ¶
RiskSource is the badge of every device that has one, from findings' one device status function (inventory may not read fnd_* tables): its most urgent open finding status with the distinct CVEs at it, else needs_input with the items waiting for a person. A device that is absent has none.
type SNMPFact ¶
type SNMPFact struct {
State string // working, not_answering, waiting, not_set_up
LastAnswerAt time.Time // zero when it never answered
}
SNMPFact is what sensor-active says of a device's SNMP (Config.SNMPOf).
type SafetyInput ¶
type SafetyInput struct {
LANRanges []string
Confirmed bool // the person's scan-scope attestation
Days []int
From, To string
PacketsPerS int // discovery and SNMP, 1..1000
RequestsPerS int // the vulnerability checks, 1..MaxCheckRate
Exclusions []string
FragileKinds []string
RegularScanKinds []string
Version string // the version the page read (SafetyVersion): another one is 409 safety_changed (review #860 M1)
}
SafetyInput is PUT /scanning/safety as the inventory stores it: the whole shared block. Whether active discovery is on is not part of it (the nmap-discovery switch is, SetDiscovery), so a save keeps the stored switch.
type SamePair ¶
type SamePair struct {
A SameRef `json:"a"`
B SameRef `json:"b"`
Why string `json:"why"`
Reason string `json:"reason"`
}
SamePair is one pair of GET /inventory/possible-same.
type SamePairs ¶
type SamePairs struct {
Items []SamePair `json:"items"`
}
SamePairs is GET /inventory/possible-same.
type SameRef ¶
type SameRef struct {
ID string `json:"id"`
Name string `json:"name"`
Approved bool `json:"approved"`
LastSeen string `json:"last_seen"`
// NeverSeen: the device was added by hand and nothing has seen it since (LastSeen is when it was added, not a sighting).
NeverSeen bool `json:"never_seen"`
}
SameRef is one device of a SamePair.
type SavedSettings ¶
type SavedSettings struct {
Settings
Adjusted []Adjustment `json:"adjusted"`
}
SavedSettings is the answer of a PUT: the stored settings and the ranges that were reduced to their network.
type ScanDecision ¶
type ScanDecision struct {
Allowed bool
Rate int // packets per second; 1 for the one gentle scan of a fragile device
Reason string // see the Reason* constants
// Careful and IP are set by VulnScanPolicy only (zero from ScanPolicy). Careful: the device is fragile or its
// kind is still unknown, so a caller should go gently even when the decision allows the normal rate (the safe
// side). IP: the address the decision was made for, from the same read; zero when the decision is a refusal.
Careful bool
IP netip.Addr
// Fragile, Unclassified and Never are set by ScanPolicy only, for every device that passed origin, address and scope: the device
// is fragile, its kind is still unknown, a person set regular_scan=never. sensor-active's identification for Scan now picks its
// scan shape from them, and refuses Never.
Fragile, Unclassified, Never bool
}
ScanDecision is the answer of ScanPolicy: may the box probe this device actively, and how fast.
type ScopeCost ¶
type ScopeCost struct {
Addresses int
Pass time.Duration
Window time.Duration // 0: no window is set
Windows int // windows one pass needs (1: it fits one)
WeekWindows int // windows in a week (the window's days)
}
ScopeCost is what one pass of active discovery over a scope costs (the estimate of the range form): the addresses it walks, the time one pass takes at the scan rate (a floor), one window's length, and how many windows one pass needs against the windows of a week.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the only writer of the inv_* tables (INV-2). Create it with New.
func (*Service) AddExclusion ¶
AddExclusion adds one exclusion to the shared list (POST /scanning/safety/exclusions, #842/#850, INV-32) in one write transaction. The entry passes the rule of a PUT (an IPv4 address or an IPv4 range without host bits: 400 bad_exclusion); one an exclusion already stored covers changes nothing (no audit row, no event); growing the list past MaxExclusions is 400 too_many_exclusions, as on the PUT. One audit row inventory.settings naming the entry, then inventory.settings.changed. It only narrows what is scanned, so it needs no attestation and keeps the scope's.
func (*Service) AddManualDevice ¶
func (s *Service) AddManualDevice(ctx context.Context, tx *sql.Tx, actor string, in ManualDevice) (string, error)
AddManualDevice declares a device inside the caller's write transaction tx (INV-14): the device, its software, the audit row and the events are the caller's one commit. It applies every check of AddDevice (a product from the catalog or typed by hand, the same length and character rules). The one difference: a vendor and product that are an exact pair of the KEV list may be longer than 64 characters, because that is data from the CISA list, not something a person typed. The events are kept until the caller calls Settle. It returns the new device's id: feeds scopes "I have this" to that one device.
func (*Service) AddRange ¶
AddRange adds one LAN range to the scope (POST /scanning/safety/ranges: "+ New range" where the person is, #842/#850, INV-32). It reads, appends and stores in one write transaction, so two adds at once both land and no other edit is overwritten. The range passes the rules of a PUT (INV-6: an internal IPv4 range, host bits dropped and reported in Adjusted, at most 16, no overlap). in.Confirmed is the scope attestation (400 scope_not_confirmed without it), and like a PUT's it covers only what the person saw: in.Shown is the list of ranges the dialog showed next to the tick and in.ShownConfirmedAt the confirmation it showed (nil: not confirmed); when the stored list (compared as networks, any order) or the stored confirmation is not that, the add is refused with 409 scope_changed and the current block (*Changed), nothing stored (review #860 H1, r2 M1: a tick never confirms a range the person did not see, nor re-confirms a scope another admin unconfirmed or confirmed again since). Then the scope, shown plus the new range, is confirmed by actor now. A range a stored one already covers changes nothing (no audit row, no event) while the scope is confirmed. One audit row inventory.settings naming the range, and saying so when the add confirmed a scope that was not confirmed; then inventory.settings.changed.
func (*Service) AddServices ¶
func (s *Service) AddServices(ctx context.Context, hint observe.AssetHint, source observe.Source, items []observe.Service) error
AddServices implements observe.ServiceSink for a partial look (INV-23, PRE-2b): a port not listed yet is added, a port already listed by that source gets its seen_at moved, and its name, product, version and confidence only when the item names a product (a -sV read of that port; a gentle look names none, so what a fuller scan said stays); no row is removed. Everything else is as ReplaceServices.
func (*Service) AddSoftware ¶
func (s *Service) AddSoftware(ctx context.Context, actor, assetID string, in AddInput) (kevCVEs int, err error)
AddSoftware declares more software on a device (S-INV-2, INV-4). The same vendor and product twice on one device is 409 duplicate_software; to change a version, remove the row and add it again.
func (*Service) AddressInUse ¶
AddressInUse says whether a device other than the box has the address: an indexed read (inv_asset_ip_uq), with no row cap (Devices stops at MaxListed and would forget the oldest device). A read error is returned and the caller must fail closed.
func (*Service) AddressMap ¶
AddressMap returns the device id of every IP the inventory knows (a device's main address and its others, INV-57), with no row cap. Read error: returned, never a short map.
func (*Service) AgentDevice ¶
AgentDevice implements observe.AgentDevices: the agent bound to the device id, its address and its MAC; found is false when no device has that id. Read only.
func (*Service) AllDevices ¶
AllDevices lists every device with no row cap, for readers that must see them all (the honeypot's conflict and spare-IP checks). Devices is the capped list of the API. ponytail: loads software and services of every device; fine to about 1,000 devices, about 100-300 ms per call at 10k-50k. Upgrade path: a narrow read (id, IP, hostname, kind, approved, is_box, OS, ports) with no software.
func (*Service) Approve ¶
Approve accepts a device a sensor found (S-INV-3); it also clears the suspicious flag. A device that was waiting also gets inventory.asset.approved {asset_id, actor} after the commit (B9b): notify closes its new-device incident naming the person. Approving again (to clear a mark) is no approval; osquery enrolment (ApproveEnrolled) is not a person and publishes only inventory.asset.updated.
func (*Service) ApproveEnrolled ¶
func (s *Service) ApproveEnrolled(ctx context.Context, hint observe.AssetHint, nodeMAC, reason string, agentSaw bool) (bool, error)
ApproveEnrolled implements observe.Approver (S-INV-4): the device an osquery agent reports on is approved by the enrolment, because an admin made the token and ran the install. The device is found as Record finds it (MAC, then IP) and never created here; an address the box answers on is no device (ownedFilter, as in Record). The row must be this machine's: it is approved only when no source ever saw it with a MAC other than nodeMAC (the agent's card on that address). An address DHCP gave to a new machine still resolves to the old machine's row until a sensor sees the move, and the agent's own MAC observation has by then made nodeMAC the row's MAC (the newest MAC), so the column alone proves nothing: the old MAC's observations do. Such a row is found but left waiting for a person, with a log line. A device a person marked suspicious or ignored keeps waiting (a person's flag wins); the box and an approved device are left as they are. One audit row inventory.approve_enrolled by "system", reason naming the token and its maker, only when the flag changes. On the same row (not the box, not one seen with another MAC) an agent OS stored with no agent kind gives the device its kind (typeFromAgentOS), approved or not: a node enrolled before agents sent a kind is typed without a new report. With agentSaw (a caller not answering a live report: agent-intake's approve-enrolled job) a row counts as found only when it holds an agent mac observation equal to nodeMAC; any other row is "not found" and left as it is.
func (*Service) AssetIDs ¶
AssetIDs returns the id of every device, with no kind filter and no row cap, ordered by id: the list a reconcile compares against (findings), so a device of any kind, even one added to the schema later, is never missing. Any read error is returned and the caller must fail closed: a short list would make the caller drop data of devices that still exist. A device a person ignored is left out: every caller reads vulnerabilities (findings, the plan, the distribution feeds), and an ignored device has none.
func (*Service) BoxIPs ¶
BoxIPs lists the addresses that are the box: the IPv4 of its own device and the addresses of Config.BoxOwnedIPs (the decoys). It is the part of ProtectedIPs nothing may ever probe, apart from the devices discovery leaves to the passive sensors (SNMP reads fragile devices but never the box).
func (*Service) BoxName ¶
BoxName returns the host name and IP of the box device ("" when it has none; ok false when there is no box row yet): a direct read of the one row, where Devices would load up to MaxListed devices to find it.
func (*Service) BoxOwnedSkipped ¶
BoxOwnedSkipped counts the observations ignored since start because they came from a box-owned address.
func (*Service) ChangeSources ¶
func (s *Service) ChangeSources(ctx context.Context, actor, id string, ch SourcesChange) (Sources, error)
ChangeSources is SetSources with the agent switch too. Turning the agent off refuses every agent's data for the device from then on (the sinks drop it: ReplaceSoftware, ReplaceServices, Record) and what the agents read stops counting at once: their software readings go (each line is settled again, so a line only an agent read is removed and the history says so) and so do their open ports. Turning it on takes their data again; the agent's next report brings it back, and Config.AskAgent asks an osquery agent for it now.
func (*Service) CheckBox ¶
CheckBox is a person's "Check now" on the box's own agent row (POST /inventory/box/check): the box reads its packages and the ports it listens on now, as its hourly job does, and the page shows the result at once. 409 not_appliance on a container-only install (it has no packages of its own to read); a read that fails is the error (502 box_read_failed), what is stored stays. One audit row inventory.box_check. It returns the box's source rows.
func (*Service) DeleteDevice ¶
DeleteDevice removes a device with its observations, services and software; the box itself is 409 box_device (INV-3). The other modules remove what they keep about it in the same transaction (deleteDeviceTx): findings deletes its findings (INV-11).
func (*Service) Detail ¶
Detail is GET /inventory/devices/{id}: observations (the current one of each field marked), services and software.
func (*Service) DetailPage ¶
DetailPage is Detail with the guess of the identification rules and the risk marker: GET /inventory/devices/{id}.
func (*Service) Device ¶
Device returns one device as a list row, or ErrNotFound. findings, notify and the other modules read it.
func (*Service) DeviceCounts ¶
DeviceCounts is the "All" and "To review" counts of the device list without the list (Home's device tile, findings GET /findings/overview): one aggregate over inv_asset. Ignored devices are in neither.
func (*Service) DeviceRefs ¶
DeviceRefs returns the devices with these ids; unknown ids are absent. An ignored device is present (INV-38): findings' reconcile (its orphan pass, through cmd/vedette findingsInventory.Assets) relies on it to keep an ignored device's findings and the decisions on them when the ignored list cannot be read. Never filter ignored rows out here.
func (*Service) DeviceSources ¶
DeviceSources is the three source rows of a device. ErrNotFound when it does not exist.
func (*Service) Devices ¶
func (s *Service) Devices(ctx context.Context) (DeviceList, error)
Devices lists the devices for the other modules (scan, reports, honeypot, MCP): at most MaxListed rows, the counts over all of them. It does not read the sources (Device.Sources nil): only the Devices page and the export need them (#855).
func (*Service) DevicesOfKind ¶
DevicesOfKind returns every device of the given kinds, with no row cap (Devices stops at MaxListed, newest first, which is the wrong read for a safety list: the oldest device, usually the gateway, would be the one cut). Read-only, ordered by id. An empty kinds is an empty answer. Any read error is returned and the caller must fail closed: a short list is never a valid answer.
func (*Service) DevicesPage ¶
func (s *Service) DevicesPage(ctx context.Context, f DeviceFilter) (DeviceList, error)
DevicesPage is Devices narrowed by the Devices search (#849) with the guesses of the identification rules: GET /inventory/devices. Only the Devices page asks for guesses; every other reader (scan, reports, honeypot, MCP, response) reads Devices or Device, which never ask the host (#714 M3).
func (*Service) DevicesRunning ¶
func (s *Service) DevicesRunning(ctx context.Context, products []ProductQuery) (map[string][]DeviceMatch, error)
DevicesRunning finds, for each product, the devices that run it. The map is keyed by ProductQuery.Key(); a product with no device has no entry. A normal product matches the devices with a software row carrying its key. A "Multiple products" entry matches exactly only a software row declared with that product (the "I have it" device); a device that has any software of the vendor, or that the vendor made, matches by vendor only. Display is the software row that matched (not the device's first row by name, "3cpio" on an Ubuntu box whose OpenSSH matched); when only its maker matched, DeviceRefs' display (first row by name, else the kind). A device a person ignored runs nothing here.
func (*Service) EarnReview ¶
EarnReview is earnReview for a reason outside inventory: a finding raised on the device or a honeypot hit from it. A device that is not quiet, or unknown, is left alone.
func (*Service) EditSoftware ¶
func (s *Service) EditSoftware(ctx context.Context, actor, assetID, softwareID string, e SoftwareEdit) error
EditSoftware changes what a person says about a software line of a device (INV-41, INV-52): its version or package release (the person's entry, which is the line until a newer reading), another product (the entry goes to that product's line and this one is marked not installed), or that it is not installed. What the person does not change is kept: the CPE, the packaged flag and the source package, and the package release while the version stays. The device's findings are matched again after the commit.
func (*Service) EnsureBox ¶
EnsureBox makes sure the box is in the inventory as the first device (INV-3, S-INV-5): created once on the first start, updated on later ones. It is approved, cannot be deleted, and everything it knows about itself has source "agent" at confidence 1. It returns the device id.
func (*Service) ExportCSV ¶
ExportCSV writes the devices f keeps (the Devices search, #849; the zero filter: all) as CSV, UTF-8 with a BOM so Excel opens it right (INV-13). Values that start like a formula are defused (csvCell).
func (*Service) ForgetBoxOwned ¶
ForgetBoxOwned deletes the device rows the sensors made of the box's own decoys (B2 lab): first seen after the Trap IP at that address was switched on (since, from the honeypot: a row from before is a real machine and stays), unapproved, not added by hand, not the box, and either at that address with no MAC or one of the box's MACs, or with no address and that decoy's MAC. The condition is checked again in the deleting transaction, so a row approved in between stays. Each deletion is audited ("inventory.delete" by "system") and announced as DeleteDevice does. It returns how many went.
func (*Service) FragileCount ¶
FragileCount is how many devices are fragile now (by type or marked by hand): the count of Devices' fragile filter.
func (*Service) HasDevice ¶
HasDevice reports whether the inventory has a device of one of these kinds whose vendor (the device's own or that of one of its software rows) is the given one, compared without case.
func (*Service) IgnoredIDs ¶
IgnoredIDs lists the devices a person ignored, ordered by id, no cap; a read error is an error, never a short list. findings' reconcile closes their open findings and keeps their findings out of the orphan pass (#945).
func (*Service) Import ¶
Import adds devices from CSV text (S-INV-2, INV-13): at most 200 KB and 500 rows; the header needs a name or product column; a bad row is reported by its number and the valid rows are still added.
func (*Service) InScope ¶
InScope reports whether ip may be scanned: inside lan_ranges and outside the exclusions (INV-7).
func (*Service) IsIgnored ¶
IsIgnored says whether a person ignored the device; false for a device that does not exist. findings asks it inside its write, so a match or a scan result that raced an Ignore never opens a finding on the ignored device (#945).
func (*Service) KeepEntered ¶
KeepEntered records that the person keeps their own value against the detected one (INV-47): the notice stays hidden until the sources read another value. Nothing else changes. Audited with the person.
func (*Service) KeepSeparate ¶
KeepSeparate is a person's answer "two devices" (POST /inventory/devices/{id}/keep-separate): the pair is stored and never offered again, until either device is deleted or merged into another. Refused like Merge (the same device twice, unknown, the box). Saying it again changes nothing. One audit row inventory.keep_separate the first time.
func (*Service) KevKeysByCPE ¶
KevKeysByCPE reads the catalog once and returns the lookup from a CPE 2.2 URI as nmap prints it ("cpe:/a:apache:http_server:2.4.49") to the KEV keys of the curated entry that names its product (item 24; exposure compares public services with it). The keys may be ones no KEV entry carries today (an entry without kev_match has vendor|product): the caller keeps only those the list has. When the catalog cannot be read it logs once and the lookup answers nil.
func (*Service) KnownMACs ¶
KnownMACs returns the MAC of every device that has one, with no row cap: the sensor's new-device budget counts a device absent from it as new, so a capped list would make old devices eat the budget of real new ones. Lower case, ordered; a read error is returned, never a short list.
func (*Service) LineRefs ¶
LineRefs returns the software lines with these ids, in any state (a finding keeps naming a line that was removed); unknown ids are absent. findings reads it to name the line of each finding in its lists and to search them by software name.
func (*Service) MarkFirstScan ¶
MarkFirstScan records that the one gentle scan of a device happened; later calls change nothing.
func (*Service) MatchInput ¶
MatchInput returns the device with its software; ok is false when it does not exist or a person ignored it (an ignored device is outside every vulnerability reader, so nothing new is matched for it).
func (*Service) MergeMany ¶
func (s *Service) MergeMany(ctx context.Context, actor, into string, from []string, choice MergeChoice) error
MergeMany is a person's answer "the same device" (POST /inventory/devices/{into}/merge): every device of from joins device into in one write, each with the join rules' own primitive (joinAs, a machine join that keeps the addresses, INV-57). into keeps its id, its main address, its approval, its notes, its name in Vedette (from's when it has none) and its findings; the addresses of from (each one of into's other addresses from then on, with what a scan read there), its MACs, sources, software, open ports, agent binding and findings move to it; from is gone. A person decides, so unlike the join rules: into is approved when a from was (approved_at from it, the suspicious mark cleared as Approve does), every note is kept, and an approved into keeps its own suspicious mark only. choice sets the name, type or OS a person picked where the devices differ, as PATCH does, in the same write. Refused: no device, too many, one twice or into itself (400 invalid), a choice that is none of the devices' values (400 bad_choice), an unknown device (404), the box (409 box_device), two agents that say two machines (409 not_same_device). Any devices may be merged, offered or not. One audit row inventory.merge per device; events per device as a join: merged, from deleted, into updated (matched again), into approved when it was not.
func (*Service) MergePreview ¶
func (s *Service) MergePreview(ctx context.Context, into string, from []string) (MergePreview, error)
MergePreview reads what MergeMany would do with the same devices, without changing anything. Refused like MergeMany for bad input (400 invalid) and an unknown device (404); a merge that would be refused for the box or two agents is answered with Refusal set.
func (*Service) Names ¶
Names maps device ids to the name to show (DisplayName; the id when nothing is known) for findings, notify, honeypot and reports.
func (*Service) PatchDevice ¶
PatchDevice changes the name in Vedette, type, fragile flag, regular-scan override or notes of a device (PRE-4, POST-4). A new type is added as a manual observation: older and weaker values stay in the list (INV-1). The name is the device's own column (user_name), never an observation: the host name the network reports stays as it is, shown apart.
func (*Service) PendingGentleScans ¶
PendingGentleScans lists the devices whose one gentle scan is still to come (#714): discovered (or added by hand with its network scan turned on, and never one whose scan is off), kind unknown, not fragile, not set to never, not the box, with an IP and no first scan. Migration 0004 cleared the first scan of such devices seen before, so the gentle scan with titles reaches them; sensor-active queues them once per start, since only a new device's inventory.asset.discovered queues one otherwise. Read-only.
func (*Service) PortReadTimes ¶
func (s *Service) PortReadTimes(ctx context.Context, assetID string, source observe.Source) (map[int]time.Time, error)
PortReadTimes is when source last read each open TCP port of a device with version detection (inv_service.read_at, INV-23), by port; a port only found open is not in it. sensor-active's weekly version read picks its ports by it. An unknown device has none.
func (*Service) PossibleSameAs ¶
PossibleSameAs lists the devices that may be the same machine as device id, the one seen last first. None for the box or an unknown id.
func (*Service) PossibleSamePairs ¶
PossibleSamePairs is GET /inventory/possible-same: every pair of devices that may be one machine, the pair seen last first. In a pair, a is the approved device when one of them is, else the one seen first: the one a merge most likely keeps.
func (*Service) ProtectedIPs ¶
ProtectedIPs lists the addresses a sweep must not probe, whatever MAC shows up there: the box itself, devices declared by hand (unless a person turned their network scan on), devices whose network scan is off, devices with regular_scan=never, and devices that already had their gentle scan and are fragile or unclassified without permission for regular scans (INV-5). A fragile or unclassified device that has not had its gentle scan yet is not listed: its one gentle scan is the policy's. The addresses of Config.BoxOwnedIPs (the decoys of the honeypot) are listed too: they are the box.
func (*Service) PruneAgentSoftware ¶
PruneAgentSoftware deletes the agent software past its retention. It is the job "agent-software-prune" of the module. The same job deletes the removed software lines past their retention (a fixed date, whatever ran meanwhile).
func (*Service) PruneServices ¶
PruneServices removes the services no source has reported for ServiceRetention (INV-23) and writes one audit row when it removed any (inventory.services_pruned, SYS-5). It is the inventory's housekeeping job (the 90 days are stated in this CONTRACT and on the device page), so it runs while the module is off too.
func (*Service) RecomputeAsset ¶
RecomputeAsset folds the observations of a device into its current columns (DATA_MODEL 5.1 rule 3): per field the winner by source rank, confidence, seen_at, id. It is the only code that writes those columns, and it runs in the transaction of the insert and the audit row. It reports whether anything changed. The OS a network device states (or the OS a person set on it) is then a software line again (syncStatedOS): what decides it may have moved.
func (*Service) ReconcileDeclaredOS ¶
ReconcileDeclaredOS stores the declared-OS decision of the devices that have a declared row and no decision, and drops a decision no declared row backs: the devices of a box that ran before the decision was stored. A box that is up to date selects nothing, so the job "declared-os-reconcile" costs a query at start-up; a device it cannot store is logged and skipped.
func (*Service) Record ¶
Record implements observe.Sink: the whole batch in one transaction (all or none). A device is found by the agent bound to it, then by MAC, then by IP; one that matches nothing is created unapproved (INV-9, POST-1). Rows that turn out to be one device are joined (joinSame).
func (*Service) RecordObservation ¶
RecordObservation stores one observation (PRE-1, POST-1). It is Record with a batch of one.
func (*Service) RefreshBoxPackages ¶
RefreshBoxPackages stores the packages installed on the box as its software (agent, confidence 1.0; INV-3). It does nothing without a BoxPackages (a container-only install) or when it gives no list (nil: an older host that does not report the list): what is stored stays. A failed read changes nothing either.
func (*Service) RefreshBoxServices ¶
RefreshBoxServices stores the ports the box listens on from outside as its open services (source agent, confidence 1.0; INV-3, INV-23): the box is never scanned by its own sensor, so this is the only source of its Services tab. The list goes through the same bounds as a sensor's (checkServices) and replaces the box's agent rows; rows of other sources stay. It does nothing without a BoxPorts (a container-only install) or when it gives no list (nil: a host older than the read): what is stored stays. A failed read changes nothing either. The box's addresses are never a device (INV-17), so the row is written by its id, not by a hint.
func (*Service) ReidentifyLines ¶
ReidentifyLines brings the stored software lines to the product catalogue of this build, when they were identified under another one (INV-58). The job runs it at start and every day after; with the lines up to date it reads one row. A device that cannot be identified again is logged and skipped: the devices after it still are, and the pass stays open, so the next run walks every device again (a device already done is only read).
func (*Service) ReleaseAgents ¶
ReleaseAgents implements observe.AgentReleaser: agent-intake deleted these agents (re-enrolment, revoke, prune), so the devices bound to them are free for the next agent that reports on them.
func (*Service) RematchAll ¶
RematchAll announces inventory.match.changed once for every device with software keyed to a CISA entry (after a baseline pull, or when matching must be recomputed from scratch, e.g. the first NVD fill). The event names the device's first CVE; findings matches the whole device on it (one event per device, not per device and CVE, so a rematch of hundreds of devices fits its deadline). It returns how many events it published.
func (*Service) RematchCVE ¶
RematchCVE announces inventory.match.changed for the devices that run the product of a CVE feeds has just listed (feeds.vuln.new_kev). A "Multiple products" entry matches every device with software of the vendor.
func (*Service) RematchCVEExcept ¶
func (s *Service) RematchCVEExcept(ctx context.Context, cve, vendor, product string, known func(ctx context.Context, assetID, cve string) (bool, error)) (int, error)
RematchCVEExcept is RematchCVE that leaves out the devices known says already match the CVE (a CVE whose vendor or product changed is announced to the devices of its new product that have no finding for it, so a flag that changed on hundreds of entries does not announce each device once per entry). known returning an error is that error; nil known leaves nobody out.
func (*Service) RematchMany ¶
RematchMany announces inventory.match.changed once for every device that runs the product of one of refs (a "Multiple products" entry: any product of its vendor), naming the first such CVE. After an NVD update of a few CVEs only their devices are matched again, each once. It returns how many events it published.
func (*Service) RemoveSoftware ¶
RemoveSoftware takes back what a person said about a software line: the version they gave (the line is back to what its sources read; a line only the person declared is removed) or their "not installed". What a sensor or agent read is not removable.
func (*Service) ReplaceServices ¶
func (s *Service) ReplaceServices(ctx context.Context, hint observe.AssetHint, source observe.Source, scope observe.ServiceScope, items []observe.Service) error
ReplaceServices implements observe.ServiceSink (INV-23, PRE-2b): the open ports a source reported for a device become items; rows of that source not in items are removed, rows of other sources stay. The device is found by MAC or IP, or created unapproved, as for ReplaceSoftware; a box-owned address is no device (INV-17). No event and no audit row: nothing listens for a port change yet.
A non-zero scope (observe.ServiceScope) makes it a scoped replace, as ReplaceSoftware has: the list covers only the TCP ports in scope.Ports, so a scan of a few ports replaces the rows of those ports and leaves the rows of the others. A row of the source outside the scope that it has not seen for scope.KeepFor goes too. A port that closes (its row removed) takes the software that source read on it (observe.PortInstance).
func (*Service) ReplaceSoftware ¶
func (s *Service) ReplaceSoftware(ctx context.Context, hint observe.AssetHint, source observe.Source, scope []string, items []observe.Software) error
ReplaceSoftware implements observe.SoftwareSink: the device is found by MAC or IP, or created unapproved.
func (*Service) SNMPKnown ¶
SNMPKnown lists, for the move of SNMP credentials to devices (sensor-active), the devices (not the box) an SNMP read has described (an snmp observation) and those whose SNMP switch a person stored on.
func (*Service) SNMPPolicy ¶
SNMPPolicy is ScanPolicy for the SNMP reads of sensor-active: the same rules, with the device's SNMP setting in place of its network scan setting. SNMP off refuses with ReasonSNMPOff; a device added by hand is read only once a person turned its SNMP on. Its network scan setting does not matter here: a device may be read with SNMP and never port-scanned. sensor-active adds its own SNMP rules on top (a fragile device is read, the box never, only approved devices, the credential's own scope). Inside lan_ranges the credential's "Send only to" list decides, as before; outside them only a device whose SNMP a person turned on is read (the person administers the device); the exclusions always win (ReasonExcluded), and the scan switch and the scope commitment hold too.
func (*Service) SaveChecks ¶
SaveChecks writes the window, the check rate and the exclusions inside the caller's write transaction tx: the scan module's PUT /scans/config, whose own row and audit row share tx (INV-32). The input passes the rules of INV-7 (a day at least, HH:MM, from ≠ to) and of the check rate (1..20), at most MaxExclusions exclusions, each an IPv4 address or an IPv4 range (host bits are dropped: 192.168.1.5/24 is 192.168.1.0/24, the same addresses). An error is an *apierr.Error. inventory.settings.changed goes out at Settle, when tx committed. No audit row of its own: the caller's scan.config row says what changed.
func (*Service) SaveSafety ¶
func (s *Service) SaveSafety(ctx context.Context, actor string, in SafetyInput) (SavedSettings, error)
SaveSafety stores the shared block (PRE-5 and INV-6/7 as SaveSettings; at least one day, the check rate 1..20, and more than MaxExclusions exclusions only when the list does not grow), and only over the version the page read: 409 safety_changed with the current block otherwise (*Changed, review #860 M1), so a page opened before an inline add never drops it. The switch of active discovery keeps the value stored when the transaction reads it (review #857 L8); scope_not_confirmed when it is on and the attestation is not ticked.
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, actor string, in SettingsInput) (SavedSettings, error)
SaveSettings stores the scan scope (PRE-5, INV-6, INV-7). scope_confirmed_at stays when the ranges did not change (POST-5). The fragile flag of every device without a manual override follows the new kinds.
func (*Service) ScanPolicy ¶
ScanPolicy decides whether sensor-active and scan may probe a device (PRE-3, POST-3; INV-5, 7, 8): the box itself is never scanned, nor a device whose network scan a person turned off (answered as regular_scan_never with Never set: "set to never be scanned on its device page"), nor a device declared by hand until a person turns its network scan on; nothing outside lan_ranges or inside the exclusions is; a fragile device, and one whose kind is still unknown (it may be fragile), gets one gentle scan when first seen and then only if regular scans are allowed for it (regular_scan "never" beats the type setting; an unknown kind is in no type setting); "never" means never for every kind, after the one gentle scan. The time window is the scheduler's business, not this function's.
func (*Service) SearchCatalog ¶
SearchCatalog is GET /inventory/catalog.
func (*Service) SetDiscovery ¶
SetDiscovery turns active discovery (active.enabled, the nmap-discovery engine of Settings › Scanning) on or off; the other settings keep their values. On needs a range, a day and the confirmed scope (INV-7: 400 no_ranges, no_days, scope_not_confirmed). One audit row inventory.settings, then inventory.settings.changed: sensor-active stops a run that may no longer go on.
func (*Service) SetIgnored ¶
SetIgnored ignores a device or stops ignoring it (S-INV-3): "this device needs no watching", a staff phone. An ignored device stays known (its row, so its MAC and agent key keep matching it when it is seen again) but is out of To review, the counts and the Devices list unless asked for; it sends no new-device alert (notify closes its open one on inventory.asset.ignored), the scan policies read its network scan and SNMP reads as off (effectiveSources; the stored source choice and the unknown mark are kept), and it is out of the vulnerability readers (MatchInput, AssetIDs, DevicesRunning), so findings makes none for it; the findings it has stay as they are, left out of every findings list and not rated by the urgency pass. A trap hit or an intrusion-detection incident from it still alerts: those modules never ask about it. Stopping sends it through review again: not approved, its own scan and SNMP settings in force again, inventory.asset.unignored, then matched again (its findings are listed and rated again at once). Saying it again changes nothing (no audit row, no event). The box is 409 box_device.
func (*Service) SetNotifyNew ¶
SetNotifyNew turns the alert for new devices on or off.
func (*Service) SetScopeCost ¶
SetScopeCost gives the inventory the estimate of a pass over a scope (active discovery's: it knows the probes an address costs and the box's own networks). A save of the scan scope, window or rate that active discovery could not sweep within a week is refused with the numbers (scope_too_large); without an estimate nothing is refused.
func (*Service) SetSoftwareVersion ¶
func (s *Service) SetSoftwareVersion(ctx context.Context, actor, assetID, softwareID, version string) error
SetSoftwareVersion changes the version of a person's entry ("edit version": Accept on the device page's "the device reports X" hint, and findings' "I updated it"); "" removes the version. A line no person gave a version is not editable here: it changes with its source's next report (EditSoftware sets a version on any line). The device's findings are matched again after the commit.
func (*Service) SetSources ¶
func (s *Service) SetSources(ctx context.Context, actor, id string, scan, snmp *string) (Sources, error)
SetSources turns the network scan and the SNMP reads of one device on or off; a nil value is left alone, and at least one is needed. Turning one on is a person's consent to that traffic to this device: a device added by hand gets it from then on, inside every other safety rule (scope, exclusions, window, fragile, never, the box). Turning one off stops it for any device: the run in progress on the device stops (inventory.asset.updated), and what that source found stays. One audit row per source changed says who, which device, which source and on or off. The box itself is 409 box_device: nothing automatic ever probes it.
func (*Service) SetSuspicious ¶
SetSuspicious marks or unmarks a device as suspicious (S-INV-3).
func (*Service) Settle ¶
Settle ends AddManualDevice and SetupScope for tx: when the caller's transaction committed the events go out, when it rolled back they are dropped. The caller must call it once it knows which; a transaction with no pending events is a no-op.
func (*Service) SetupScope ¶
func (s *Service) SetupScope(ctx context.Context, tx *sql.Tx, actor string, ranges []string, confirmed bool) error
SetupScope stores the LAN ranges and the scan commitment of first-run setup (core INV-15, S-CORE-1) inside the caller's write transaction tx, so that they are the scope of Settings › Scanning › Safety from the first page on (#350): the ranges pass INV-6 (an error is an *apierr.Error and the caller's setup fails with it), lan_ranges is replaced, and the scope is confirmed by actor now when confirmed is true and cleared otherwise. The other settings keep their values. No audit row of its own: the caller's core.setup row counts the ranges. inventory.settings.changed goes out at Settle, when the caller's transaction committed.
func (*Service) SoftwareLines ¶
SoftwareLines is the software of a device as every surface shows it (findings' port, the device page): one row per line, the line's effective reading with its other readings; the lines a person said are not installed are in it, marked. ErrNotFound when the device does not exist. KevCVEs is left empty.
func (*Service) Split ¶
Split is a person's answer "this address is another device" (POST /inventory/devices/{id}/split), the undo of a merge (INV-57): the address (an IPv4 address or a MAC of the device; the interface row that holds it moves whole, its IP and MAC together) becomes a device of its own with what was read only there: the MAC's observations, and the readings and open ports a scan took at that address. What the device's other sources read of the whole machine (an agent's software, SNMP) stays with it. When the address was the device's main one, the other address seen last becomes its main one. The new device is approved when the device was, so no new-device alert goes out for it; the pair is kept separate (inv_separate), so it is never offered as possibly the same device and no join rule takes it back. Findings follow the software: matched again on both devices. Refused: an unknown device (404), an address that is not the device's (404 address_not_found), a text that is no IPv4 address or MAC (400 bad_address), the box (409 box_device), the device's only address (409 only_address). One audit row inventory.split. It returns the new device's id.
func (*Service) ToReviewIDs ¶
ToReviewIDs is the id of every device in To review (toReviewSQL: not approved, not quiet), ignored devices and the box left out, ordered by id, with no cap: findings' Needs your input counts the ones with no open finding as one card that opens To review.
func (*Service) UpsertSoftware ¶
func (s *Service) UpsertSoftware(ctx context.Context, assetID string, items []SoftwareItem, source string) error
UpsertSoftware replaces the software a source read on a device (PRE-2, POST-2): the readings of that source not in items go, readings of other sources stay. "manual" and "agent" are refused: a person's entries are set one by one, and an agent list names the agent that read it ("box" for the box's own packages).
func (*Service) UseDetected ¶
UseDetected drops the person's value of a field so the sources' reading wins (INV-47): the device page then shows the detected value. detected is the value the person saw; when the sources read another one meanwhile it is 409 detected_changed and nothing changes. Audited with the person.
func (*Service) VulnScanPolicies ¶
func (s *Service) VulnScanPolicies(ctx context.Context, assetIDs []string, explicit bool) (map[string]ScanDecision, error)
VulnScanPolicies is VulnScanPolicy for many devices with one settings read and one device query. A device that does not exist (deleted since the caller listed it) is absent from the map; it does not fail the batch.
func (*Service) VulnScanPolicy ¶
func (s *Service) VulnScanPolicy(ctx context.Context, assetID string, explicit bool) (ScanDecision, error)
VulnScanPolicy decides whether the vulnerability scanner (module scan) may probe a device. It is ScanPolicy without the sensor-active switch (scan has its own) and with one more input: explicit, true when a person picked this very device in "Scan now" (that pick is the consent, audited by the caller).
Always refused: no IP, scope not confirmed, outside lan_ranges or inside the exclusions, regular_scan=never, a network scan turned off, and a device declared by hand whose network scan nobody turned on (INV-5): absolute here, even with explicit; the person changes the setting first. A device declared by hand with its network scan on is scanned like a discovered one. The box itself is refused unless explicit: a person may scan it, nothing automatic does; picked, it goes through the same checks as any device and runs at the normal rate. A fragile device and an unclassified one (kind unknown) are refused for schedules and the KEV rescan (explicit=false), and allowed when explicit, at a quarter of the configured rate (Active.Rate, packets per second, at least 1). regular_scan=allow, or a kind in regular_scan_kinds, lets a fragile or unclassified device be scanned at the normal rate without a pick (INV-8). It never calls MarkFirstScan: the one gentle scan belongs to discovery.
type ServiceRow ¶
type ServiceRow struct {
Port int `json:"port"`
Proto string `json:"proto"`
Name string `json:"name"`
Product *string `json:"product,omitempty"`
Version *string `json:"version,omitempty"`
Detail *string `json:"detail,omitempty"` // what the service said about the device besides product and version
Source string `json:"source"`
Confidence float64 `json:"confidence"`
// Address is the other address of the device a scan found the port on (INV-57); nil for the main address and an agent's list.
Address *string `json:"address,omitempty"`
}
ServiceRow is a service seen listening on a device (contract.ts Service).
type Settings ¶
type Settings struct {
LANRanges []string `json:"lan_ranges"`
Active ActiveWindow `json:"active"`
FragileKinds []string `json:"fragile_kinds"`
RegularScanKinds []string `json:"regular_scan_kinds"`
ScopeConfirmedAt *string `json:"scope_confirmed_at"`
ScopeConfirmedBy *string `json:"scope_confirmed_by"`
// Version names the stored safety block (INV-32, review #860 M1): every read sets it (SafetyVersion), a writer given one
// refuses with 409 safety_changed when the block changed since. In SettingsInput it is the version the page read ("" = none).
Version string `json:"version"`
}
Settings is the scan scope of the box (contract.ts InventorySettings).
type SettingsEvent ¶
type SettingsEvent struct {
Scope string `json:"scope"` // "scan" or "notify_new"
}
SettingsEvent is the data of inventory.settings.changed.
type SettingsInput ¶
type SettingsInput struct {
Settings
ScopeConfirmed bool `json:"scope_confirmed"` // the person's scan-scope attestation
}
SettingsInput is PUT /inventory/settings.
type Software ¶
type Software struct {
ID string `json:"id"`
Display string `json:"display"`
Vendor string `json:"vendor"`
Product string `json:"product"`
Version *string `json:"version"`
Kev []string `json:"kev"`
Source string `json:"source"`
Confidence float64 `json:"confidence"`
// Basis is "guess" on the row of nmap's OS fingerprint (no version, no match key), "" otherwise (INV-44).
Basis string `json:"basis,omitempty"`
// NotInstalled: a person said this software is not installed on the device (INV-41 (6)). Readers that tell what the device runs
// (the assistant, MCP) take Device.Running, which leaves it out.
NotInstalled bool `json:"not_installed"`
// contains filtered or unexported fields
}
Software is one software line as a row of a device list (contract.ts Software): SoftwareLine.row.
type SoftwareCorrection ¶
type SoftwareCorrection struct {
SetAt string `json:"set_at"`
SetBy string `json:"set_by"`
// Detected is the strongest reading of a source of the line; nil when only the person says it is there.
Detected *SoftwareDetected `json:"detected"`
Disagrees bool `json:"disagrees"` // the sources read another version or package release than the person's
// Active: the person's value is in use. It always is: a newer reading ends an entry (it lapses), and a new reading ends a "not
// installed" mark (the line is then shown as the sources read it, with no correction).
Active bool `json:"active"`
// NotInstalled: the person said the software is not installed (INV-41 (6)); it matches nothing while the mark holds.
NotInstalled bool `json:"not_installed"`
}
SoftwareCorrection is on a line a person gave a version or marked not installed: when, by whom, and what the sources read now.
type SoftwareDetected ¶
type SoftwareDetected struct {
ID string `json:"id"`
Display string `json:"display"`
Version *string `json:"version"`
PkgVersion *string `json:"pkg_version"`
Source string `json:"source"`
SeenAt string `json:"seen_at"`
}
SoftwareDetected is what the sources read of a line a person gave a version or marked not installed (contract.ts SoftwareCorrection.detected).
type SoftwareEdit ¶
type SoftwareEdit struct {
Version *string // "" removes the version
PkgVersion *string // the distribution's package release ("10.2_p1-r1"); "" removes it
CatalogID string // another product, from the catalog...
Vendor string // ...or typed
Product string
// NotInstalled: the person says the software is not installed on the device (INV-41 (6)). It takes no other field; a later
// version, release or product a person gives makes the line installed again (the person says what is there).
NotInstalled bool
}
SoftwareEdit is PATCH /inventory/devices/{id}/software/{sid}: a nil field or an empty product is left as it is.
type SoftwareItem ¶
type SoftwareItem struct {
Display, Vendor, Product, Version, CPE string
KevKeys []string
Confidence float64
// Guess is a sensor's guess (observe.Software.Guess): stored without match keys, so it raises no finding.
Guess bool
// Packaged: an agent read it from the operating system's package database (observe.Software.Packaged). Stored only for
// source agent.
Packaged bool
// PkgVersion and PkgSource: a deb row's full Debian version and source package. Stored only with Packaged; a value
// that is not a Debian version or package name is dropped (the row stays, without a distribution decision).
PkgVersion, PkgSource string
// Instance tells two readings of one product by one source apart (observe.Software.Instance).
Instance string
}
SoftwareItem is software to store for a device.
type SoftwareLine ¶
type SoftwareLine struct {
// ID is the id of the line: stable across version moves (a finding names it).
ID string `json:"id"`
Display string `json:"display"`
Vendor string `json:"vendor"`
Product string `json:"product"`
Version *string `json:"version"` // nil when the source gave none
// PkgVersion is the full package release (an agent's packaged reading, or a person's entry); absent when none.
PkgVersion *string `json:"pkg_version,omitempty"`
Packaged bool `json:"packaged"` // read from the operating system's package database
CPE string `json:"cpe"` // "" when none
KevCVEs []string `json:"kev_cves"` // the exploited CVEs of its match keys; none on a line a person said is not installed
// Source is the class of the effective reading's source ("agent" for every agent, "manual" for a person's entry).
Source string `json:"source"`
Confidence float64 `json:"confidence"`
Basis string `json:"basis,omitempty"` // "guess" on nmap's OS fingerprint (no version, no match key)
SetBy string `json:"set_by"` // who entered the value, when it is a person's entry; "" otherwise
SeenAt string `json:"seen_at"` // when the effective reading's source last read it
// NotInstalled: a person said this software is not installed on the device (INV-41 (6)). It matches nothing; the readers that
// tell what the device runs (the assistant, MCP) leave it out, the export marks it.
NotInstalled bool `json:"not_installed"`
// AlsoSeen lists the other readings of the line, strongest source first, never as rows of their own.
AlsoSeen []AlsoSeen `json:"also_seen"`
// Differs: another reading of another release still feeds matching (Resolve rule 4); the first AlsoSeen with SameRelease false
// is the one to name.
Differs bool `json:"differs"`
// Corrected: the value is a person's entry that a source reads otherwise; CorrectedFrom is what the strongest source reads.
Corrected bool `json:"corrected"`
CorrectedFrom *CorrectedFrom `json:"corrected_from"`
// Correction, on a line a person gave a version or marked not installed, says when, by whom, and what the sources read now.
Correction *SoftwareCorrection `json:"correction,omitempty"`
// CanCorrect: a person may give this line a version (PATCH, INV-52), whatever source it was read from. true on every line.
CanCorrect bool `json:"can_correct"`
// contains filtered or unexported fields
}
SoftwareLine is one software line of a device as every surface shows it (contract.ts SoftwareLine): the line's effective reading, with the other readings, a person's entry or "not installed" mark, and the exploited CVEs of its match keys.
type SoftwareName ¶
SoftwareName is a software name of the search's suggestions and the number of listed devices that run it.
type SourceRow ¶
type SourceRow struct {
Source string `json:"source"` // RowScan, RowSNMP or RowAgent
State string `json:"state"` // one of the State constants
Dot string `json:"dot"` // one of the Dot constants
LastAt *string `json:"last_at"` // when it last read the device (SNMP: the last answer; an agent: its last call); nil when never
Switch *string `json:"switch"` // the person's switch for this device, "on" or "off"; nil when the row has none
Action *string `json:"action"` // the one button; nil when none
Agent *string `json:"agent"` // agent row: AgentOsquery, AgentWazuh, AgentBox or AgentNone; nil on the other rows
Token *AgentToken `json:"token"` // agent row: the token Show setup shows (AgentFact.Token); nil otherwise
// NextAt is when the source reads the device next by itself: the box's own agent row (its hourly read, BoxEvery after the last one
// since start); nil otherwise or when not known yet.
NextAt *string `json:"next_at"`
// Refused is the agent row of state cert_changed when the box heard the device's agent refuse its certificate: since when, the
// last time and how often (since the box's start); nil otherwise.
Refused *Refused `json:"refused"`
}
SourceRow is one row of a device's sources (contract.ts DeviceSourceRow).
type Sources ¶
type Sources struct {
Scan string `json:"scan_source"`
SNMP string `json:"snmp_source"`
Agent string `json:"agent_source"` // the agents' data of the device: on unless a person turned it off
}
Sources is the state of a device's active sources (PUT /inventory/devices/{id}/sources): SourceOn or SourceOff each, the default resolved (on for a device a sensor found, off for one added by hand).
type SourcesChange ¶
type SourcesChange struct{ Scan, SNMP, Agent *string }
SourcesChange is what PUT /inventory/devices/{id}/sources changes: nil leaves a source alone.
type Summary ¶
Summary is the source of the most trusted value and the confidence of the weakest (DATA_MODEL 5.1 (5)).
type TLSRefusal ¶
TLSRefusal is what the box heard from one address since its start (Config.TLSRefusals): handshakes that ended because the client pins another certificate authority than the box's. Count is 0 when none.
type TopSoftware ¶
type TopSoftware struct {
Devices []SoftwareName `json:"devices"` // approved or quiet
Review []SoftwareName `json:"review"` // To review
}
TopSoftware is the suggestions of the search's software:, per list of the page.
Source Files
¶
- addresses.go
- box.go
- catalog.go
- corrections.go
- csv.go
- declared.go
- detected.go
- devicelist.go
- devicesources.go
- devicesquery.go
- entries.go
- handlers.go
- join.go
- lapse.go
- lines.go
- manual.go
- merge.go
- mergedfrom.go
- mergesplit.go
- module.go
- observe.go
- osguess.go
- quiet.go
- reads.go
- reidentify.go
- resolve.go
- retention.go
- safety.go
- samedevice.go
- sameos.go
- scanpolicy.go
- selfcheck.go
- service.go
- services.go
- settings.go
- software.go
- softwareline.go
- stated.go
- statedos.go
- types.go
- validate.go
- wiring.go