Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the OS version in the DPKG inventory Ecosystem. #152

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions extractor/filesystem/os/dpkg/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,9 @@ func (e Extractor) ToCPEs(i *extractor.Inventory) ([]string, error) { return []s
// Ecosystem returns the OSV Ecosystem of the software extracted by this extractor.
func (Extractor) Ecosystem(i *extractor.Inventory) (string, error) {
m := i.Metadata.(*Metadata)
if m.OSID != "" {
// Capitalize first letter for the Ecosystem string.
return cases.Title(language.English).String(m.OSID), nil
osID := cases.Title(language.English).String(toNamespace(m))
if m.OSVersionID == "" {
return osID, nil
}
log.Errorf("os-release[ID] not set, fallback to 'Linux'")
return "Linux", nil
return osID + ":" + m.OSVersionID, nil
}
8 changes: 8 additions & 0 deletions extractor/filesystem/os/dpkg/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,14 @@ func TestEcosystem(t *testing.T) {
metadata: &dpkg.Metadata{},
want: "Linux",
},
{
name: "OS version present",
metadata: &dpkg.Metadata{
OSID: "debian",
OSVersionID: "12",
},
want: "Debian:12",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading