Skip to content

Commit

Permalink
refactor: SUSE - update OSType constants and references for compatibi…
Browse files Browse the repository at this point in the history
…lity

1. Renamed deprecated OSType constants to maintain backward compatibility.
2. Modified all occurrences where the old constants were used to ensure consistency

(cherry picked from commit 3d21d19)
  • Loading branch information
santhosh1729 committed Jan 7, 2025
1 parent cd01f23 commit 2aca44f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/fanal/types/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ func (o *OS) Detected() bool {
return o.Family != ""
}

// Normalize normalizes OS family names for backward compatibility
func (o *OS) Normalize() {
if alias, ok := OSTypeAliases[o.Family]; ok {
o.Family = alias
}
}

// Merge merges OS version and enhanced security maintenance programs
func (o *OS) Merge(newOS OS) {
if lo.IsEmpty(newOS) {
Expand All @@ -45,6 +52,7 @@ func (o *OS) Merge(newOS OS) {
o.Extended = true
}
}
o.Normalize()
}

type Repository struct {
Expand Down
9 changes: 9 additions & 0 deletions pkg/fanal/types/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ const (
Wolfi OSType = "wolfi"
)

// OSTypeAliases is a map of aliases for operating systems.
// This is used to map the old family names to the new ones for backward compatibility.
var OSTypeAliases = map[OSType]OSType{
"opensuse.leap": OpenSUSELeap,
"opensuse.tumbleweed": OpenSUSETumbleweed,
"suse linux enterprise micro": SLEMicro,
"suse linux enterprise server": SLES,
}

// Programming language dependencies
const (
Bundler LangType = "bundler"
Expand Down

0 comments on commit 2aca44f

Please sign in to comment.