From 571bfcdb22f4a903a6179f2a4d31aa94f2f12ec9 Mon Sep 17 00:00:00 2001 From: Teppei Fukuda Date: Tue, 3 May 2022 19:06:02 +0300 Subject: [PATCH] feat(analyzer): more general support for os-release (#470) Co-authored-by: DmitriyLewen --- analyzer/all/import.go | 3 +- analyzer/const.go | 1 + analyzer/os/photon/photon.go | 65 ---------- analyzer/os/photon/photon_test.go | 61 ---------- .../os/photon/testdata/not_photon/os-release | 1 - analyzer/os/release/release.go | 84 +++++++++++++ analyzer/os/release/release_test.go | 112 ++++++++++++++++++ analyzer/os/release/testdata/alpine | 6 + analyzer/os/release/testdata/no-id | 5 + analyzer/os/release/testdata/no-version | 5 + .../os/release/testdata/opensuseleap-15.2.1 | 10 ++ .../os/release/testdata/opensuseleap-42.3 | 10 ++ .../testdata/opensusetumbleweed} | 9 +- .../os-release => release/testdata/photon} | 6 +- analyzer/os/release/testdata/sles | 9 ++ analyzer/os/release/testdata/unknown | 2 + analyzer/os/suse/suse.go | 72 ----------- analyzer/os/suse/suse_test.go | 72 ----------- analyzer/os/suse/testdata/not_suse/os-release | 1 - .../testdata/opensuse_leap_150/os-release | 10 -- analyzer/os/suse/testdata/sles_151/os-release | 8 -- 21 files changed, 253 insertions(+), 299 deletions(-) delete mode 100644 analyzer/os/photon/photon.go delete mode 100644 analyzer/os/photon/photon_test.go delete mode 100644 analyzer/os/photon/testdata/not_photon/os-release create mode 100644 analyzer/os/release/release.go create mode 100644 analyzer/os/release/release_test.go create mode 100644 analyzer/os/release/testdata/alpine create mode 100644 analyzer/os/release/testdata/no-id create mode 100644 analyzer/os/release/testdata/no-version create mode 100644 analyzer/os/release/testdata/opensuseleap-15.2.1 create mode 100644 analyzer/os/release/testdata/opensuseleap-42.3 rename analyzer/os/{suse/testdata/opensuse_leap_tumbleweed/os-release => release/testdata/opensusetumbleweed} (52%) rename analyzer/os/{photon/testdata/photon_3/os-release => release/testdata/photon} (60%) create mode 100644 analyzer/os/release/testdata/sles create mode 100644 analyzer/os/release/testdata/unknown delete mode 100644 analyzer/os/suse/suse.go delete mode 100644 analyzer/os/suse/suse_test.go delete mode 100644 analyzer/os/suse/testdata/not_suse/os-release delete mode 100644 analyzer/os/suse/testdata/opensuse_leap_150/os-release delete mode 100644 analyzer/os/suse/testdata/sles_151/os-release diff --git a/analyzer/all/import.go b/analyzer/all/import.go index 9413926eaaa4..14ec251abd44 100644 --- a/analyzer/all/import.go +++ b/analyzer/all/import.go @@ -23,9 +23,8 @@ import ( _ "github.com/aquasecurity/fanal/analyzer/os/amazonlinux" _ "github.com/aquasecurity/fanal/analyzer/os/debian" _ "github.com/aquasecurity/fanal/analyzer/os/mariner" - _ "github.com/aquasecurity/fanal/analyzer/os/photon" _ "github.com/aquasecurity/fanal/analyzer/os/redhatbase" - _ "github.com/aquasecurity/fanal/analyzer/os/suse" + _ "github.com/aquasecurity/fanal/analyzer/os/release" _ "github.com/aquasecurity/fanal/analyzer/os/ubuntu" _ "github.com/aquasecurity/fanal/analyzer/pkg/apk" _ "github.com/aquasecurity/fanal/analyzer/pkg/dpkg" diff --git a/analyzer/const.go b/analyzer/const.go index dfe9eb3b4759..2d0ae6b228ac 100644 --- a/analyzer/const.go +++ b/analyzer/const.go @@ -6,6 +6,7 @@ const ( // ====== // OS // ====== + TypeOSRelease Type = "os-release" TypeAlpine Type = "alpine" TypeAmazon Type = "amazon" TypeCBLMariner Type = "cbl-mariner" diff --git a/analyzer/os/photon/photon.go b/analyzer/os/photon/photon.go deleted file mode 100644 index 10eb32854749..000000000000 --- a/analyzer/os/photon/photon.go +++ /dev/null @@ -1,65 +0,0 @@ -package photon - -import ( - "bufio" - "context" - "os" - "strings" - - "github.com/aquasecurity/fanal/utils" - - "github.com/aquasecurity/fanal/types" - - "golang.org/x/xerrors" - - aos "github.com/aquasecurity/fanal/analyzer/os" - - "github.com/aquasecurity/fanal/analyzer" -) - -func init() { - analyzer.RegisterAnalyzer(&photonOSAnalyzer{}) -} - -const version = 1 - -var requiredFiles = []string{ - "usr/lib/os-release", - "etc/os-release", -} - -type photonOSAnalyzer struct{} - -func (a photonOSAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) { - photonName := "" - scanner := bufio.NewScanner(input.Content) - for scanner.Scan() { - line := scanner.Text() - if strings.HasPrefix(line, "NAME=\"VMware Photon") { - photonName = aos.Photon - continue - } - - if photonName != "" && strings.HasPrefix(line, "VERSION_ID=") { - return &analyzer.AnalysisResult{ - OS: &types.OS{ - Family: photonName, - Name: strings.TrimSpace(line[11:]), - }, - }, nil - } - } - return nil, xerrors.Errorf("photon: %w", aos.AnalyzeOSError) -} - -func (a photonOSAnalyzer) Required(filePath string, _ os.FileInfo) bool { - return utils.StringInSlice(filePath, requiredFiles) -} - -func (a photonOSAnalyzer) Type() analyzer.Type { - return analyzer.TypePhoton -} - -func (a photonOSAnalyzer) Version() int { - return version -} diff --git a/analyzer/os/photon/photon_test.go b/analyzer/os/photon/photon_test.go deleted file mode 100644 index c20c89c5e16e..000000000000 --- a/analyzer/os/photon/photon_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package photon - -import ( - "context" - "os" - "testing" - - "github.com/aquasecurity/fanal/analyzer" - aos "github.com/aquasecurity/fanal/analyzer/os" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/aquasecurity/fanal/types" -) - -func Test_photonOSAnalyzer_Analyze(t *testing.T) { - tests := []struct { - name string - inputFile string - want *analyzer.AnalysisResult - wantErr string - }{ - { - name: "happy path with Photon OS 3.0", - inputFile: "testdata/photon_3/os-release", - want: &analyzer.AnalysisResult{ - OS: &types.OS{Family: aos.Photon, Name: "3.0"}, - }, - }, - { - name: "sad path", - inputFile: "testdata/not_photon/os-release", - want: &analyzer.AnalysisResult{ - OS: &types.OS{Family: aos.Photon, Name: "3.0"}, - }, - wantErr: "photon: unable to analyze OS information", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - a := photonOSAnalyzer{} - f, err := os.Open(tt.inputFile) - require.NoError(t, err) - defer f.Close() - - ctx := context.Background() - got, err := a.Analyze(ctx, analyzer.AnalysisInput{ - FilePath: "etc/os-release", - Content: f, - }) - if tt.wantErr != "" { - require.NotNil(t, err) - assert.Contains(t, err.Error(), tt.wantErr) - return - } else { - require.NoError(t, err) - } - assert.Equal(t, tt.want, got) - }) - } -} diff --git a/analyzer/os/photon/testdata/not_photon/os-release b/analyzer/os/photon/testdata/not_photon/os-release deleted file mode 100644 index 574c7bd1ede5..000000000000 --- a/analyzer/os/photon/testdata/not_photon/os-release +++ /dev/null @@ -1 +0,0 @@ -Red Hat Linux release 6.2 (Zoot) diff --git a/analyzer/os/release/release.go b/analyzer/os/release/release.go new file mode 100644 index 000000000000..7b1707d6cd30 --- /dev/null +++ b/analyzer/os/release/release.go @@ -0,0 +1,84 @@ +package release + +import ( + "bufio" + "context" + "os" + "strings" + + "golang.org/x/exp/slices" + + "github.com/aquasecurity/fanal/analyzer" + aos "github.com/aquasecurity/fanal/analyzer/os" + "github.com/aquasecurity/fanal/types" +) + +func init() { + analyzer.RegisterAnalyzer(&osReleaseAnalyzer{}) +} + +const version = 1 + +var requiredFiles = []string{ + "etc/os-release", + "usr/lib/os-release", +} + +type osReleaseAnalyzer struct{} + +func (a osReleaseAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) { + var id, versionID string + scanner := bufio.NewScanner(input.Content) + for scanner.Scan() { + line := scanner.Text() + + ss := strings.SplitN(line, "=", 2) + if len(ss) != 2 { + continue + } + key, value := strings.TrimSpace(ss[0]), strings.TrimSpace(ss[1]) + + switch key { + case "ID": + id = strings.Trim(value, `"'`) + case "VERSION_ID": + versionID = strings.Trim(value, `"'`) + default: + continue + } + + var family string + switch id { + case "alpine": + family = aos.Alpine + case "opensuse-tumbleweed": + family = aos.OpenSUSETumbleweed + case "opensuse-leap", "opensuse": // opensuse for leap:42, opensuse-leap for leap:15 + family = aos.OpenSUSELeap + case "sles": + family = aos.SLES + case "photon": + family = aos.Photon + } + + if family != "" && versionID != "" { + return &analyzer.AnalysisResult{ + OS: &types.OS{Family: family, Name: versionID}, + }, nil + } + } + + return nil, nil +} + +func (a osReleaseAnalyzer) Required(filePath string, _ os.FileInfo) bool { + return slices.Contains(requiredFiles, filePath) +} + +func (a osReleaseAnalyzer) Type() analyzer.Type { + return analyzer.TypeOSRelease +} + +func (a osReleaseAnalyzer) Version() int { + return version +} diff --git a/analyzer/os/release/release_test.go b/analyzer/os/release/release_test.go new file mode 100644 index 000000000000..b10295617e01 --- /dev/null +++ b/analyzer/os/release/release_test.go @@ -0,0 +1,112 @@ +package release + +import ( + "context" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/aquasecurity/fanal/analyzer" + aos "github.com/aquasecurity/fanal/analyzer/os" + "github.com/aquasecurity/fanal/types" +) + +func Test_osReleaseAnalyzer_Analyze(t *testing.T) { + tests := []struct { + name string + inputFile string + input analyzer.AnalysisInput + want *analyzer.AnalysisResult + wantErr string + }{ + { + name: "alpine", + inputFile: "testdata/alpine", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.Alpine, Name: "3.15.4"}, + }, + }, + { + name: "openSUSE-leap 15.2.1", + inputFile: "testdata/opensuseleap-15.2.1", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.OpenSUSELeap, Name: "15.2.1"}, + }, + }, + { + name: "openSUSE-leap 42.3", + inputFile: "testdata/opensuseleap-42.3", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.OpenSUSELeap, Name: "42.3"}, + }, + }, + { + name: "openSUSE-tumbleweed", + inputFile: "testdata/opensusetumbleweed", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.OpenSUSETumbleweed, Name: "20220412"}, + }, + }, + { + name: "SUSE Linux Enterprise Server", + inputFile: "testdata/sles", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.SLES, Name: "15.3"}, + }, + }, + { + name: "Photon OS", + inputFile: "testdata/photon", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.Photon, Name: "4.0"}, + }, + }, + { + name: "Photon OS", + inputFile: "testdata/photon", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.Photon, Name: "4.0"}, + }, + }, + { + name: "Unknown OS", + inputFile: "testdata/unknown", + want: nil, + }, + { + name: "No 'ID' field", + inputFile: "testdata/no-id", + want: nil, + }, + { + name: "No 'VERSION_ID' field", + inputFile: "testdata/no-version", + want: nil, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + f, err := os.Open(tt.inputFile) + require.NoError(t, err) + defer f.Close() + + a := osReleaseAnalyzer{} + res, err := a.Analyze(context.Background(), analyzer.AnalysisInput{ + FilePath: "etc/os-release", + Content: f, + }) + + if tt.wantErr != "" { + assert.Error(t, err) + assert.Equal(t, tt.wantErr, err.Error()) + return + } + + assert.NoError(t, err) + assert.Equal(t, tt.want, res) + }) + } +} diff --git a/analyzer/os/release/testdata/alpine b/analyzer/os/release/testdata/alpine new file mode 100644 index 000000000000..f53b6e704bb6 --- /dev/null +++ b/analyzer/os/release/testdata/alpine @@ -0,0 +1,6 @@ +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.15.4 +PRETTY_NAME="Alpine Linux v3.15" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://bugs.alpinelinux.org/" \ No newline at end of file diff --git a/analyzer/os/release/testdata/no-id b/analyzer/os/release/testdata/no-id new file mode 100644 index 000000000000..dc088d5994c9 --- /dev/null +++ b/analyzer/os/release/testdata/no-id @@ -0,0 +1,5 @@ +NAME="Alpine Linux" +VERSION_ID=3.15.4 +PRETTY_NAME="Alpine Linux v3.15" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://bugs.alpinelinux.org/" \ No newline at end of file diff --git a/analyzer/os/release/testdata/no-version b/analyzer/os/release/testdata/no-version new file mode 100644 index 000000000000..075d0208d18e --- /dev/null +++ b/analyzer/os/release/testdata/no-version @@ -0,0 +1,5 @@ +NAME="Alpine Linux" +ID=alpine +PRETTY_NAME="Alpine Linux v3.15" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://bugs.alpinelinux.org/" \ No newline at end of file diff --git a/analyzer/os/release/testdata/opensuseleap-15.2.1 b/analyzer/os/release/testdata/opensuseleap-15.2.1 new file mode 100644 index 000000000000..cc1ee6bcb755 --- /dev/null +++ b/analyzer/os/release/testdata/opensuseleap-15.2.1 @@ -0,0 +1,10 @@ +NAME="openSUSE Leap" +VERSION="15.2.1 Beta" +ID="opensuse-leap" +ID_LIKE="suse opensuse" +VERSION_ID="15.2.1" +PRETTY_NAME="openSUSE Leap 15.2.1 Beta" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:opensuse:leap:15.2.1" +BUG_REPORT_URL="https://bugs.opensuse.org" +HOME_URL="https://www.opensuse.org/" \ No newline at end of file diff --git a/analyzer/os/release/testdata/opensuseleap-42.3 b/analyzer/os/release/testdata/opensuseleap-42.3 new file mode 100644 index 000000000000..a449c2ce1415 --- /dev/null +++ b/analyzer/os/release/testdata/opensuseleap-42.3 @@ -0,0 +1,10 @@ +NAME="openSUSE Leap" +VERSION="42.3" +ID=opensuse +ID_LIKE="suse" +VERSION_ID="42.3" +PRETTY_NAME="openSUSE Leap 42.3" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:opensuse:leap:42.3" +BUG_REPORT_URL="https://bugs.opensuse.org" +HOME_URL="https://www.opensuse.org/" diff --git a/analyzer/os/suse/testdata/opensuse_leap_tumbleweed/os-release b/analyzer/os/release/testdata/opensusetumbleweed similarity index 52% rename from analyzer/os/suse/testdata/opensuse_leap_tumbleweed/os-release rename to analyzer/os/release/testdata/opensusetumbleweed index 7d3335c1e849..1929741767f0 100644 --- a/analyzer/os/suse/testdata/opensuse_leap_tumbleweed/os-release +++ b/analyzer/os/release/testdata/opensusetumbleweed @@ -1,11 +1,12 @@ NAME="openSUSE Tumbleweed" -# VERSION="20191204" +# VERSION="20220412" ID="opensuse-tumbleweed" ID_LIKE="opensuse suse" -VERSION_ID="20191204" +VERSION_ID="20220412" PRETTY_NAME="openSUSE Tumbleweed" ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:opensuse:tumbleweed:20191204" +CPE_NAME="cpe:/o:opensuse:tumbleweed:20220412" BUG_REPORT_URL="https://bugs.opensuse.org" HOME_URL="https://www.opensuse.org/" -LOGO="distributor-logo" +DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed" +LOGO="distributor-logo-Tumbleweed" \ No newline at end of file diff --git a/analyzer/os/photon/testdata/photon_3/os-release b/analyzer/os/release/testdata/photon similarity index 60% rename from analyzer/os/photon/testdata/photon_3/os-release rename to analyzer/os/release/testdata/photon index 01f4b9a2d7ed..abf0ba3fecea 100644 --- a/analyzer/os/photon/testdata/photon_3/os-release +++ b/analyzer/os/release/testdata/photon @@ -1,8 +1,8 @@ NAME="VMware Photon OS" -VERSION="3.0" +VERSION="4.0" ID=photon -VERSION_ID=3.0 +VERSION_ID=4.0 PRETTY_NAME="VMware Photon OS/Linux" ANSI_COLOR="1;34" HOME_URL="https://vmware.github.io/photon/" -BUG_REPORT_URL="https://github.com/vmware/photon/issues" +BUG_REPORT_URL="https://github.com/vmware/photon/issues" \ No newline at end of file diff --git a/analyzer/os/release/testdata/sles b/analyzer/os/release/testdata/sles new file mode 100644 index 000000000000..e41d21049bfa --- /dev/null +++ b/analyzer/os/release/testdata/sles @@ -0,0 +1,9 @@ +NAME="SLES" +VERSION="15-SP3" +VERSION_ID="15.3" +PRETTY_NAME="SUSE Linux Enterprise Server 15 SP3" +ID="sles" +ID_LIKE="suse" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:suse:sles:15:sp3" +DOCUMENTATION_URL="https://documentation.suse.com/" \ No newline at end of file diff --git a/analyzer/os/release/testdata/unknown b/analyzer/os/release/testdata/unknown new file mode 100644 index 000000000000..20658f0975a5 --- /dev/null +++ b/analyzer/os/release/testdata/unknown @@ -0,0 +1,2 @@ +ID=unknown +VERSION_ID=4.3.2 \ No newline at end of file diff --git a/analyzer/os/suse/suse.go b/analyzer/os/suse/suse.go deleted file mode 100644 index 7d43b28417bc..000000000000 --- a/analyzer/os/suse/suse.go +++ /dev/null @@ -1,72 +0,0 @@ -package suse - -import ( - "bufio" - "context" - "os" - "strings" - - "golang.org/x/xerrors" - - "github.com/aquasecurity/fanal/analyzer" - aos "github.com/aquasecurity/fanal/analyzer/os" - "github.com/aquasecurity/fanal/types" - "github.com/aquasecurity/fanal/utils" -) - -func init() { - analyzer.RegisterAnalyzer(&suseOSAnalyzer{}) -} - -const version = 1 - -var requiredFiles = []string{ - "usr/lib/os-release", - "etc/os-release", -} - -type suseOSAnalyzer struct{} - -func (a suseOSAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) { - suseName := "" - scanner := bufio.NewScanner(input.Content) - for scanner.Scan() { - line := scanner.Text() - if strings.HasPrefix(line, "NAME=\"openSUSE") { - if strings.Contains(line, "Leap") { - suseName = aos.OpenSUSELeap - } else if strings.Contains(line, "Tumbleweed") { - suseName = aos.OpenSUSETumbleweed - } else { - suseName = aos.OpenSUSE - } - continue - } - if strings.HasPrefix(line, "NAME=\"SLES") { - suseName = aos.SLES - continue - } - - if suseName != "" && strings.HasPrefix(line, "VERSION_ID=") { - return &analyzer.AnalysisResult{ - OS: &types.OS{ - Family: suseName, - Name: strings.TrimSpace(line[12 : len(line)-1]), - }, - }, nil - } - } - return nil, xerrors.Errorf("suse: %w", aos.AnalyzeOSError) -} - -func (a suseOSAnalyzer) Required(filePath string, _ os.FileInfo) bool { - return utils.StringInSlice(filePath, requiredFiles) -} - -func (a suseOSAnalyzer) Type() analyzer.Type { - return analyzer.TypeSUSE -} - -func (a suseOSAnalyzer) Version() int { - return version -} diff --git a/analyzer/os/suse/suse_test.go b/analyzer/os/suse/suse_test.go deleted file mode 100644 index dcc41f81ed90..000000000000 --- a/analyzer/os/suse/suse_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package suse - -import ( - "context" - "os" - "testing" - - "github.com/aquasecurity/fanal/analyzer" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - aos "github.com/aquasecurity/fanal/analyzer/os" - "github.com/aquasecurity/fanal/types" -) - -func Test_suseOSAnalyzer_Analyze(t *testing.T) { - tests := []struct { - name string - inputFile string - want *analyzer.AnalysisResult - wantErr string - }{ - { - name: "happy path with openSUSE Leap 15.0", - inputFile: "testdata/opensuse_leap_150/os-release", - want: &analyzer.AnalysisResult{ - OS: &types.OS{Family: aos.OpenSUSELeap, Name: "15.0"}, - }, - }, - { - name: "happy path with openSUSE Leap Tumbleweed", - inputFile: "testdata/opensuse_leap_tumbleweed/os-release", - want: &analyzer.AnalysisResult{ - OS: &types.OS{Family: aos.OpenSUSETumbleweed, Name: "20191204"}, - }, - }, - { - name: "happy path with SLES 15.1", - inputFile: "testdata/sles_151/os-release", - want: &analyzer.AnalysisResult{ - OS: &types.OS{Family: aos.SLES, Name: "15.1"}, - }, - }, - { - name: "sad path", - inputFile: "testdata/not_suse/os-release", - wantErr: "suse: unable to analyze OS information", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - a := suseOSAnalyzer{} - f, err := os.Open(tt.inputFile) - require.NoError(t, err) - defer f.Close() - - ctx := context.Background() - got, err := a.Analyze(ctx, analyzer.AnalysisInput{ - FilePath: "etc/lsb-release", - Content: f, - }) - if tt.wantErr != "" { - require.NotNil(t, err) - assert.Contains(t, err.Error(), tt.wantErr) - return - } else { - require.NoError(t, err) - } - assert.Equal(t, tt.want, got) - }) - } -} diff --git a/analyzer/os/suse/testdata/not_suse/os-release b/analyzer/os/suse/testdata/not_suse/os-release deleted file mode 100644 index 574c7bd1ede5..000000000000 --- a/analyzer/os/suse/testdata/not_suse/os-release +++ /dev/null @@ -1 +0,0 @@ -Red Hat Linux release 6.2 (Zoot) diff --git a/analyzer/os/suse/testdata/opensuse_leap_150/os-release b/analyzer/os/suse/testdata/opensuse_leap_150/os-release deleted file mode 100644 index a51941931feb..000000000000 --- a/analyzer/os/suse/testdata/opensuse_leap_150/os-release +++ /dev/null @@ -1,10 +0,0 @@ -NAME="openSUSE Leap" -VERSION="15.0" -ID="opensuse-leap" -ID_LIKE="suse opensuse" -VERSION_ID="15.0" -PRETTY_NAME="openSUSE Leap 15.0" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:opensuse:leap:15.0" -BUG_REPORT_URL="https://bugs.opensuse.org" -HOME_URL="https://www.opensuse.org/" diff --git a/analyzer/os/suse/testdata/sles_151/os-release b/analyzer/os/suse/testdata/sles_151/os-release deleted file mode 100644 index c9161574c137..000000000000 --- a/analyzer/os/suse/testdata/sles_151/os-release +++ /dev/null @@ -1,8 +0,0 @@ -NAME="SLES" -VERSION="15-SP1" -VERSION_ID="15.1" -PRETTY_NAME="SUSE Linux Enterprise Server 15 SP1" -ID="sles" -ID_LIKE="suse" -ANSI_COLOR="0;32" -CPE_NAME="cpe:/o:suse:sles:15:sp1"