Skip to content

Commit 5cfb147

Browse files
committed
Add/fix package version for BellSoft/Alpaquita OS package versions
1 parent a16b04d commit 5cfb147

6 files changed

Lines changed: 48 additions & 0 deletions

File tree

extractor/filesystem/os/apk/apk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func (e Extractor) Requirements() *plugin.Capabilities { return &plugin.Capabili
8989
func (e Extractor) FileRequired(api filesystem.FileAPI) bool {
9090
// Should match the status file.
9191
if filepath.ToSlash(api.Path()) != "lib/apk/db/installed" &&
92+
filepath.ToSlash(api.Path()) != "var/lib/apk/db/installed" &&
9293
// TODO(b/428271704): Remove once we handle symlinks properly.
9394
filepath.ToSlash(api.Path()) != "usr/lib/apk/db/installed" {
9495
return false

extractor/filesystem/os/apk/apk_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ func TestFileRequired(t *testing.T) {
5858
wantRequired: true,
5959
wantResultMetric: stats.FileRequiredResultOK,
6060
},
61+
{
62+
name: "installed file in /var",
63+
path: "var/lib/apk/db/installed",
64+
wantRequired: true,
65+
wantResultMetric: stats.FileRequiredResultOK,
66+
},
6167
{
6268
name: "sub file",
6369
path: "lib/apk/db/installed/test",

extractor/filesystem/os/ecosystem/ecosystem.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ func MakeEcosystem(metadata any) osvecosystem.Parsed {
4343
if version == "" {
4444
return osvecosystem.FromEcosystem(osvconstants.EcosystemAlpine)
4545
}
46+
if m.OSID == "alpaquita" {
47+
return osvecosystem.Parsed{Ecosystem: osvconstants.EcosystemAlpaquita, Suffix: m.OSVersionID}
48+
}
49+
if m.OSID == "bellsoft-hardened-containers" {
50+
return osvecosystem.Parsed{Ecosystem: osvconstants.EcosystemBellSoftHardenedContainers, Suffix: m.OSVersionID}
51+
}
4652
return osvecosystem.Parsed{Ecosystem: osvconstants.EcosystemAlpine, Suffix: m.TrimDistroVersion(version)}
4753

4854
case *dpkgmeta.Metadata:

extractor/filesystem/os/ecosystem/ecosystem_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,38 @@ func TestMakeEcosystemAPK(t *testing.T) {
5757
metadata: &apkmeta.Metadata{},
5858
want: "Alpine",
5959
},
60+
{
61+
desc: "BellSoft 1st case",
62+
metadata: &apkmeta.Metadata{
63+
OSID: "alpaquita",
64+
OSVersionID: "23",
65+
},
66+
want: "Alpaquita:23",
67+
},
68+
{
69+
desc: "BellSoft 2nd case",
70+
metadata: &apkmeta.Metadata{
71+
OSID: "alpaquita",
72+
OSVersionID: "stream",
73+
},
74+
want: "Alpaquita:stream",
75+
},
76+
{
77+
desc: "BellSoft 3rd case",
78+
metadata: &apkmeta.Metadata{
79+
OSID: "bellsoft-hardened-containers",
80+
OSVersionID: "23",
81+
},
82+
want: "BellSoft Hardened Containers:23",
83+
},
84+
{
85+
desc: "BellSoft 4th case",
86+
metadata: &apkmeta.Metadata{
87+
OSID: "bellsoft-hardened-containers",
88+
OSVersionID: "stream",
89+
},
90+
want: "BellSoft Hardened Containers:stream",
91+
},
6092
}
6193
for _, tt := range tests {
6294
t.Run(tt.desc, func(t *testing.T) {

semantic/parse.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func Parse(str string, ecosystem string) (Version, error) {
5656
return parseAlpineVersion(str)
5757
case "Alpine":
5858
return parseAlpineVersion(str)
59+
case "BellSoft Hardened Containers":
60+
return parseAlpineVersion(str)
5961
case "Bitnami":
6062
return parseSemverVersion(str), nil
6163
case "Bioconductor":

semantic/parse_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var ecosystems = []string{
2525
"AlmaLinux",
2626
"Alpaquita",
2727
"Alpine",
28+
"BellSoft Hardened Containers",
2829
"Bioconductor",
2930
"Bitnami",
3031
"Chainguard",

0 commit comments

Comments
 (0)