MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / bomSWDoc

Function bomSWDoc

cmd/format/bomsw.go:24–61  ·  view source on GitHub ↗
(report Report)

Source from the content-addressed store, hash-verified

22}
23
24func 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
63func calculateSbomHashCheck(doc *model.BomSWDocument) string {
64 sha256Hash := sha256.New()

Callers 1

BomSWJsonFunction · 0.85

Calls 6

AppendComponentsMethod · 0.95
AppendDependenciesMethod · 0.95
NewBomSWDocumentFunction · 0.92
calculateSbomHashCheckFunction · 0.85
PurlMethod · 0.80
ForEachMethod · 0.45

Tested by

no test coverage detected