golang.org/x/tools/gopls@v0.15.3/internal/vulncheck/osv/osv.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated by copying from golang.org/x/vuln@v1.0.1 (go run copier.go); DO NOT EDIT. 6 7 // Package osv implements the Go OSV vulnerability format 8 // (https://go.dev/security/vuln/database#schema), which is a subset of 9 // the OSV shared vulnerability format 10 // (https://ossf.github.io/osv-schema), with database and 11 // ecosystem-specific meanings and fields. 12 // 13 // As this package is intended for use with the Go vulnerability 14 // database, only the subset of features which are used by that 15 // database are implemented (for instance, only the SEMVER affected 16 // range type is implemented). 17 package osv 18 19 import "time" 20 21 // RangeType specifies the type of version range being recorded and 22 // defines the interpretation of the RangeEvent object's Introduced 23 // and Fixed fields. 24 // 25 // In this implementation, only the "SEMVER" type is supported. 26 // 27 // See https://ossf.github.io/osv-schema/#affectedrangestype-field. 28 type RangeType string 29 30 // RangeTypeSemver indicates a semantic version as defined by 31 // SemVer 2.0.0, with no leading "v" prefix. 32 const RangeTypeSemver RangeType = "SEMVER" 33 34 // Ecosystem identifies the overall library ecosystem. 35 // In this implementation, only the "Go" ecosystem is supported. 36 type Ecosystem string 37 38 // GoEcosystem indicates the Go ecosystem. 39 const GoEcosystem Ecosystem = "Go" 40 41 // Pseudo-module paths used to describe vulnerabilities 42 // in the Go standard library and toolchain. 43 const ( 44 // GoStdModulePath is the pseudo-module path string used 45 // to describe vulnerabilities in the Go standard library. 46 GoStdModulePath = "stdlib" 47 // GoCmdModulePath is the pseudo-module path string used 48 // to describe vulnerabilities in the go command. 49 GoCmdModulePath = "toolchain" 50 ) 51 52 // Module identifies the Go module containing the vulnerability. 53 // Note that this field is called "package" in the OSV specification. 54 // 55 // See https://ossf.github.io/osv-schema/#affectedpackage-field. 56 type Module struct { 57 // The Go module path. Required. 58 // For the Go standard library, this is "stdlib". 59 // For the Go toolchain, this is "toolchain." 60 Path string `json:"name"` 61 // The ecosystem containing the module. Required. 62 // This should always be "Go". 63 Ecosystem Ecosystem `json:"ecosystem"` 64 } 65 66 // RangeEvent describes a single module version that either 67 // introduces or fixes a vulnerability. 68 // 69 // Exactly one of Introduced and Fixed must be present. Other range 70 // event types (e.g, "last_affected" and "limit") are not supported in 71 // this implementation. 72 // 73 // See https://ossf.github.io/osv-schema/#affectedrangesevents-fields. 74 type RangeEvent struct { 75 // Introduced is a version that introduces the vulnerability. 76 // A special value, "0", represents a version that sorts before 77 // any other version, and should be used to indicate that the 78 // vulnerability exists from the "beginning of time". 79 Introduced string `json:"introduced,omitempty"` 80 // Fixed is a version that fixes the vulnerability. 81 Fixed string `json:"fixed,omitempty"` 82 } 83 84 // Range describes the affected versions of the vulnerable module. 85 // 86 // See https://ossf.github.io/osv-schema/#affectedranges-field. 87 type Range struct { 88 // Type is the version type that should be used to interpret the 89 // versions in Events. Required. 90 // In this implementation, only the "SEMVER" type is supported. 91 Type RangeType `json:"type"` 92 // Events is a list of versions representing the ranges in which 93 // the module is vulnerable. Required. 94 // The events should be sorted, and MUST represent non-overlapping 95 // ranges. 96 // There must be at least one RangeEvent containing a value for 97 // Introduced. 98 // See https://ossf.github.io/osv-schema/#examples for examples. 99 Events []RangeEvent `json:"events"` 100 } 101 102 // Reference type is a reference (link) type. 103 type ReferenceType string 104 105 const ( 106 // ReferenceTypeAdvisory is a published security advisory for 107 // the vulnerability. 108 ReferenceTypeAdvisory = ReferenceType("ADVISORY") 109 // ReferenceTypeArticle is an article or blog post describing the vulnerability. 110 ReferenceTypeArticle = ReferenceType("ARTICLE") 111 // ReferenceTypeReport is a report, typically on a bug or issue tracker, of 112 // the vulnerability. 113 ReferenceTypeReport = ReferenceType("REPORT") 114 // ReferenceTypeFix is a source code browser link to the fix (e.g., a GitHub commit). 115 ReferenceTypeFix = ReferenceType("FIX") 116 // ReferenceTypePackage is a home web page for the package. 117 ReferenceTypePackage = ReferenceType("PACKAGE") 118 // ReferenceTypeEvidence is a demonstration of the validity of a vulnerability claim. 119 ReferenceTypeEvidence = ReferenceType("EVIDENCE") 120 // ReferenceTypeWeb is a web page of some unspecified kind. 121 ReferenceTypeWeb = ReferenceType("WEB") 122 ) 123 124 // Reference is a reference URL containing additional information, 125 // advisories, issue tracker entries, etc., about the vulnerability. 126 // 127 // See https://ossf.github.io/osv-schema/#references-field. 128 type Reference struct { 129 // The type of reference. Required. 130 Type ReferenceType `json:"type"` 131 // The fully-qualified URL of the reference. Required. 132 URL string `json:"url"` 133 } 134 135 // Affected gives details about a module affected by the vulnerability. 136 // 137 // See https://ossf.github.io/osv-schema/#affected-fields. 138 type Affected struct { 139 // The affected Go module. Required. 140 // Note that this field is called "package" in the OSV specification. 141 Module Module `json:"package"` 142 // The module version ranges affected by the vulnerability. 143 Ranges []Range `json:"ranges,omitempty"` 144 // Details on the affected packages and symbols within the module. 145 EcosystemSpecific EcosystemSpecific `json:"ecosystem_specific"` 146 } 147 148 // Package contains additional information about an affected package. 149 // This is an ecosystem-specific field for the Go ecosystem. 150 type Package struct { 151 // Path is the package import path. Required. 152 Path string `json:"path,omitempty"` 153 // GOOS is the execution operating system where the symbols appear, if 154 // known. 155 GOOS []string `json:"goos,omitempty"` 156 // GOARCH specifies the execution architecture where the symbols appear, if 157 // known. 158 GOARCH []string `json:"goarch,omitempty"` 159 // Symbols is a list of function and method names affected by 160 // this vulnerability. Methods are listed as <recv>.<method>. 161 // 162 // If included, only programs which use these symbols will be marked as 163 // vulnerable by `govulncheck`. If omitted, any program which imports this 164 // package will be marked vulnerable. 165 Symbols []string `json:"symbols,omitempty"` 166 } 167 168 // EcosystemSpecific contains additional information about the vulnerable 169 // module for the Go ecosystem. 170 // 171 // See https://go.dev/security/vuln/database#schema. 172 type EcosystemSpecific struct { 173 // Packages is the list of affected packages within the module. 174 Packages []Package `json:"imports,omitempty"` 175 } 176 177 // Entry represents a vulnerability in the Go OSV format, documented 178 // in https://go.dev/security/vuln/database#schema. 179 // It is a subset of the OSV schema (https://ossf.github.io/osv-schema). 180 // Only fields that are published in the Go Vulnerability Database 181 // are supported. 182 type Entry struct { 183 // SchemaVersion is the OSV schema version used to encode this 184 // vulnerability. 185 SchemaVersion string `json:"schema_version,omitempty"` 186 // ID is a unique identifier for the vulnerability. Required. 187 // The Go vulnerability database issues IDs of the form 188 // GO-<YEAR>-<ENTRYID>. 189 ID string `json:"id"` 190 // Modified is the time the entry was last modified. Required. 191 Modified time.Time `json:"modified,omitempty"` 192 // Published is the time the entry should be considered to have 193 // been published. 194 Published time.Time `json:"published,omitempty"` 195 // Withdrawn is the time the entry should be considered to have 196 // been withdrawn. If the field is missing, then the entry has 197 // not been withdrawn. 198 Withdrawn *time.Time `json:"withdrawn,omitempty"` 199 // Aliases is a list of IDs for the same vulnerability in other 200 // databases. 201 Aliases []string `json:"aliases,omitempty"` 202 // Summary gives a one-line, English textual summary of the vulnerability. 203 // It is recommended that this field be kept short, on the order of no more 204 // than 120 characters. 205 Summary string `json:"summary,omitempty"` 206 // Details contains additional English textual details about the vulnerability. 207 Details string `json:"details"` 208 // Affected contains information on the modules and versions 209 // affected by the vulnerability. 210 Affected []Affected `json:"affected"` 211 // References contains links to more information about the 212 // vulnerability. 213 References []Reference `json:"references,omitempty"` 214 // Credits contains credits to entities that helped find or fix the 215 // vulnerability. 216 Credits []Credit `json:"credits,omitempty"` 217 // DatabaseSpecific contains additional information about the 218 // vulnerability, specific to the Go vulnerability database. 219 DatabaseSpecific *DatabaseSpecific `json:"database_specific,omitempty"` 220 } 221 222 // Credit represents a credit for the discovery, confirmation, patch, or 223 // other event in the life cycle of a vulnerability. 224 // 225 // See https://ossf.github.io/osv-schema/#credits-fields. 226 type Credit struct { 227 // Name is the name, label, or other identifier of the individual or 228 // entity being credited. Required. 229 Name string `json:"name"` 230 } 231 232 // DatabaseSpecific contains additional information about the 233 // vulnerability, specific to the Go vulnerability database. 234 // 235 // See https://go.dev/security/vuln/database#schema. 236 type DatabaseSpecific struct { 237 // The URL of the Go advisory for this vulnerability, of the form 238 // "https://pkg.go.dev/GO-YYYY-XXXX". 239 URL string `json:"url,omitempty"` 240 }