Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/vulnerability/detection/os.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The unfixed/unfixable vulnerabilities mean that the patch has not yet been provi
| Rocky Linux | 8, 9 | Installed by yum/rpm | NO |
| Oracle Linux | 5, 6, 7, 8 | Installed by yum/rpm | NO |
| CBL-Mariner | 1.0, 2.0 | Installed by yum/rpm | YES |
| Amazon Linux | 1, 2, 2022 | Installed by yum/rpm | NO |
| Amazon Linux | 1, 2, 2022, 2023 | Installed by yum/rpm | NO |
| openSUSE Leap | 42, 15 | Installed by zypper/rpm | NO |
| SUSE Enterprise Linux | 11, 12, 15 | Installed by zypper/rpm | NO |
| Photon OS | 1.0, 2.0, 3.0, 4.0 | Installed by tdnf/yum/rpm | NO |
Expand Down
3 changes: 2 additions & 1 deletion pkg/detector/ospkg/amazon/amazon.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
"2": time.Date(2024, 6, 30, 23, 59, 59, 0, time.UTC),
// N/A
"2022": time.Date(3000, 1, 1, 23, 59, 59, 0, time.UTC),
"2023": time.Date(2028, 3, 15, 23, 59, 59, 0, time.UTC),
}
)

Expand Down Expand Up @@ -66,7 +67,7 @@ func (s *Scanner) Detect(osVer string, _ *ftypes.Repository, pkgs []ftypes.Packa
log.Logger.Info("Detecting Amazon Linux vulnerabilities...")

osVer = strings.Fields(osVer)[0]
if osVer != "2" && osVer != "2022" {
if osVer != "2" && osVer != "2022" && osVer != "2023" {
osVer = "1"
}
log.Logger.Debugf("amazon: os version: %s", osVer)
Expand Down
32 changes: 32 additions & 0 deletions pkg/detector/ospkg/amazon/amazon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ func TestScanner_Detect(t *testing.T) {
},
},
},
{
name: "amazon linux 2023",
fixtures: []string{"testdata/fixtures/amazon.yaml", "testdata/fixtures/data-source.yaml"},
args: args{
osVer: "2023",
pkgs: []ftypes.Package{
{
Name: "protobuf",
Version: "3.14.0-7.amzn2023.0.3",
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
},
},
},
want: []types.DetectedVulnerability{
{
PkgName: "protobuf",
VulnerabilityID: "CVE-2022-1941",
InstalledVersion: "3.14.0-7.amzn2023.0.3",
FixedVersion: "3.19.6-1.amzn2023.0.1",
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
ID: vulnerability.Amazon,
Name: "Amazon Linux Security Center",
URL: "https://alas.aws.amazon.com/",
},
},
},
},
{
name: "empty version",
fixtures: []string{"testdata/fixtures/amazon.yaml", "testdata/fixtures/data-source.yaml"},
Expand Down
7 changes: 7 additions & 0 deletions pkg/detector/ospkg/amazon/testdata/fixtures/amazon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@
- key: CVE-2021-44228
value:
FixedVersion: "2.15.0-1.amzn2022.0.1"
- bucket: amazon linux 2023
pairs:
- bucket: protobuf
pairs:
- key: CVE-2022-1941
value:
FixedVersion: "3.19.6-1.amzn2023.0.1"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
Name: "Amazon Linux Security Center"
URL: "https://alas.aws.amazon.com/"
- key: amazon linux 2022
value:
ID: "amazon"
Name: "Amazon Linux Security Center"
URL: "https://alas.aws.amazon.com/"
- key: amazon linux 2023
value:
ID: "amazon"
Name: "Amazon Linux Security Center"
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/os/amazonlinux/amazonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const version = 1

var requiredFiles = []string{
"etc/system-release", // for 1 and 2 versions
"usr/lib/system-release", // for 2022 version
"usr/lib/system-release", // for 2022, 2023 version
}

type amazonlinuxOSAnalyzer struct{}
Expand Down
13 changes: 13 additions & 0 deletions pkg/fanal/analyzer/os/amazonlinux/amazonlinux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ func Test_amazonlinuxOSAnalyzer_Analyze(t *testing.T) {
},
},
},
{
name: "happy path amazon linux 2023",
input: analyzer.AnalysisInput{
FilePath: "usr/lib/system-release",
Content: strings.NewReader(`Amazon Linux release 2023 (Amazon Linux)`),
},
want: &analyzer.AnalysisResult{
OS: types.OS{
Family: aos.Amazon,
Name: "2023 (Amazon Linux)",
},
},
},
{
name: "sad path amazon linux 2 without code name",
input: analyzer.AnalysisInput{
Expand Down