github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/common/spdxhelpers/origintor.go (about) 1 package spdxhelpers 2 3 import ( 4 "fmt" 5 6 "github.com/nextlinux/gosbom/gosbom/pkg" 7 ) 8 9 // Originator needs to conform to the SPDX spec here: 10 // https://spdx.github.io/spdx-spec/package-information/#76-package-originator-field 11 // Available options are: <omit>, NOASSERTION, Person: <person>, Organization: <org> 12 // return values are: <type>, <value> 13 func Originator(p pkg.Package) (string, string) { 14 typ := "" 15 author := "" 16 if hasMetadata(p) { 17 switch metadata := p.Metadata.(type) { 18 case pkg.ApkMetadata: 19 author = metadata.Maintainer 20 case pkg.NpmPackageJSONMetadata: 21 author = metadata.Author 22 case pkg.PythonPackageMetadata: 23 author = metadata.Author 24 if author == "" { 25 author = metadata.AuthorEmail 26 } else if metadata.AuthorEmail != "" { 27 author = fmt.Sprintf("%s (%s)", author, metadata.AuthorEmail) 28 } 29 case pkg.GemMetadata: 30 if len(metadata.Authors) > 0 { 31 author = metadata.Authors[0] 32 } 33 case pkg.RpmMetadata: 34 typ = "Organization" 35 author = metadata.Vendor 36 case pkg.DpkgMetadata: 37 author = metadata.Maintainer 38 } 39 if typ == "" && author != "" { 40 typ = "Person" 41 } 42 } 43 return typ, author 44 }