生成一个来自Trivy的HTML报告。

huangapple go评论226阅读模式
英文:

Generate a html report from Trivy

问题

I'm trying to generate a HTML report from Trivy. On the example page, they provide trivy image --format template --template "@contrib/html.tpl" -o report.html golang:1.12-alpine. When I run this, I get the following error,

FATAL report error: unable to write results: failed to initialize template writer: error retrieving template from path: open contrib/html.tpl: no such file or directory

Based on the documentation, It looks like this is a default template so I'm assuming it's included. My logic here is that there is no "/" following the "@" in the template path.

I'm currently on version 0.41.0

英文:

I'm trying to generate a HTML report from Trivy. On the example page, they provide trivy image --format template --template "@contrib/html.tpl" -o report.html golang:1.12-alpine. When I run this, I get the following error,

FATAL report error: unable to write results: failed to initialize template writer: error retrieving template from path: open contrib/html.tpl: no such file or directory

Based on the documentation, It looks like this is a default template so I'm assuming it's included. My logic here is that there is no "/" following the "@" in the template path.

I'm currently on version 0.41.0

答案1

得分: 1

不确定您使用的操作系统,但在Kali Linux上,我执行以下操作:

    trivy fs FOLDER_PATH --format -template --template 
          "@/usr/share/trivy/templates/html.tpl" --output NAME_OF_FOLDER.html

我喜欢自定义.tpl文件以生成我喜欢的HTML页面,所以我通常会将文件复制到其他地方并进行编辑。

`--template "@/home/user/Desktop/html.tpl"`(或者您想要放置它的任何地方)

您提供的示例来自旧文档。这里有一些更新的内容可能会有所帮助:https://aquasecurity.github.io/trivy/v0.41/docs/configuration/reporting/#default-templates
英文:

Not sure what operating system you're using, but on Kali Linux I do the following:

trivy fs FOLDER_PATH --format -template --template 
      "@/usr/share/trivy/templates/html.tpl" --output NAME_OF_FOLDER.html

I like customizing the .tpl file to generate a html page to my liking, so I generally copy the file somewhere else and edit it.

--template "@/home/user/Desktop/html.tpl" (or wherever you wanna put it)

The example you link is from old documentation. Here's something newer that might help: https://aquasecurity.github.io/trivy/v0.41/docs/configuration/reporting/#default-templates

答案2

得分: 1

根据0.41版本的文档,您需要找出模板保存在您系统上的路径。我也使用标准模板,并需要将 "@/usr/local/share/trivy/templates/html.tpl" 设置为路径。我猜这取决于您的操作系统以及您安装trivy的方式。我在CentOS 7系统上运行它。

文档中的信息:
生成一个来自Trivy的HTML报告。

文档中的示例命令:$ trivy image --format template --template "@/path/to/template" golang:1.12-alpine -o your_output.html

英文:

According to the documentation for 0.41 you need to find out the path where the templates are saved on your system. I also use the standard template and need to set "@/usr/local/share/trivy/templates/html.tpl" as path. I guess it depends on your operating system and the way you've installed trivy. I run it on a centOS 7 System

Information from the Documentation:
生成一个来自Trivy的HTML报告。

Example command from documentation: $ trivy image --format template --template "@/path/to/template" golang:1.12-alpine -o your_output.html

答案3

得分: 1

I did not install trivy from RPM and had no files other than a solid trivy binary of a few 10 MBs. Downloaded the html.tpl template from their github repo https://github.com/aquasecurity/trivy/blob/main/contrib/html.tpl and placed it in /usr/bin/html.tpl and used the command line: trivy image --format template --template "@/usr/bin/html.tpl" -o report.html image-name

英文:

I did not install trivy from RPM and had no files other than a solid trivy binary of a few 10 MBs. Downloaded the html.tpl template from their github repo https://github.com/aquasecurity/trivy/blob/main/contrib/html.tpl and placed it in /usr/bin/html.tpl and used the command line: trivy image --format template --template "@/usr/bin/html.tpl" -o report.html image-name

答案4

得分: 0

"First, we should find the file in your system "html.tpl". I am using a mac and when I ran the below find command

find / -name html.tpl

output:
/System/Volumes/Data/Applications/...../.trivy/contrib/html.tpl

I passed the html.tpl path in the command

trivy image --format template --template html path -o report.html image name

It worked."

英文:

First, we should find the file in your system "html.tpl". I am using a mac and when I ran the below find command

> find / -name html.tpl

output:
/System/Volumes/Data/Applications/...../.trivy/contrib/html.tpl

I passed the html.tpl path in the command

trivy image --format template --template html path -o report.html image name

It worked.

huangapple
  • 本文由 发表于 2023年5月10日 22:32:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76219682.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定