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

Function Save

cmd/format/save.go:36–84  ·  view source on GitHub ↗
(report Report, output string)

Source from the content-addressed store, hash-verified

34}
35
36func Save(report Report, output string) {
37 for out := range strings.SplitSeq(output, ",") {
38 logs.Infof("result save to %s", out)
39 switch filepath.Ext(out) {
40 case ".html":
41 Html(genReport(report), out)
42 case ".json":
43 if strings.HasSuffix(out, ".spdx.json") {
44 SpdxJson(report, out)
45 } else if strings.HasSuffix(out, ".dsdx.json") {
46 DsdxJson(report, out)
47 } else if strings.HasSuffix(out, ".cdx.json") {
48 CycloneDXJson(report, out)
49 } else if strings.HasSuffix(out, ".swid.json") {
50 SwidJson(report, out)
51 } else if strings.HasSuffix(out, ".bomsw.json") {
52 BomSWJson(report, out)
53 } else {
54 Json(genReport(report), out)
55 }
56 case ".sw", ".bom-sw", ".bomsw":
57 BomSWJson(report, out)
58 case ".dsdx":
59 Dsdx(report, out)
60 case ".spdx":
61 Spdx(report, out)
62 case ".xml":
63 if strings.HasSuffix(out, ".spdx.xml") {
64 SpdxXml(report, out)
65 } else if strings.HasSuffix(out, ".dsdx.xml") {
66 DsdxXml(report, out)
67 } else if strings.HasSuffix(out, ".cdx.xml") {
68 CycloneDXXml(report, out)
69 } else if strings.HasSuffix(out, ".swid.xml") {
70 SwidXml(report, out)
71 } else {
72 Xml(report, out)
73 }
74 case ".csv":
75 Csv(report, out)
76 case ".sqlite", ".db":
77 Sqlite(report, out)
78 case ".sarif":
79 Sarif(report, out)
80 default:
81 Json(genReport(report), out)
82 }
83 }
84}
85
86func genReport(report Report) Report {
87 optional := config.Conf().Optional

Callers 1

mainFunction · 0.92

Calls 15

InfofFunction · 0.92
HtmlFunction · 0.85
genReportFunction · 0.85
SpdxJsonFunction · 0.85
DsdxJsonFunction · 0.85
CycloneDXJsonFunction · 0.85
SwidJsonFunction · 0.85
BomSWJsonFunction · 0.85
JsonFunction · 0.85
DsdxFunction · 0.85
SpdxFunction · 0.85
SpdxXmlFunction · 0.85

Tested by

no test coverage detected