Skip to content

Commit 174e0a0

Browse files
feat: support scientific linux (#3175)
Adds support for Scientific Linux as an alias to the RHEL vulnerability data. Signed-off-by: Weston Steimel <author@code.w.steimel.me.uk>
1 parent 112f9bf commit 174e0a0

7 files changed

Lines changed: 47 additions & 4 deletions

File tree

grype/db/v6/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ func KnownOperatingSystemSpecifierOverrides() []OperatingSystemSpecifierOverride
1818
{Alias: "rockylinux", ReplacementName: strRef("rhel")}, // non-standard, but common (dockerhub uses "rockylinux")
1919
{Alias: "alma", ReplacementName: strRef("rhel")},
2020
{Alias: "almalinux", ReplacementName: strRef("rhel")}, // non-standard, but common (dockerhub uses "almalinux")
21+
{Alias: "scientific", ReplacementName: strRef("rhel")},
22+
{Alias: "sl", ReplacementName: strRef("rhel")}, // non-standard, but common (dockerhub uses "sl")
2123
{Alias: "gentoo", ReplacementName: strRef("rhel")},
2224

2325
// Alternaitve distros that should match against the debian vulnerability data

grype/distro/distro_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
370370
},
371371
{
372372
Name: "test-fixtures/os/custom",
373-
Type: RedHat,
373+
Type: Scientific,
374374
Version: "8",
375375
},
376376
{
@@ -461,6 +461,16 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
461461
Type: Raspbian,
462462
Version: "9",
463463
},
464+
{
465+
Name: "test-fixtures/os/scientific",
466+
Type: Scientific,
467+
Version: "7.5",
468+
},
469+
{
470+
Name: "test-fixtures/os/scientific6",
471+
Type: Scientific,
472+
Version: "6.10",
473+
},
464474
}
465475

466476
for _, tt := range tests {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
NAME="Scientific Linux"
2+
VERSION="7.5 (Nitrogen)"
3+
ID="scientific"
4+
ID_LIKE="rhel centos fedora"
5+
VERSION_ID="7.5"
6+
PRETTY_NAME="Scientific Linux 7.5 (Nitrogen)"
7+
ANSI_COLOR="0;31"
8+
CPE_NAME="cpe:/o:scientificlinux:scientificlinux:7.5:GA"
9+
HOME_URL="http://www.scientificlinux.org//"
10+
BUG_REPORT_URL="mailto:scientific-linux-devel@listserv.fnal.gov"
11+
12+
REDHAT_BUGZILLA_PRODUCT="Scientific Linux 7"
13+
REDHAT_BUGZILLA_PRODUCT_VERSION=7.5
14+
REDHAT_SUPPORT_PRODUCT="Scientific Linux"
15+
REDHAT_SUPPORT_PRODUCT_VERSION="7.5"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Scientific Linux release 6.10 (Carbon)

grype/distro/type.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
Chainguard Type = "chainguard"
3535
MinimOS Type = "minimos"
3636
Raspbian Type = "raspbian"
37+
Scientific Type = "scientific"
3738
)
3839

3940
// All contains all Linux distribution options
@@ -62,6 +63,7 @@ var All = []Type{
6263
Chainguard,
6364
MinimOS,
6465
Raspbian,
66+
Scientific,
6567
}
6668

6769
// IDMapping maps a distro ID from the /etc/os-release (e.g. like "ubuntu") to a Distro type.
@@ -89,12 +91,14 @@ var IDMapping = map[string]Type{
8991
"chainguard": Chainguard,
9092
"minimos": MinimOS,
9193
"raspbian": Raspbian,
94+
"scientific": Scientific,
9295
}
9396

9497
// aliasTypes maps common aliases to their corresponding Type.
9598
var aliasTypes = map[string]Type{
96-
"Alpine Linux": Alpine, // needed for CPE matching (see #2039)
97-
"windows": Windows,
99+
"Alpine Linux": Alpine, // needed for CPE matching (see #2039)
100+
"windows": Windows,
101+
"scientific linux": Scientific, // Scientific linux prior to v7 didn't have an os-release file and syft raises up "scientific linux" as the release id as parsed from /etc/redhat-release
98102
}
99103

100104
var typeToIDMapping = map[Type]string{}

grype/distro/type_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ func TestTypeFromRelease(t *testing.T) {
116116
},
117117
want: Alpine,
118118
},
119+
{
120+
name: "Scientific Linux 6",
121+
release: linux.Release{
122+
Name: "Scientific Linux",
123+
ID: "scientific linux",
124+
IDLike: []string{"scientific linux"},
125+
Version: "6.10 Carbon",
126+
VersionID: "6.10",
127+
},
128+
want: Scientific,
129+
},
119130
}
120131

121132
for _, tt := range tests {

0 commit comments

Comments
 (0)