vulnerabilitydatabase

package
v0.0.0-...-c00a8af Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCVSSCritical = 9.0
	DefaultCVSSHigh     = 7.0
	DefaultCVSSMedium   = 5.0
	DefaultCVSSLow      = 2.0
)
View Source
const (
	IDTableName = "id"
)
View Source
const (
	VulnerabilityMatchExclusionTableName = "vulnerability_match_exclusion"
)
View Source
const (
	VulnerabilityMetadataTableName = "vulnerability_metadata"
)
View Source
const (
	VulnerabilityTableName = "vulnerability"
)

Variables

This section is empty.

Functions

func ExtractExploitPocURL

func ExtractExploitPocURL(url []string) (string, []string)

func GetCvss

func GetCvss(c []Cvss) (float64, float64, string)

Cvss is a struct that represents the CVSS object

Types

type Advisory

type Advisory struct {
	ID   string `json:"id"`
	Link string `json:"link"`
}

Advisory represents published statements regarding a vulnerability (and potentially about it's resolution).

type Cvss

type Cvss struct {
	// VendorMetadata captures non-standard CVSS fields that vendors can sometimes
	// include when providing CVSS information.  This vendor-specific metadata type
	// allows to capture that data for persisting into the database
	VendorMetadata interface{} `json:"vendor_metadata"`
	Metrics        CvssMetrics `json:"metrics"`
	Vector         string      `json:"vector"`  // A textual representation of the metric values used to determine the score
	Version        string      `json:"version"` // The version of the CVSS spec, for example 2.0, 3.0, or 3.1
	Source         string      `json:"source"`  // Identifies the organization that provided the score
	Type           string      `json:"type"`    // Whether the source is a `primary` or `secondary` source
}

Cvss contains select Common Vulnerability Scoring System fields for a vulnerability.

type CvssMetrics

type CvssMetrics struct {
	// BaseScore ranges from 0 - 10 and defines qualities intrinsic to the severity of a vulnerability.
	BaseScore float64 `json:"base_score"`
	// ExploitabilityScore is a pointer to avoid having a 0 value by default.
	// It is an indicator of how easy it may be for an attacker to exploit
	// a vulnerability
	ExploitabilityScore *float64 `json:"exploitability_score"`
	// ImpactScore represents the effects of an exploited vulnerability
	// relative to compromise in confidentiality, integrity, and availability.
	// It is an optional parameter, so that is why it is a pointer instead of
	// a regular field
	ImpactScore *float64 `json:"impact_score"`
}

CvssMetrics are the quantitative values that make up a CVSS score.

type Fix

type Fix struct {
	Versions []string `json:"versions"` // The version(s) which this particular vulnerability was fixed in
	State    FixState `json:"state"`
}

Fix represents all information about known fixes for a stated vulnerability.

type FixState

type FixState string
const (
	UnknownFixState FixState = "unknown"
	FixedState      FixState = "fixed"
	NotFixedState   FixState = "not-fixed"
	WontFixState    FixState = "wont-fix"
)

type IDModel

type IDModel struct {
	BuildTimestamp string `gorm:"column:build_timestamp"`
	SchemaVersion  int    `gorm:"column:schema_version"`
}

func (IDModel) TableName

func (IDModel) TableName() string

type Vulnerability

type Vulnerability struct {
	ID                     string                   `json:"id"`                      // The identifier of the vulnerability or advisory
	PackageName            string                   `json:"package_name"`            // The name of the package that is vulnerable
	Namespace              string                   `json:"namespace"`               // The ecosystem where the package resides
	VersionConstraint      string                   `json:"version_constraint"`      // The version range which the given package is vulnerable
	VersionFormat          string                   `json:"version_format"`          // The format which all version fields should be interpreted as
	CPEs                   []string                 `json:"cpes"`                    // The CPEs which are considered vulnerable
	RelatedVulnerabilities []VulnerabilityReference `json:"related_vulnerabilities"` // Other Vulnerabilities that are related to this one (e.g. GHSA relate to CVEs, or how distro CVE relates to NVD record)
	Fix                    Fix                      `json:"fix"`                     // All information about fixed versions
	Advisories             []Advisory               `json:"advisories"`              // Any vendor advisories about fixes or other notifications about this vulnerability
}

Vulnerability represents the minimum data fields necessary to perform package-to-vulnerability matching. This can represent a CVE, 3rd party advisory, or any source that relates back to a CVE.

type VulnerabilityDBModel

type VulnerabilityDBModel struct {
	VulnerabilityModel         []VulnerabilityModel         `json:"vulnerability_model"`
	VulnerabilityMetadataModel []VulnerabilityMetadataModel `json:"vulnerability_metadata_model"`
	IDModel                    IDModel                      `json:"id_model"`
}

type VulnerabilityMatchExclusionModel

type VulnerabilityMatchExclusionModel struct {
	PK            uint64            `gorm:"primary_key;auto_increment;"`
	ID            string            `gorm:"column:id; index:get_vulnerability_match_exclusion_index"`
	Constraints   sqlite.NullString `gorm:"column:constraints; default:null"`
	Justification string            `gorm:"column:justification"`
}

VulnerabilityMatchExclusionModel is a struct used to serialize db.VulnerabilityMatchExclusion information into a sqlite3 DB.

func (VulnerabilityMatchExclusionModel) TableName

TableName returns the table which all db.VulnerabilityMatchExclusion model instances are stored into.

type VulnerabilityMetadata

type VulnerabilityMetadata struct {
	ID           string
	Namespace    string
	DataSource   string
	RecordSource string
	Severity     string
	URLs         []string
	Description  string
	Cvss         []Cvss
	CISAKEV      bool
	EPSSScore    float64
}

type VulnerabilityMetadataModel

type VulnerabilityMetadataModel struct {
	ID           string            `gorm:"primary_key; column:id;"`
	Namespace    string            `gorm:"primary_key; column:namespace;"`
	DataSource   string            `gorm:"column:data_source"`
	RecordSource string            `gorm:"column:record_source"`
	Severity     string            `gorm:"column:severity"`
	URLs         sqlite.NullString `gorm:"column:urls; default:null"`
	Description  string            `gorm:"column:description"`
	Cvss         sqlite.NullString `gorm:"column:cvss; default:null"`
	CISAKEV      bool              `gorm:"column:cisakev"`
	EPSSScore    float64           `gorm:"column:epss"`
}

VulnerabilityMetadataModel is a struct used to serialize db.VulnerabilityMetadata information into a sqlite3 DB.

func (*VulnerabilityMetadataModel) Inflate

Inflate generates a db.VulnerabilityMetadataModel object from the serialized model instance.

func (*VulnerabilityMetadataModel) TableName

func (m *VulnerabilityMetadataModel) TableName() string

TableName returns the table which all db.VulnerabilityMetadata model instances are stored into.

type VulnerabilityModel

type VulnerabilityModel struct {
	PK                     uint64            `gorm:"primary_key;auto_increment;"`
	ID                     string            `gorm:"column:id"`
	PackageName            string            `gorm:"column:package_name; index:get_vulnerability_index"`
	Namespace              string            `gorm:"column:namespace; index:get_vulnerability_index"`
	PackageQualifiers      sqlite.NullString `gorm:"column:package_qualifiers"`
	VersionConstraint      string            `gorm:"column:version_constraint"`
	VersionFormat          string            `gorm:"column:version_format"`
	CPEs                   sqlite.NullString `gorm:"column:cpes; default:null"`
	RelatedVulnerabilities sqlite.NullString `gorm:"column:related_vulnerabilities; default:null"`
	FixedInVersions        sqlite.NullString `gorm:"column:fixed_in_versions; default:null"`
	FixState               string            `gorm:"column:fix_state"`
	Advisories             sqlite.NullString `gorm:"column:advisories; default:null"`
}

VulnerabilityModel is a struct used to serialize db.Vulnerability information into a sqlite3 DB.

func (*VulnerabilityModel) Inflate

func (m *VulnerabilityModel) Inflate() (Vulnerability, error)

Inflate generates a db.Vulnerability object from the serialized model instance.

func (*VulnerabilityModel) TableName

func (m *VulnerabilityModel) TableName() string

TableName returns the table which all db.Vulnerability model instances are stored into.

type VulnerabilityReference

type VulnerabilityReference struct {
	ID        string `json:"id"`
	Namespace string `json:"namespace"`
}

Jump to

Keyboard shortcuts

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