(report Report, output string)
| 34 | } |
| 35 | |
| 36 | func 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 | |
| 86 | func genReport(report Report) Report { |
| 87 | optional := config.Conf().Optional |
no test coverage detected