@@ -15,74 +15,6 @@ import (
1515 "time"
1616)
1717
18- // SPDX Document structure
19- type SPDXDocument struct {
20- SPDXVersion string `json:"spdxVersion"`
21- DataLicense string `json:"dataLicense"`
22- SPDXID string `json:"SPDXID"`
23- Name string `json:"name"`
24- DocumentNamespace string `json:"documentNamespace"`
25- CreationInfo CreationInfo `json:"creationInfo"`
26- Packages []Package `json:"packages"`
27- Relationships []Relationship `json:"relationships"`
28- }
29-
30- type CreationInfo struct {
31- Created string `json:"created"`
32- Creators []string `json:"creators"`
33- LicenseListVersion string `json:"licenseListVersion"`
34- }
35-
36- type Package struct {
37- SPDXID string `json:"SPDXID"`
38- Name string `json:"name"`
39- DownloadLocation string `json:"downloadLocation"`
40- FilesAnalyzed bool `json:"filesAnalyzed"`
41- VerificationCode * Verification `json:"verificationCode,omitempty"`
42- Checksums []Checksum `json:"checksums,omitempty"`
43- HomePage string `json:"homePage,omitempty"`
44- LicenseConcluded string `json:"licenseConcluded"`
45- LicenseDeclared string `json:"licenseDeclared"`
46- CopyrightText string `json:"copyrightText"`
47- Description string `json:"description,omitempty"`
48- PackageVersion string `json:"versionInfo,omitempty"`
49- Supplier string `json:"supplier,omitempty"`
50- ExternalRefs []ExternalRef `json:"externalRefs,omitempty"`
51- }
52-
53- type Verification struct {
54- Value string `json:"packageVerificationCodeValue"`
55- }
56-
57- type Checksum struct {
58- Algorithm string `json:"algorithm"`
59- Value string `json:"checksumValue"`
60- }
61-
62- type Relationship struct {
63- SPDXElementID string `json:"spdxElementId"`
64- RelatedSPDXElement string `json:"relatedSpdxElement"`
65- RelationshipType string `json:"relationshipType"`
66- }
67-
68- type ExternalRef struct {
69- Category string `json:"referenceCategory"`
70- Type string `json:"referenceType"`
71- Locator string `json:"referenceLocator"`
72- }
73-
74- type DpkgPackage struct {
75- Name string
76- Version string
77- Architecture string
78- Status string
79- Maintainer string
80- Homepage string
81- Description string
82- License string
83- Copyright string
84- }
85-
8618func main () {
8719 var (
8820 outputFile = flag .String ("output" , "ubuntu-sbom.spdx.json" , "Output file path" )
@@ -308,21 +240,6 @@ func (g *SBOMGenerator) calculatePackageChecksum(packageName string) string {
308240 return fmt .Sprintf ("%x" , h .Sum (nil ))
309241}
310242
311- func hashFile (path string ) string {
312- file , err := os .Open (path )
313- if err != nil {
314- return ""
315- }
316- defer file .Close ()
317-
318- h := sha256 .New ()
319- if _ , err := io .Copy (h , file ); err != nil {
320- return ""
321- }
322-
323- return fmt .Sprintf ("%x" , h .Sum (nil ))
324- }
325-
326243func (g * SBOMGenerator ) Save (doc * SPDXDocument , outputPath string ) error {
327244 file , err := os .Create (outputPath )
328245 if err != nil {
@@ -442,14 +359,3 @@ func sanitizeName(name string) string {
442359 re := regexp .MustCompile (`[^a-zA-Z0-9-.]` )
443360 return re .ReplaceAllString (name , "-" )
444361}
445-
446- func generateUUID () string {
447- // Simple UUID v4 generation
448- b := make ([]byte , 16 )
449- for i := range b {
450- b [i ] = byte (time .Now ().UnixNano () & 0xff )
451- }
452-
453- return fmt .Sprintf ("%x-%x-%x-%x-%x" ,
454- b [0 :4 ], b [4 :6 ], b [6 :8 ], b [8 :10 ], b [10 :])
455- }
0 commit comments