mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 15:37:50 -08:00
refactor: rename scanner to service (#8584)
This commit is contained in:
29
pkg/scan/utils/utils.go
Normal file
29
pkg/scan/utils/utils.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aquasecurity/trivy/pkg/fanal/types"
|
||||
)
|
||||
|
||||
// FormatVersion formats the package version based on epoch, version & release
|
||||
func FormatVersion(pkg types.Package) string {
|
||||
return formatVersion(pkg.Epoch, pkg.Version, pkg.Release)
|
||||
}
|
||||
|
||||
// FormatSrcVersion formats the package version based on source epoch, version & release
|
||||
func FormatSrcVersion(pkg types.Package) string {
|
||||
return formatVersion(pkg.SrcEpoch, pkg.SrcVersion, pkg.SrcRelease)
|
||||
}
|
||||
|
||||
func formatVersion(epoch int, version, release string) string {
|
||||
v := version
|
||||
if release != "" {
|
||||
v = fmt.Sprintf("%s-%s", v, release)
|
||||
}
|
||||
if epoch != 0 {
|
||||
v = fmt.Sprintf("%d:%s", epoch, v)
|
||||
}
|
||||
return v
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user