(report Report)
| 22 | } |
| 23 | |
| 24 | func bomSWDoc(report Report) *model.BomSWDocument { |
| 25 | |
| 26 | doc := model.NewBomSWDocument(report.TaskInfo.AppName, "opensca-cli") |
| 27 | defer func() { |
| 28 | doc.SbomHashCheck = calculateSbomHashCheck(doc) |
| 29 | }() |
| 30 | |
| 31 | report.DepDetailGraph.ForEach(func(n *detail.DepDetailGraph) bool { |
| 32 | |
| 33 | if n.Name == "" { |
| 34 | return true |
| 35 | } |
| 36 | |
| 37 | lics := []string{} |
| 38 | for _, lic := range n.Licenses { |
| 39 | lics = append(lics, lic.ShortName) |
| 40 | } |
| 41 | doc.AppendComponents(func(swc *model.BomSWComponent) { |
| 42 | swc.ID = n.Purl() |
| 43 | swc.Name = n.Name |
| 44 | swc.Version = n.Version |
| 45 | swc.License = lics |
| 46 | }) |
| 47 | |
| 48 | children := []string{} |
| 49 | for _, c := range n.Children { |
| 50 | if c.Name == "" { |
| 51 | continue |
| 52 | } |
| 53 | children = append(children, c.Purl()) |
| 54 | } |
| 55 | doc.AppendDependencies(n.Purl(), children) |
| 56 | |
| 57 | return true |
| 58 | }) |
| 59 | |
| 60 | return doc |
| 61 | } |
| 62 | |
| 63 | func calculateSbomHashCheck(doc *model.BomSWDocument) string { |
| 64 | sha256Hash := sha256.New() |
no test coverage detected