db

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schemas = []Schema{
	{
		Fallback: true,
		Name:     "fallback",
		Indices:  []string{},
		Columns: []Column{

			{Name: "data", Type: "TEXT", Index: false, NotNull: true, IsJSON: true},
		},
	},
	{
		Indices: []string{"vulncheck-nvd2"},
		Name:    "nvd",
		Results: true,
		Columns: []Column{
			{Name: "id", Type: "TEXT", Index: true, NotNull: true},
			{Name: "published", Type: "TEXT", Index: false, NotNull: false, IsJSON: false},
			{Name: "vulncheckKEVExploitAdd", Type: "TEXT", Index: false, NotNull: false, IsJSON: false},
			{Name: "metrics", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "weaknesses", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "description", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
		},
	},
	{
		Indices: []string{"ipintel-3d", "ipintel-10d", "ipintel-30d"},
		Name:    "ipintel",
		Columns: []Column{

			{Name: "ip", Type: "TEXT", Index: true, NotNull: true},
			{Name: "country", Type: "TEXT", Index: true, NotNull: true},
			{Name: "asn", Type: "TEXT", Index: true, NotNull: true},
			{Name: "country_code", Type: "TEXT", Index: true, NotNull: true},
			{Name: "hostnames", Type: "TEXT", Index: true, NotNull: false, IsJSON: true},
			{Name: "type", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},

			{Name: "port", Type: "INTEGER", Index: false, NotNull: true},
			{Name: "ssl", Type: "BOOLEAN", Index: false, NotNull: true},
			{Name: "lastSeen", Type: "TEXT", Index: false, NotNull: true},
			{Name: "city", Type: "TEXT", Index: false, NotNull: false},
			{Name: "cve", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "matches", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "type_kind", Type: "TEXT", Index: false, NotNull: false},
			{Name: "type_finding", Type: "TEXT", Index: false, NotNull: false},
			{Name: "feed_ids", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
		},
	},
	{
		Name:    "purl PM",
		Version: 2,
		Indices: []string{
			"cargo", "golang", "cocoapods", "hex", "npm", "gem", "pypi", "maven", "nuget", "composer", "hackage", "cran", "pub", "conan", "swift", "go", "dub", "elixir", "julia", "luarocks", "opam", "r", "vcpkg",
		},
		Columns: []Column{
			{Name: "name", Type: "TEXT", Index: false, NotNull: true},
			{Name: "version", Type: "TEXT", Index: false, NotNull: true},

			{Name: "purl", Type: "TEXT", Index: false, NotNull: true, IsJSON: true},
			{Name: "licenses", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "cves", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "vulnerabilities", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "research_attributes", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},

			{Name: purlKeyColumn, Type: "TEXT", Index: true, NotNull: false},
		},
	},
	{
		Name:    "purl OS",
		Version: 2,
		Indices: []string{
			"alpine-purls", "rocky-purls", "debian-purls", "ubuntu-purls",
		},
		Columns: []Column{
			{Name: "name", Type: "TEXT", Index: false, NotNull: true},
			{Name: "version", Type: "TEXT", Index: false, NotNull: true},

			{Name: "purl", Type: "TEXT", Index: false, NotNull: true, IsJSON: true},
			{Name: "licenses", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "cves", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "vulnerabilities", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
			{Name: "research_attributes", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},

			{Name: purlKeyColumn, Type: "TEXT", Index: true, NotNull: false},
		},
	},

	{
		Name:    "cpecve",
		Indices: []string{"cpecve"},
		Columns: []Column{
			{Name: "vendor", Type: "TEXT", Index: true, NotNull: false},
			{Name: "product", Type: "TEXT", Index: true, NotNull: false},
			{Name: "version", Type: "TEXT", Index: true, NotNull: false},
			{Name: "update", Type: "TEXT", Index: true, NotNull: false},
			{Name: "edition", Type: "TEXT", Index: true, NotNull: false},
			{Name: "language", Type: "TEXT", Index: true, NotNull: false},
			{Name: "sw_edition", Type: "TEXT", Index: true, NotNull: false},
			{Name: "target_sw", Type: "TEXT", Index: true, NotNull: false},
			{Name: "target_hw", Type: "TEXT", Index: true, NotNull: false},
			{Name: "other", Type: "TEXT", Index: true, NotNull: false},
			{Name: "cpe23Uri", Type: "TEXT", Index: true, NotNull: false},
			{Name: "cves", Type: "TEXT", Index: false, NotNull: false, IsJSON: true},
		},
	},
}

Functions

func DB

func DB() (*sql.DB, error)

DB provides a cached database connection.

func IPIntelSearch

func IPIntelSearch(indexName, country, asn, cidr, countryCode, hostname, id string) ([]IPEntry, *Stats, error)

func ImportIndex

func ImportIndex(zipPath string, index string, progressCallback func(int)) (int64, error)

ImportIndex loads the JSON files in a downloaded backup zip into the table for index, reading them straight out of the archive rather than extracting them to disk first. It returns the uncompressed size of the data imported.

func MetaByCVE added in v0.10.0

func MetaByCVE(cve string) (*sdk.IndexVulncheckNvd2Response, error)

func PURLSearch

func PURLSearch(indexName string, instance packageurl.PackageURL) ([]PurlEntry, *Stats, error)

func SchemaVersionFor added in v1.4.0

func SchemaVersionFor(index string) int

SchemaVersionFor returns the table layout version this CLI expects for a synced index.

Types

type Column

type Column struct {
	Name    string // Column name in database
	Type    string // SQL type (TEXT, INTEGER, etc)
	Index   bool   // Whether to create an index
	NotNull bool   // Whether column can be null
	IsJSON  bool   // Whether value is JSON array
}

type IPEntry

type IPEntry struct {
	IP          string   `json:"ip"`
	Port        int      `json:"port"`
	SSL         bool     `json:"ssl"`
	LastSeen    string   `json:"lastSeen"`
	ASN         string   `json:"asn"`
	Country     string   `json:"country"`
	CountryCode string   `json:"country_code"`
	City        string   `json:"city"`
	CVE         []string `json:"cve"`
	Matches     []string `json:"matches"`
	Hostnames   []string `json:"hostnames"`
	Type        struct {
		ID      string `json:"id"`
		Kind    string `json:"kind"`
		Finding string `json:"finding"`
	} `json:"type"`
	FeedIDs []string `json:"feed_ids"`
}

type PurlEntry

type PurlEntry struct {
	Name               string                      `json:"name"`
	Version            string                      `json:"version"`
	Purl               []string                    `json:"purl"`
	CVEs               []string                    `json:"cves"`
	Vulnerabilities    []sdk.PurlVulnerability     `json:"vulnerabilities"`
	ResearchAttributes *sdk.PurlResearchAttributes `json:"research_attributes,omitempty"`
}

func (PurlEntry) Malicious added in v1.4.0

func (e PurlEntry) Malicious() bool

Malicious reports whether VulnCheck research flags this package version as malicious.

type Schema

type Schema struct {
	Indices  []string
	Name     string
	Fallback bool
	Results  bool // whether the JSON in each file is inside a "results" array
	Columns  []Column

	// Version is bumped whenever the CLI starts relying on a change to the
	// table layout. A cached index built at an older version is re-imported
	// on the next sync even when the upstream backup has not changed.
	Version int
}

func GetSchema

func GetSchema(indexName string) *Schema

type Stats

type Stats struct {
	Duration time.Duration
}

func CPESearch

func CPESearch(indexName string, cpe cpeutils.CPE) ([]cpeutils.CPEVulnerabilities, *Stats, error)

Jump to

Keyboard shortcuts

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