Skip to content

Commit

Permalink
fix(amazon): check only major version of AL to find advisories (#6295)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Mar 11, 2024
1 parent 96bd7ac commit fb8c516
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/detector/ospkg/amazon/amazon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detector/ospkg/amazon/amazon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fb8c516

Please sign in to comment.