Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
15102e4
Rewrite Debian conversion to make OSV files instead of PkgInfo #vc4a
jess-lowe Sep 3, 2025
b8d2774
Change debian id to include prefix and the OG ID as upstream
jess-lowe Sep 3, 2025
0a4975a
remove unused code
jess-lowe Sep 3, 2025
a5f5f30
Rename Debian CVE struct
jess-lowe Sep 3, 2025
f8294ea
these tests are testing me.
jess-lowe Sep 3, 2025
361626a
remove debian from combine-to-osv
jess-lowe Sep 3, 2025
4f4c42f
update dsa/dla/dtsa conversion to use DEBIAN- upstream
jess-lowe Sep 3, 2025
4d82cad
Merge remote-tracking branch 'upstream/master' into refactor/uncouple…
jess-lowe Sep 3, 2025
d5ce3bc
fix missing bracket and other fun things
jess-lowe Sep 4, 2025
56e04f3
Update output bucket
jess-lowe Sep 4, 2025
938f4dc
liiiiiiiiiiiiiint
jess-lowe Sep 4, 2025
bee5533
string lint thing
jess-lowe Sep 4, 2025
49355ac
fix test
jess-lowe Sep 4, 2025
0b7f388
L is for lint
jess-lowe Sep 4, 2025
da624e6
L is for last one??
jess-lowe Sep 4, 2025
7e6d368
just assign affectedVersion
jess-lowe Sep 4, 2025
6bd6a1d
Add published date
jess-lowe Sep 4, 2025
3dc23b7
fix tests
jess-lowe Sep 4, 2025
ea1c589
Update DSA conversion to include both DEBIAN-CVE and CVE-
jess-lowe Sep 5, 2025
05b5672
fix file name
jess-lowe Sep 7, 2025
a62297e
Merge remote-tracking branch 'upstream/master' into refactor/uncouple…
jess-lowe Sep 8, 2025
61e5095
Use NVD data for Published date
jess-lowe Sep 8, 2025
b524e8b
fix tests
jess-lowe Sep 8, 2025
b3b6645
update build script
jess-lowe Sep 8, 2025
9d61ab5
fix lint
jess-lowe Sep 8, 2025
617d5e4
Update output path to be the debian-osv bucket in line with DSAs and …
jess-lowe Sep 8, 2025
974229b
update cron job output buckets
jess-lowe Sep 8, 2025
ddc032b
don't write out files with no affected packages
jess-lowe Sep 8, 2025
bf73b98
fix lint
jess-lowe Sep 8, 2025
46af2f4
Update vulnfeeds/vulns/vulns.go
jess-lowe Sep 10, 2025
4820730
Rename loadTestData2
jess-lowe Sep 10, 2025
8eee496
reformat testdata
jess-lowe Sep 10, 2025
edc8a2d
make loadTestData a helper
jess-lowe Sep 10, 2025
7e9a081
fix mustRead thingy
jess-lowe Sep 10, 2025
e3e77b8
reformat test files
jess-lowe Sep 10, 2025
57b8170
Merge remote-tracking branch 'upstream/master' into refactor/uncouple…
jess-lowe Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
- name: GOOGLE_CLOUD_PROJECT
value: oss-vdb-test
- name: OUTPUT_GCS_BUCKET
value: osv-test-cve-osv-conversion
value: osv-test-debian-osv
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
- name: GOOGLE_CLOUD_PROJECT
value: oss-vdb
- name: OUTPUT_GCS_BUCKET
value: cve-osv-conversion
value: debian-osv
1 change: 0 additions & 1 deletion vulnfeeds/cmd/combine-to-osv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Combine [`PackageInfo`](https://github.com/google/osv.dev/blob/2c22e9534a521c6c6
To address the generation of CVE records from multiple disparate sources (all requiring a common record prefix):

* Alpine, by [this code](../alpine)
* Debian, by [this code](../debian)
* the NVD, by [this code](../nvd-cve-osv)

## How
Expand Down
48 changes: 3 additions & 45 deletions vulnfeeds/cmd/combine-to-osv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const (

alpineEcosystem = "Alpine"
alpineSecurityTrackerURL = "https://security.alpinelinux.org/vuln"
debianEcosystem = "Debian"
debianSecurityTrackerURL = "https://security-tracker.debian.org/tracker"
)

func main() {
Expand All @@ -47,7 +45,7 @@ func main() {
logger.Fatalf("Can't create output path: %s", err)
}

allCves := loadAllCVEs(*cvePath)
allCves := vulns.LoadAllCVEs(*cvePath)
allParts, cveModifiedMap := loadParts(*partsInputPath)
combinedData := combineIntoOSV(allCves, allParts, *cveListPath, cveModifiedMap)
writeOSVFile(combinedData, *osvOutputPath)
Expand Down Expand Up @@ -167,14 +165,10 @@ func combineIntoOSV(loadedCves map[cves.CVEID]cves.Vulnerability, allParts map[c
}
}

addedDebianURL := false
addedAlpineURL := false
for _, pkgInfo := range allParts[cveID] {
convertedCve.AddPkgInfo(pkgInfo)
if strings.HasPrefix(pkgInfo.Ecosystem, debianEcosystem) && !addedDebianURL {
addReference(string(cveID), debianEcosystem, convertedCve)
addedDebianURL = true
} else if strings.HasPrefix(pkgInfo.Ecosystem, alpineEcosystem) && !addedAlpineURL {
if strings.HasPrefix(pkgInfo.Ecosystem, alpineEcosystem) && !addedAlpineURL {
addReference(string(cveID), alpineEcosystem, convertedCve)
addedAlpineURL = true
}
Expand Down Expand Up @@ -210,47 +204,11 @@ func writeOSVFile(osvData map[cves.CVEID]*vulns.Vulnerability, osvOutputPath str
logger.Infof("Successfully written %d OSV files", len(osvData))
}

// loadAllCVEs loads the downloaded CVE's from the NVD database into memory.
func loadAllCVEs(cvePath string) map[cves.CVEID]cves.Vulnerability {
dir, err := os.ReadDir(cvePath)
if err != nil {
logger.Fatalf("Failed to read dir %s: %s", cvePath, err)
}

result := make(map[cves.CVEID]cves.Vulnerability)

for _, entry := range dir {
if !strings.HasSuffix(entry.Name(), ".json") {
continue
}
file, err := os.Open(path.Join(cvePath, entry.Name()))
if err != nil {
logger.Fatalf("Failed to open CVE JSON %q: %s", path.Join(cvePath, entry.Name()), err)
}
var nvdcve cves.CVEAPIJSON20Schema
err = json.NewDecoder(file).Decode(&nvdcve)
if err != nil {
logger.Fatalf("Failed to decode JSON in %q: %s", file.Name(), err)
}

for _, item := range nvdcve.Vulnerabilities {
result[item.CVE.ID] = item
}
logger.Infof("Loaded CVE: %s", entry.Name())
file.Close()
}

return result
}

// addReference adds the related security tracker URL to a given vulnerability's references
func addReference(cveID string, ecosystem string, convertedCve *vulns.Vulnerability) {
securityReference := osvschema.Reference{Type: osvschema.ReferenceAdvisory}
switch ecosystem {
case alpineEcosystem:
if ecosystem == alpineEcosystem {
securityReference.URL, _ = url.JoinPath(alpineSecurityTrackerURL, cveID)
case debianEcosystem:
securityReference.URL, _ = url.JoinPath(debianSecurityTrackerURL, cveID)
}

if securityReference.URL == "" {
Expand Down
6 changes: 3 additions & 3 deletions vulnfeeds/cmd/combine-to-osv/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ func TestCombineIntoOSV(t *testing.T) {
if len(combinedOSV[cve].Affected) != len(allParts[cve]) {
t.Errorf("Affected lengths for %s do not match", cve)
}

found := false
switch cve {
case "CVE-2018-1000500":
for _, reference := range combinedOSV[cve].References {
if reference.Type == "ADVISORY" &&
reference.URL == "https://security-tracker.debian.org/tracker/CVE-2018-1000500" {
found = true
t.Errorf("Found unexpected Debian advisory URL for %s", cve)
}
}
case "CVE-2022-33745":
Expand All @@ -128,12 +129,11 @@ func TestCombineIntoOSV(t *testing.T) {
}
}
}
if !found {
if !found && cve != "CVE-2018-1000500" {
t.Errorf("%s doesn't have all expected references", cve)
}
}
}

func TestGetModifiedTime(t *testing.T) {
_, err := getModifiedTime("../../test_data/parts/debian/CVE-2016-1585.debian.json")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions vulnfeeds/cmd/debian/debian_security_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ type Release struct {
Urgency string `json:"urgency"`
}

type CVE struct {
type DebianCVE struct {
Description string `json:"description"`
DebianBug int
Scope string `json:"scope"`
Releases map[string]Release `json:"releases"`
}

type DebianSecurityTrackerData map[string]map[string]CVE
type DebianSecurityTrackerData map[string]map[string]DebianCVE
Loading
Loading