|
1 | 1 | [返回目录](/docs/README-zh-CN.md) / [English](./Reports.md) |
2 | 2 |
|
| 3 | +# 生成报告 |
| 4 | + |
| 5 | +OpenSCA 支持生成多种格式的报告, 包括 JSON(`.json`), XML(`.xml`), HTML(`.html`), SQLite(`.sqlite`), CSV(`.csv`), SARIF(`.sarif`) |
| 6 | + |
| 7 | +> CSV 格式报告仅包含依赖关系, 不包含漏洞信息. 若需要包含漏洞信息的 Excel 格式报告, 我们提供了 [json2excel](https://github.com/XmirrorSecurity/OpenSCA-cli/blob/master/scripts/json2excel.py) 脚本, 可以将 JSON 格式报告转换为 Excel 格式报告. |
| 8 | +
|
| 9 | +此外, OpenSCA 提供 SaaS 服务, 同步扫描结果后, 可以在 [OpenSCA SaaS Console](https://opensca.xmirror.cn/console) 查看和下载报告. |
| 10 | + |
| 11 | +# 使用 OpenSCA-cli 生成报告 |
| 12 | + |
| 13 | +## 基本命令 |
| 14 | + |
| 15 | +OpenSCA-cli 使用 `-out` 参数指定报告输出路径, 使用后缀名指定报告格式. |
| 16 | + |
| 17 | +```shell |
| 18 | +opensca-cli -path {项目路径} -out {报告路径}.{报告格式} |
| 19 | +``` |
| 20 | + |
| 21 | +## 示例 |
| 22 | + |
| 23 | +<table> |
| 24 | +<tr> |
| 25 | +<th align="center">生成 JSON 格式报告</th> |
| 26 | +<th align="center">生成 XML 格式报告</th> |
| 27 | +<th align="center">生成 HTML 格式报告</th> |
| 28 | +<th align="center">生成 SQLite 格式报告</th> |
| 29 | +<th align="center">生成 CSV 格式报告</th> |
| 30 | +<th align="center">生成 SARIF 格式报告</th> |
| 31 | +</tr> |
| 32 | +<tr> |
| 33 | +<td> |
| 34 | + |
| 35 | +```shell |
| 36 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.json |
| 37 | +``` |
| 38 | + |
| 39 | +</td> |
| 40 | +<td> |
| 41 | + |
| 42 | +```shell |
| 43 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.xml |
| 44 | +``` |
| 45 | + |
| 46 | +</td> |
| 47 | +<td> |
| 48 | + |
| 49 | +```shell |
| 50 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.html |
| 51 | +``` |
| 52 | + |
| 53 | +</td> |
| 54 | +<td> |
| 55 | + |
| 56 | +```shell |
| 57 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.sqlite |
| 58 | +``` |
| 59 | + |
| 60 | +</td> |
| 61 | +<td> |
| 62 | + |
| 63 | +```shell |
| 64 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.csv |
| 65 | +``` |
| 66 | + |
| 67 | +</td> |
| 68 | +<td> |
| 69 | + |
| 70 | +```shell |
| 71 | +opensca-cli -path ~/workscapce/myproject -out ~/workscapce/myproject/report.sarif |
| 72 | +``` |
| 73 | + |
| 74 | +</td> |
| 75 | +</tr> |
| 76 | +</table> |
| 77 | + |
| 78 | +# 使用 json2excel 脚本生成 Excel 格式报告 |
| 79 | + |
| 80 | +## 需求 |
| 81 | + |
| 82 | +- Python 3.6+ |
| 83 | +- pandas |
| 84 | + |
| 85 | +## 安装脚本 |
| 86 | + |
| 87 | +```shell |
| 88 | +# 下载脚本 |
| 89 | +wget https://raw.githubusercontent.com/XmirrorSecurity/OpenSCA-cli/master/scripts/json2excel.py |
| 90 | + |
| 91 | +# 安装依赖 |
| 92 | +pip install pandas |
| 93 | +``` |
| 94 | + |
| 95 | +## 使用方法 |
| 96 | + |
| 97 | +**修改 json2excel.py** |
| 98 | + |
| 99 | +修改 json2excel.py 文件中的以下内容: |
| 100 | + |
| 101 | +- 将 "result.json" 修改为你的 JSON 格式报告路径 |
| 102 | +- 将 "result.xlsx" 修改为你的 Excel 格式报告路径 |
| 103 | + |
| 104 | +```python |
| 105 | +# ... |
| 106 | +if __name__ == "__main__": |
| 107 | + json2excel("result.json", "result.xlsx") |
| 108 | +``` |
| 109 | + |
| 110 | +**运行脚本** |
| 111 | + |
| 112 | +```shell |
| 113 | +python json2excel.py |
| 114 | +``` |
0 commit comments