forked from aquasecurity/fanal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suse linux enterprise server support (aquasecurity#55)
* Add suse linux enterprise server * Fix comment * Add openSUSE Tumbleweed support
- Loading branch information
Showing
13 changed files
with
153 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package suse | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"golang.org/x/xerrors" | ||
|
||
"github.com/aquasecurity/fanal/analyzer" | ||
"github.com/aquasecurity/fanal/analyzer/os" | ||
) | ||
|
||
func TestAnalyze(t *testing.T) { | ||
var tests = map[string]struct { | ||
path string | ||
os analyzer.OS | ||
wantErr error | ||
}{ | ||
"OpenSUSELeap15.0": { | ||
path: "./testdata/opensuse_leap_150", | ||
os: analyzer.OS{Family: os.OpenSUSELeap, Name: "15.0"}, | ||
}, | ||
"OpenSUSELeap15.1": { | ||
path: "./testdata/opensuse_leap_151", | ||
os: analyzer.OS{Family: os.OpenSUSELeap, Name: "15.1"}, | ||
}, | ||
"OpenSUSELeap42.3": { | ||
path: "./testdata/opensuse_leap_423", | ||
os: analyzer.OS{Family: os.OpenSUSELeap, Name: "42.3"}, | ||
}, | ||
"SLES12": { | ||
path: "./testdata/sles_12", | ||
os: analyzer.OS{Family: os.SLES, Name: "12"}, | ||
}, | ||
"SLES15": { | ||
path: "./testdata/sles_15", | ||
os: analyzer.OS{Family: os.SLES, Name: "15"}, | ||
}, | ||
"SLES15.1": { | ||
path: "./testdata/sles_151", | ||
os: analyzer.OS{Family: os.SLES, Name: "15.1"}, | ||
}, | ||
"openSUSE Tumbleweed": { | ||
path: "./testdata/opensuse_leap_tumbleweed", | ||
os: analyzer.OS{Family: os.OpenSUSETumbleweed, Name: "20191204"}, | ||
}, | ||
"Invalid": { | ||
path: "./testdata/not_suse", | ||
wantErr: os.AnalyzeOSError, | ||
}, | ||
} | ||
a := suseOSAnalyzer{} | ||
for testname, v := range tests { | ||
fileMap, err := os.GetFileMap(v.path) | ||
if err != nil { | ||
t.Errorf("%s : catch the error : %v", testname, err) | ||
} | ||
osInfo, err := a.Analyze(fileMap) | ||
if v.wantErr != nil { | ||
if err == nil { | ||
t.Errorf("%s : expected error but no error", testname) | ||
} | ||
if !xerrors.Is(err, v.wantErr) { | ||
t.Errorf("[%s]\nexpected : %v\nactual : %v", testname, v.wantErr, err) | ||
} | ||
} | ||
if !reflect.DeepEqual(v.os, osInfo) { | ||
t.Errorf("[%s]\nexpected : %v\nactual : %v", testname, v.os, osInfo) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Red Hat Linux release 6.2 (Zoot) |
10 changes: 10 additions & 0 deletions
10
analyzer/os/suse/testdata/opensuse_leap_150/etc/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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/" |
10 changes: 10 additions & 0 deletions
10
analyzer/os/suse/testdata/opensuse_leap_151/etc/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
NAME="openSUSE Leap" | ||
VERSION="15.1" | ||
ID="opensuse-leap" | ||
ID_LIKE="suse opensuse" | ||
VERSION_ID="15.1" | ||
PRETTY_NAME="openSUSE Leap 15.1" | ||
ANSI_COLOR="0;32" | ||
CPE_NAME="cpe:/o:opensuse:leap:15.1" | ||
BUG_REPORT_URL="https://bugs.opensuse.org" | ||
HOME_URL="https://www.opensuse.org/" |
10 changes: 10 additions & 0 deletions
10
analyzer/os/suse/testdata/opensuse_leap_423/etc/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
NAME="openSUSE Leap" | ||
VERSION="42.3" | ||
ID="opensuse-leap" | ||
ID_LIKE="suse opensuse" | ||
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/" |
11 changes: 11 additions & 0 deletions
11
analyzer/os/suse/testdata/opensuse_leap_tumbleweed/etc/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
NAME="openSUSE Tumbleweed" | ||
# VERSION="20191204" | ||
ID="opensuse-tumbleweed" | ||
ID_LIKE="opensuse suse" | ||
VERSION_ID="20191204" | ||
PRETTY_NAME="openSUSE Tumbleweed" | ||
ANSI_COLOR="0;32" | ||
CPE_NAME="cpe:/o:opensuse:tumbleweed:20191204" | ||
BUG_REPORT_URL="https://bugs.opensuse.org" | ||
HOME_URL="https://www.opensuse.org/" | ||
LOGO="distributor-logo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
NAME="SLES" | ||
VERSION="12" | ||
VERSION_ID="12" | ||
PRETTY_NAME="SUSE Linux Enterprise Server 12" | ||
ID="sles" | ||
ID_LIKE="suse" | ||
ANSI_COLOR="0;32" | ||
CPE_NAME="cpe:/o:suse:sles:12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
NAME="SLES" | ||
VERSION="15" | ||
VERSION_ID="15" | ||
PRETTY_NAME="SUSE Linux Enterprise Server 15" | ||
ID="sles" | ||
ID_LIKE="suse" | ||
ANSI_COLOR="0;32" | ||
CPE_NAME="cpe:/o:suse:sles:15" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters