diff --git a/pkg/detector/ospkg/amazon/amazon.go b/pkg/detector/ospkg/amazon/amazon.go index 0846e24c3dcb..0c5a35f13a8f 100644 --- a/pkg/detector/ospkg/amazon/amazon.go +++ b/pkg/detector/ospkg/amazon/amazon.go @@ -44,6 +44,8 @@ func (s *Scanner) Detect(osVer string, _ *ftypes.Repository, pkgs []ftypes.Packa log.Logger.Info("Detecting Amazon Linux vulnerabilities...") osVer = strings.Fields(osVer)[0] + // The format `2023.xxx.xxxx` can be used. + osVer = osver.Major(osVer) if osVer != "2" && osVer != "2022" && osVer != "2023" { osVer = "1" } @@ -97,6 +99,8 @@ func (s *Scanner) Detect(osVer string, _ *ftypes.Repository, pkgs []ftypes.Packa // IsSupportedVersion checks if the version is supported. func (s *Scanner) IsSupportedVersion(ctx context.Context, osFamily ftypes.OSType, osVer string) bool { osVer = strings.Fields(osVer)[0] + // The format `2023.xxx.xxxx` can be used. + osVer = osver.Major(osVer) if osVer != "2" && osVer != "2022" && osVer != "2023" { osVer = "1" } diff --git a/pkg/detector/ospkg/amazon/amazon_test.go b/pkg/detector/ospkg/amazon/amazon_test.go index 1fa65f0598fb..c9c5a3c65840 100644 --- a/pkg/detector/ospkg/amazon/amazon_test.go +++ b/pkg/detector/ospkg/amazon/amazon_test.go @@ -108,7 +108,7 @@ func TestScanner_Detect(t *testing.T) { "testdata/fixtures/data-source.yaml", }, args: args{ - osVer: "2023", + osVer: "2023.3.20240304", pkgs: []ftypes.Package{ { Name: "protobuf",