mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* Improve CycloneDX format output ## Additions to CycloneDX output * CPEs * Authors * Publishers * External References (Website, Distribution, VCS) * Description Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
33 lines
633 B
Go
33 lines
633 B
Go
package cyclonedxhelpers
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func Author(p pkg.Package) string {
|
|
if hasMetadata(p) {
|
|
switch metadata := p.Metadata.(type) {
|
|
case pkg.NpmPackageJSONMetadata:
|
|
return metadata.Author
|
|
case pkg.PythonPackageMetadata:
|
|
author := metadata.Author
|
|
if metadata.AuthorEmail != "" {
|
|
if author == "" {
|
|
return metadata.AuthorEmail
|
|
}
|
|
author += fmt.Sprintf(" <%s>", metadata.AuthorEmail)
|
|
}
|
|
return author
|
|
case pkg.GemMetadata:
|
|
if len(metadata.Authors) > 0 {
|
|
return strings.Join(metadata.Authors, ",")
|
|
}
|
|
return ""
|
|
}
|
|
}
|
|
return ""
|
|
}
|