github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/common/spdxhelpers/source_info.go (about) 1 package spdxhelpers 2 3 import ( 4 "strings" 5 6 "github.com/nextlinux/gosbom/gosbom/pkg" 7 ) 8 9 //nolint:funlen 10 func SourceInfo(p pkg.Package) string { 11 answer := "" 12 switch p.Type { 13 case pkg.AlpmPkg: 14 answer = "acquired package info from ALPM DB" 15 case pkg.RpmPkg: 16 answer = "acquired package info from RPM DB" 17 case pkg.ApkPkg: 18 answer = "acquired package info from APK DB" 19 case pkg.DartPubPkg: 20 answer = "acquired package info from pubspec manifest" 21 case pkg.DebPkg: 22 answer = "acquired package info from DPKG DB" 23 case pkg.DotnetPkg: 24 answer = "acquired package info from dotnet project assets file" 25 case pkg.NpmPkg: 26 answer = "acquired package info from installed node module manifest file" 27 case pkg.PythonPkg: 28 answer = "acquired package info from installed python package manifest file" 29 case pkg.JavaPkg, pkg.JenkinsPluginPkg: 30 answer = "acquired package info from installed java archive" 31 case pkg.GemPkg: 32 answer = "acquired package info from installed gem metadata file" 33 case pkg.GoModulePkg: 34 answer = "acquired package info from go module information" 35 case pkg.RustPkg: 36 answer = "acquired package info from rust cargo manifest" 37 case pkg.PhpComposerPkg: 38 answer = "acquired package info from PHP composer manifest" 39 case pkg.CocoapodsPkg: 40 answer = "acquired package info from installed cocoapods manifest file" 41 case pkg.ConanPkg: 42 answer = "acquired package info from conan manifest" 43 case pkg.PortagePkg: 44 answer = "acquired package info from portage DB" 45 case pkg.HackagePkg: 46 answer = "acquired package info from cabal or stack manifest files" 47 case pkg.HexPkg: 48 answer = "acquired package info from rebar3 or mix manifest file" 49 case pkg.LinuxKernelPkg: 50 answer = "acquired package info from linux kernel archive" 51 case pkg.LinuxKernelModulePkg: 52 answer = "acquired package info from linux kernel module files" 53 case pkg.NixPkg: 54 answer = "acquired package info from nix store path" 55 case pkg.Rpkg: 56 answer = "acquired package info from R-package DESCRIPTION file" 57 default: 58 answer = "acquired package info from the following paths" 59 } 60 if p.FoundBy == "sbom-cataloger" { 61 answer = "acquired package info from SBOM" 62 } 63 var paths []string 64 for _, l := range p.Locations.ToSlice() { 65 paths = append(paths, l.RealPath) 66 } 67 68 return answer + ": " + strings.Join(paths, ", ") 69 }