From ce77f2d2444b84a1e55d10b25878d781e765d41f Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Fri, 14 Feb 2025 00:20:00 -0600 Subject: [PATCH] agent: Add more distributions Chainguard and Wolfi This is for improved support of: - https://gallery.ecr.aws/chainguard/ - https://aws.amazon.com/marketplace/seller-profile?id=45c2a1e6-2f03-4b9f-80ad-6591bdb6fd4d Signed-off-by: Dimitri John Ledkov --- .../configurepackage/envdetect/constants/constants.go | 6 ++++++ .../configurepackage/envdetect/osdetect/osdetect_unix.go | 6 +++++- .../envdetect/osdetect/osdetect_unix_test.go | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/agent/plugins/configurepackage/envdetect/constants/constants.go b/agent/plugins/configurepackage/envdetect/constants/constants.go index 76364ca0d8..2f73406e61 100644 --- a/agent/plugins/configurepackage/envdetect/constants/constants.go +++ b/agent/plugins/configurepackage/envdetect/constants/constants.go @@ -67,6 +67,12 @@ const PlatformBottlerocket = "bottlerocket" // PlatformAlpine uses Ohai identifier for alpine platform const PlatformAlpine = "alpine" +// PlatformChainguard uses Ohai identifier for chainguard platform +const PlatformChainguard = "chainguard" + +// PlatformWolfi uses Ohai identifier for wolfi platform +const PlatformWolfi = "wolfi" + // PlatformSuse uses Ohai identifier for suse platform const PlatformSuse = "suse" diff --git a/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix.go b/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix.go index 6dcf5a9feb..53454f5c38 100644 --- a/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix.go +++ b/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix.go @@ -187,6 +187,10 @@ func parseOSreleaseFile(lines []string) (string, string, error) { if strings.Contains(strings.ToLower(name), "leap") { platform = c.PlatformOpensuseLeap } + case "chainguard": + platform = c.PlatformChainguard + case "wolfi": + platform = c.PlatformWolfi } return platform, platformVersion, nil @@ -412,7 +416,7 @@ func platformFamilyForPlatform(platform string) (string, error) { return c.PlatformFamilyRhel, nil case c.PlatformFedora: return c.PlatformFamilyFedora, nil - case c.PlatformAlpine: + case c.PlatformAlpine, c.PlatformChainguard, c.PlatformWolfi: return c.PlatformFamilyAlpine, nil case c.PlatformSuse, c.PlatformOpensuse, c.PlatformOpensuseLeap: return c.PlatformFamilySuse, nil diff --git a/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix_test.go b/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix_test.go index 8ef8e603c4..3be03813c7 100644 --- a/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix_test.go +++ b/agent/plugins/configurepackage/envdetect/osdetect/osdetect_unix_test.go @@ -169,6 +169,14 @@ func TestParseOSreleaseFile(t *testing.T) { []string{`NAME="Alpine Linux"`, `ID=alpine`, `VERSION_ID=3.5.0`, `PRETTY_NAME="Alpine Linux v3.5"`, `HOME_URL="http://alpinelinux.org"`, `BUG_REPORT_URL="http://bugs.alpinelinux.org"`}, "alpine", "3.5.0", false, }, + { + []string{`NAME="Chainguard"`, `ID=chainguard`, `VERSION_ID=20230214`, `PRETTY_NAME="Chainguard"`, `HOME_URL="https://chainguard.dev"`}, + "chainguard", "20230214", false, + }, + { + []string{`NAME="Wolfi"`, `ID=wolfi`, `VERSION_ID=20230201`, `PRETTY_NAME="Wolfi"`, `HOME_URL="https://wolfi.dev"`, `BUG_REPORT_URL="https://github.com/wolfi-dev/os/issues"`}, + "wolfi", "20230201", false, + }, { []string{`NAME="CentOS Linux"`, `VERSION="7 (Core)"`, `ID="centos"`, `ID_LIKE="rhel fedora"`, `VERSION_ID="7"`, `PRETTY_NAME="CentOS Linux 7 (Core)"`, `ANSI_COLOR="0;31"`, `CPE_NAME="cpe:/o:centos:centos:7"`, `HOME_URL="https://www.centos.org/"`, `BUG_REPORT_URL="https://bugs.centos.org/"`, `CENTOS_MANTISBT_PROJECT="CentOS-7"`, `CENTOS_MANTISBT_PROJECT_VERSION="7"`, `REDHAT_SUPPORT_PRODUCT="centos"`, `REDHAT_SUPPORT_PRODUCT_VERSION="7"`}, "centos", "7", false,