refactor: rename scanner to service (#8584)

This commit is contained in:
Teppei Fukuda
2025-03-24 03:47:03 +04:00
committed by GitHub
parent de7eb13938
commit c80310d769
46 changed files with 357 additions and 343 deletions

29
pkg/scan/utils/utils.go Normal file
View 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
}