Documentation
¶
Index ¶
- Constants
- type Affected
- type AffectedSlice
- func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Filter(filterFunc func(affected *Affected[EcosystemSpecific, DatabaseSpecific]) bool) AffectedSlice[EcosystemSpecific, DatabaseSpecific]
- func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) FilterByEcosystem(ecosystem Ecosystem) AffectedSlice[EcosystemSpecific, DatabaseSpecific]
- func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) HasEcosystem(ecosystem Ecosystem) bool
- func (x *AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Scan(src any) error
- func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Value() (driver.Value, error)
- type Aliases
- type Credits
- type CreditsType
- type Ecosystem
- type Event
- type Events
- type OsvSchema
- type Package
- type Range
- type RangeType
- type Reference
- type ReferenceType
- type References
- type Related
- type Severity
- type SeveritySlice
- type SeverityType
Constants ¶
View Source
const ( // RangeTypeSemver The versions introduced and fixed are semantic versions as defined by SemVer 2.0.0, with no leading “v” prefix. // The relation u < v denotes the precedence order defined in section 11 of SemVer 2.0. Ranges listed with type SEMVER // should not overlap: since SEMVER is a strict linear ordering, it is always possible to simplify to non-overlapping ranges. // Specifying one or more SEMVER ranges removes the requirement to specify an explicit enumerated versions list (see the discussion above). // Some ecosystems may recommend using SemVer 2.0 for versioning without explicitly enforcing it. In those cases you should use the ECOSYSTEM type instead. RangeTypeSemver = "SEMVER" // RangeTypeEcosystem The versions introduced and fixed are arbitrary, uninterpreted strings specific to the package ecosystem, // which does not conform to SemVer 2.0’s version ordering. // It is recommended that you provide an explicitly enumerated versions list when specifying one or more ECOSYSTEM ranges, // because ECOSYSTEM range inclusion queries may not be able to be answered without reference to the package ecosystem’s // own logic and therefore may not be able to be used by ecosystem-independent processors. The infrastructure and tooling // provided by https://osv.dev also provides automation for auto-populating the versions list based on supported ECOSYSTEM // ranges as part of the ingestion process. RangeTypeEcosystem = "ECOSYSTEM" // RangeTypeGit The versions introduced and fixed are full-length Git commit hashes. The repository’s commit graph is needed to evaluate // whether a given version is in the range. The relation u < v is true when commit u is a (perhaps distant) parent of commit v. RangeTypeGit = "GIT" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Affected ¶
type Affected[EcosystemSpecific, DatabaseSpecific any] struct { // 被此漏洞影响到的包 Package *Package `json:"package" yaml:"package" db:"package" bson:"package" gorm:"column:package;serializer:json"` // 被影响到的这个包的哪些版本,通常是版本区间 Ranges []*Range[DatabaseSpecific] `json:"ranges" yaml:"ranges" db:"ranges" bson:"ranges" gorm:"column:ranges;serializer:json"` // 可选的严重级别 Severity []*Severity `json:"severity" yaml:"severity" db:"severity" bson:"severity" gorm:"column:severity;serializer:json"` // 枚举出每一个受影响的版本 Versions []string `json:"versions" yaml:"versions" db:"versions" bson:"versions" gorm:"column:versions;serializer:json"` // 由包管理器决定 EcosystemSpecific EcosystemSpecific `` /* 150-byte string literal not displayed */ // 由具体实现的数据库决定 DatabaseSpecific DatabaseSpecific `` /* 145-byte string literal not displayed */ }
Affected 漏洞的某个影响范围,它可能会影响到很多个版本范围,这表示其中一个 Example: "affected": [
{
"package": {
"ecosystem": "RubyGems",
"name": "sprout"
},
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.7.246"
}
]
}
]
}
],
type AffectedSlice ¶
type AffectedSlice[EcosystemSpecific, DatabaseSpecific any] []*Affected[EcosystemSpecific, DatabaseSpecific]
AffectedSlice 表示一个影响范围的集合
func (AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Filter ¶
func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Filter(filterFunc func(affected *Affected[EcosystemSpecific, DatabaseSpecific]) bool) AffectedSlice[EcosystemSpecific, DatabaseSpecific]
Filter 过滤影响范围
func (AffectedSlice[EcosystemSpecific, DatabaseSpecific]) FilterByEcosystem ¶
func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) FilterByEcosystem(ecosystem Ecosystem) AffectedSlice[EcosystemSpecific, DatabaseSpecific]
FilterByEcosystem 根据ecosystem过滤影响范围
func (AffectedSlice[EcosystemSpecific, DatabaseSpecific]) HasEcosystem ¶
func (x AffectedSlice[EcosystemSpecific, DatabaseSpecific]) HasEcosystem(ecosystem Ecosystem) bool
HasEcosystem 判断被影响到的包是否有包含给定的包管理器的,一般用于过滤
func (*AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Scan ¶
func (x *AffectedSlice[EcosystemSpecific, DatabaseSpecific]) Scan(src any) error
type Credits ¶
type CreditsType ¶
type CreditsType string
const ( // CreditsTypeFinder FINDER: identified the vulnerability. CreditsTypeFinder CreditsType = "FINDER" // CreditsTypeReporter REPORTER: notified the vendor of the vulnerability to a CNA. CreditsTypeReporter CreditsType = "REPORTER" // CreditsTypeAnalyst ANALYST: validated the vulnerability to ensure accuracy or severity. CreditsTypeAnalyst CreditsType = "ANALYST" // CreditsTypeCoordinator COORDINATOR: facilitated the coordinated response process. CreditsTypeCoordinator CreditsType = "COORDINATOR" // CreditsTypeRemediationDeveloper REMEDIATION_DEVELOPER: prepared a code change or other remediation plans. CreditsTypeRemediationDeveloper CreditsType = "REMEDIATION_DEVELOPER" // CreditsTypeRemediationReviewer REMEDIATION_REVIEWER: reviewed vulnerability remediation plans or code changes for effectiveness and completeness. CreditsTypeRemediationReviewer CreditsType = "REMEDIATION_REVIEWER" // CreditsTypeRemediationVerifier REMEDIATION_VERIFIER: tested and verified the vulnerability or its remediation. CreditsTypeRemediationVerifier CreditsType = "REMEDIATION_VERIFIER" // CreditsTypeTool TOOL: names of tools used in vulnerability discovery or identification. CreditsTypeTool CreditsType = "TOOL" // CreditsTypeSponsor SPONSOR: supported the vulnerability identification or remediation activities. CreditsTypeSponsor CreditsType = "SPONSOR" // CreditsTypeOther OTHER: any other type or role that does not fall under the categories described above. CreditsTypeOther CreditsType = "OTHER" )
type Ecosystem ¶
type Ecosystem string
Ecosystem 表示包管理器的类型,比如 Maven
const ( // EcosystemGo Go The Go ecosystem; the name field is a Go module path. EcosystemGo Ecosystem = "Go" // EcosystemNpm npm The NPM ecosystem; the name field is an NPM package name. EcosystemNpm Ecosystem = "npm" // EcosystemOSSFuzz OSS-Fuzz For reports from the OSS-Fuzz project that have no more appropriate ecosystem; // the name field is the name assigned by the OSS-Fuzz project, as recorded in the submitted fuzzing configuration. EcosystemOSSFuzz Ecosystem = "OSS-Fuzz" // EcosystemPyPI PyPI the Python PyPI ecosystem; the name field is a normalized PyPI package name. EcosystemPyPI Ecosystem = "PyPI" // EcosystemRubyGems RubyGems The RubyGems ecosystem; the name field is a gem name. EcosystemRubyGems Ecosystem = "RubyGems" // EcosystemCratesIo crates.io The crates.io ecosystem for Rust; the name field is a crate name. EcosystemCratesIo Ecosystem = "crates.io" // EcosystemPackagist Packagist The PHP package manager ecosystem; the name is a package name. EcosystemPackagist Ecosystem = "Packagist" // EcosystemMaven Maven The Maven Java package ecosystem. The name field is a Maven package name. EcosystemMaven Ecosystem = "Maven" // EcosystemNuGet NuGet The NuGet package ecosystem. The name field is a NuGet package name. EcosystemNuGet Ecosystem = "NuGet" // EcosystemLinux Linux The Linux kernel. The only supported name is Kernel. EcosystemLinux Ecosystem = "Linux" // EcosystemDebian Debian The Debian package ecosystem; the name is the name of the source package. The ecosystem // string might optionally have a :<RELEASE> suffix to scope the package to a particular Debian release. <RELEASE> // is a numeric version specified in the Debian distro-info-data. For example, the ecosystem string “Debian:7” refers // to the Debian 7 (wheezy) release. EcosystemDebian Ecosystem = "Debian" // EcosystemAlpine Alpine The Alpine package ecosystem; the name is the name of the source package. // The ecosystem string must have a :v<RELEASE-NUMBER> suffix to scope the package to a particular Alpine release // branch (the v prefix is required). E.g. v3.16. EcosystemAlpine Ecosystem = "Alpine" // EcosystemHex Hex The package manager for the Erlang ecosystem; the name is a Hex package name. EcosystemHex Ecosystem = "Hex" // EcosystemAndroid Android The Android ecosystem; the name field is the Android component name that the patch // applies to, as shown in the Android Security Bulletins such as Framework, Media Framework and Kernel Component. // The exhaustive list of components can be found at the Appendix. EcosystemAndroid Ecosystem = "Android" // EcosystemGitHubActions GitHub Actions The GitHub Actions ecosystem; the name field is the action’s repository // name with owner e.g. {owner}/{repo}. EcosystemGitHubActions Ecosystem = "GitHub Actions" // EcosystemPub Pub The package manager for the Dart ecosystem; the name field is a Dart package name. EcosystemPub Ecosystem = "Pub" // EcosystemConanCenter ConanCenter The ConanCenter ecosystem for C and C++; the name field is a Conan package name. EcosystemConanCenter Ecosystem = "ConanCenter" // EcosystemRocky Rocky Linux The Rocky Linux package ecosystem; the name is the name of the source package. // The ecosystem string might optionally have a :<RELEASE> suffix to scope the package to a particular Rocky Linux // release. <RELEASE> is a numeric version. EcosystemRocky Ecosystem = "Rocky" // EcosystemAlmaLinux AlmaLinux package ecosystem; the name is the name of the source package. The ecosystem string // might optionally have a :<RELEASE> suffix to scope the package to a particular AlmaLinux release. <RELEASE> is a // numeric version. EcosystemAlmaLinux Ecosystem = "AlmaLinux" )
type Event ¶
type Event struct {
// 哪个版本引入的
Introduced string `json:"introduced" yaml:"introduced" db:"introduced" bson:"introduced" gorm:"column:introduced"`
// 哪个版本修复的
Fixed string `json:"fixed" yaml:"fixed" db:"fixed" bson:"fixed" gorm:"column:fixed"`
// 已知的最后影响版本是哪个
LastAffected string `json:"last_affected" yaml:"last_affected" db:"last_affected" bson:"last_affected" gorm:"column:last_affected"`
Limit string `json:"limit" yaml:"limit" db:"limit" bson:"limit" gorm:"column:limit"`
}
"events": [
{
"introduced": "2.3.0"
},
{
"fixed": "2.3.18"
}
]
func (*Event) IsIntroduced ¶
func (*Event) IsLastAffected ¶
type OsvSchema ¶
type OsvSchema[EcosystemSpecific, DatabaseSpecific any] struct { // OSV的版本 SchemaVersion string `json:"schema_version" yaml:"schema_version" db:"schema_version" bson:"schema_version" gorm:"column:schema_version"` ID string `json:"id" yaml:"id" db:"id" bson:"id" gorm:"column:id"` // 修改日期 Modified time.Time `json:"modified" yaml:"modified" db:"modified" bson:"modified" gorm:"column:modified"` // 发布日期 Published time.Time `json:"published" yaml:"published" db:"published" bson:"published" gorm:"column:published"` // TODO 2023-5-23 19:10:45 草这个字段啥意思... Withdrawn string `json:"withdrawn" yaml:"withdrawn" db:"withdrawn" bson:"withdrawn" gorm:"column:withdrawn"` // 漏洞的编号 Aliases Aliases `json:"aliases" yaml:"aliases" db:"aliases" bson:"aliases" gorm:"column:aliases;serializer:json"` Related Related `json:"related" yaml:"related" db:"related" bson:"related" gorm:"column:related;serializer:json"` // 可以认为是漏洞标题啥的 Summary string `json:"summary" yaml:"summary" db:"summary" bson:"summary" gorm:"column:summary"` // 可以认为是漏洞详情啥的 Details string `json:"details" yaml:"details" db:"details" bson:"details" gorm:"column:details"` // 漏洞的严重级别 Severity SeveritySlice `json:"severity" yaml:"severity" db:"severity" bson:"severity" gorm:"column:severity;serializer:json"` // 漏洞的影响范围 Affected AffectedSlice[EcosystemSpecific, DatabaseSpecific] `json:"affected" yaml:"affected" db:"affected" bson:"affected" gorm:"column:affected;serializer:json"` // 参考资料 References References `json:"references" yaml:"references" db:"references" bson:"references" gorm:"column:references;serializer:json"` // 漏洞库自己的实现规范 DatabaseSpecific DatabaseSpecific `` /* 145-byte string literal not displayed */ Credits *Credits `json:"credits" yaml:"credits" db:"credits" bson:"credits" gorm:"column:credits;serializer:json"` }
OsvSchema 表示一个OSV格式的漏洞数据 参考文档: https://ossf.github.io/osv-schema/
type Package ¶
type Package struct {
// 包管理器类型
Ecosystem Ecosystem `json:"ecosystem" yaml:"ecosystem" db:"ecosystem" bson:"ecosystem" gorm:"column:ecosystem"`
// 包的名字
Name string `json:"name" yaml:"name" db:"name" bson:"name" gorm:"column:name"`
// https://github.com/package-url/purl-spec
PackageUrl string `json:"purl" yaml:"purl" db:"purl" bson:"purl" gorm:"column:purl"`
}
"package": {
"ecosystem": "RubyGems",
"name": "sprout"
},
func (*Package) GetArtifactID ¶
GetArtifactID @see GetGroupID
func (*Package) GetGroupID ¶
GetGroupID 如果ecosystem是maven的话,则name是GroupId:ArtifactID这样拼接在一起的,提供两个单独获取的API
type Range ¶
type Range[DatabaseSpecific any] struct { // 范围的类型,如果是软件包的话通常情况下看的是ecosystem Type RangeType `json:"type" yaml:"type" db:"type" bson:"type" gorm:"column:type"` Repo string `json:"repo" yaml:"repo" db:"repo" bson:"repo" gorm:"column:repo"` // 具体的范围 Events Events `json:"events" yaml:"events" db:"events" bson:"events" gorm:"column:events;serializer:json"` // 由具体实现的数据库决定 DatabaseSpecific DatabaseSpecific `` /* 145-byte string literal not displayed */ }
Range 用于表示被漏洞影响的范围 Example:
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.7.246"
}
]
}
type Reference ¶
type Reference struct {
// 引用的类型
Type ReferenceType `json:"type" yaml:"type" db:"type" bson:"type" gorm:"column:type"`
// 具体的引用链接
URL string `json:"url" yaml:"url" db:"url" bson:"url" gorm:"column:url"`
}
Reference Example:
{
"type": "WEB",
"url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-vxv8-r8q2-63xw"
}
type ReferenceType ¶
type ReferenceType string
const ( // ReferenceTypeAdvisory A published security advisory for the vulnerability. ReferenceTypeAdvisory ReferenceType = "ADVISORY" // ReferenceTypeArticle An article or blog post describing the vulnerability. ReferenceTypeArticle ReferenceType = "ARTICLE" // ReferenceTypeDetection A tool, script, scanner, or other mechanism that allows for detection of the vulnerability // in production environments. e.g. YARA rules, hashes, virus signature, or other scanners. ReferenceTypeDetection ReferenceType = "DETECTION" // ReferenceTypeDiscussion A social media discussion regarding the vulnerability, e.g. a Twitter, Mastodon, Hacker News, // or Reddit thread. ReferenceTypeDiscussion ReferenceType = "DISCUSSION" // ReferenceTypeReport A report, typically on a bug or issue tracker, of the vulnerability. ReferenceTypeReport ReferenceType = "REPORT" // ReferenceTypeFix A source code browser link to the fix (e.g., a GitHub commit) Note that the fix type is meant for // viewing by people using web browsers. Programs interested in analyzing the exact commit range would do better to use // the GIT-typed affected[].ranges entries (described above). ReferenceTypeFix ReferenceType = "FIX" // ReferenceTypeIntroduced A source code browser link to the introduction of the vulnerability (e.g., a GitHub commit) // Note that the introduced type is meant for viewing by people using web browsers. Programs interested in analyzing the // exact commit range would do better to use the GIT-typed affected[].ranges entries (described above). ReferenceTypeIntroduced ReferenceType = "introduced" // ReferenceTypePackage A home web page for the package. ReferenceTypePackage ReferenceType = "PACKAGE" // ReferenceTypeEvidence A demonstration of the validity of a vulnerability claim, e.g. app.any.run replaying the // exploitation of the vulnerability. ReferenceTypeEvidence ReferenceType = "evidence" // ReferenceTypeWeb A web page of some unspecified kind. ReferenceTypeWeb ReferenceType = "WEB" )
type References ¶
type References []*Reference
func (References) FilterByType ¶
func (x References) FilterByType(referenceTypes ...ReferenceType) References
func (*References) Scan ¶
func (x *References) Scan(src any) error
type Severity ¶
type Severity struct {
Type SeverityType `json:"type" yaml:"type" db:"type" bson:"type" gorm:"column:type"`
Score string `json:"score" yaml:"score" db:"score" bson:"score" gorm:"column:score"`
// contains filtered or unexported fields
}
Severity Example:
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
}
Document: https://ossf.github.io/osv-schema/#severity-field
func (*Severity) GetScoreAsFloat ¶
func (*Severity) GetScoreAsPointer ¶
type SeveritySlice ¶
type SeveritySlice []*Severity
func (SeveritySlice) GetCVSS2 ¶
func (x SeveritySlice) GetCVSS2() *Severity
func (SeveritySlice) GetCVSS3 ¶
func (x SeveritySlice) GetCVSS3() *Severity
func (*SeveritySlice) Scan ¶
func (x *SeveritySlice) Scan(src any) error
type SeverityType ¶
type SeverityType string
const ( // SeverityTypeCVSS2 e.g."AV:L/AC:M/Au:N/C:N/I:P/A:C" SeverityTypeCVSS2 SeverityType = "CVSS_V2" // SeverityTypeCVSS3 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N SeverityTypeCVSS3 SeverityType = "CVSS_V3" )
Click to show internal directories.
Click to hide internal directories.