vulndb

package
v0.16.7 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vulndb reads and writes netcap.sqlite, the vulnerability and exploit database shared by the Go and Rust implementations.

The file format is specified in SCHEMA.md next to this file. Both implementations must build identical queries from the same inputs, so the query construction below is part of the format, not an implementation detail.

Index

Constants

View Source
const (
	// FileName is the database file inside the netcap dbs directory.
	FileName = "netcap.sqlite"

	// Format identifies the file in its meta table.
	Format = "netcap-vulndb"

	// SchemaVersion is bumped on any incompatible table or query change.
	SchemaVersion = 2

	// MaxHits caps the results of one lookup, matching bleve's default
	// search size used by netcap v0.9.x.
	MaxHits = 10
)

Variables

View Source
var ErrSchema = errors.New("vulndb: unsupported database schema")

ErrSchema reports a file that is not a netcap.sqlite of this schema.

Functions

func MatchExpr

func MatchExpr(terms ...string) string

MatchExpr joins the non-empty phrases of terms with AND.

func Phrase

func Phrase(term string) string

Phrase quotes term as an FTS5 phrase, or returns "" when it holds no letter or digit (an empty phrase is an FTS5 syntax error).

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder writes a new database to a temporary file and publishes it with a rename on Finish, so readers never see a partial file.

func Create

func Create(path string) (*Builder, error)

Create starts a build of path.

func (*Builder) Abort

func (b *Builder) Abort()

Abort discards the build.

func (*Builder) AddExploit

func (b *Builder) AddExploit(e Exploit) error

AddExploit inserts e; a repeated ID keeps the first entry.

func (*Builder) AddVulnerability

func (b *Builder) AddVulnerability(v Vulnerability) error

AddVulnerability inserts v; a repeated ID keeps the first entry.

func (*Builder) Counts

func (b *Builder) Counts() (vulnerabilities, exploits int)

Counts returns the inserted vulnerability and exploit counts.

func (*Builder) Finish

func (b *Builder) Finish() error

Finish indexes, writes meta and atomically replaces path.

func (*Builder) SetMeta

func (b *Builder) SetMeta(key, value string)

SetMeta records a meta key; format and schema_version are set by Finish.

type CPEMatch

type CPEMatch struct {
	Vulnerable     bool   `json:"vulnerable"`
	Criteria       string `json:"criteria"`
	StartIncluding string `json:"versionStartIncluding,omitempty"`
	StartExcluding string `json:"versionStartExcluding,omitempty"`
	EndIncluding   string `json:"versionEndIncluding,omitempty"`
	EndExcluding   string `json:"versionEndExcluding,omitempty"`
}

type Configuration

type Configuration struct {
	Operator string `json:"operator,omitempty"`
	Negate   bool   `json:"negate,omitempty"`
	Nodes    []Node `json:"nodes"`
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a read-only handle.

func Open

func Open(path string) (*DB, error)

Open opens path read-only and checks the format and schema version.

func (*DB) Close

func (d *DB) Close() error

Close releases the handle.

func (*DB) ExploitCandidates

func (d *DB) ExploitCandidates(vendor, product, version string) ([]Exploit, error)

ExploitCandidates returns unverified Exploit-DB text-search candidates containing every non-empty phrase of vendor, product and version.

func (*DB) Exploits

func (d *DB) Exploits(vendor, product, version string) ([]Exploit, error)

Exploit associations require a CVE whose CPE applicability matches this software.

func (*DB) Meta

func (d *DB) Meta() (map[string]string, error)

Meta returns the meta table.

func (*DB) Path

func (d *DB) Path() string

Path returns the file the handle was opened from.

func (*DB) References

func (d *DB) References(id string) ([]Reference, error)

References returns links for a CVE, or [] for a schema-1 database without the optional capability/table. Unknown capability versions are not interpreted.

func (*DB) Vulnerabilities

func (d *DB) Vulnerabilities(vendor, product, version string) ([]Vulnerability, error)

func (*DB) VulnerabilityCandidates

func (d *DB) VulnerabilityCandidates(vendor, product, version string) ([]Vulnerability, error)

VulnerabilityCandidates returns unverified text-search candidates containing every non-empty phrase of vendor and product and whose version list contains version exactly. Without a text term or a version nothing is returned.

type Exploit

type Exploit struct {
	ID          string
	File        string
	Description string
	Date        string
	Author      string
	Type        string
	Platform    string
	Port        string
	CVEs        []string
	MatchStatus string
}

Exploit is one Exploit-DB entry. File is relative to the exploitdb folder.

type Identity

type Identity struct{ Part, Vendor, Product, Version string }

func CanonicalSoftwareIdentity added in v0.16.3

func CanonicalSoftwareIdentity(vendor, product, version string) (Identity, bool)

CanonicalSoftwareIdentity exposes the same explicit aliases for audit deduplication.

type Node

type Node struct {
	Operator string     `json:"operator"`
	Negate   bool       `json:"negate"`
	Matches  []CPEMatch `json:"cpeMatch,omitempty"`
	Children []Node     `json:"children,omitempty"`
	Nodes    []Node     `json:"nodes,omitempty"`
}

type Reference

type Reference struct {
	URL    string   `json:"url"`
	Source string   `json:"source"`
	Tags   []string `json:"tags"`
}

Reference is NVD link metadata, never downloaded content.

func NormalizeReferences

func NormalizeReferences(refs []Reference) []Reference

NormalizeReferences retains absolute HTTP(S) links with a host and no credentials, whitespace, controls or malformed escapes. Attribution is opaque.

type Vulnerability

type Vulnerability struct {
	ID                    string
	Description           string
	Severity              string
	V2Score               string
	AccessVector          string
	AttackComplexity      string
	ConfidentialityImpact string
	IntegrityImpact       string
	AvailabilityImpact    string
	BaseScore             float64
	BaseSeverity          string
	Versions              []string
	References            []Reference `json:"references"`
	Configurations        []Configuration
	MatchStatus           string
}

Vulnerability is one NVD entry.

Jump to

Keyboard shortcuts

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