db

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

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: true, 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",
		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: true, 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: "purl OS",
		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: true, 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:    "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(filePath string, indexDir string, progressCallback func(int)) error

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)

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"`
}

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
}

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