gvm-script -c ./gvm-tools.conf tls --hostname 127.0.0.1 --port 9390 pdf-report.gmp f06bdf89-c29c-4565-923a-d64908012067
PDF file produced command above can not be opened.
GVM versions
**gsad:8.0.1 (‘gsad --version’)
**gvmd: 8.0.1 (‘gvmd --version’)
**openvas:6.0.1 (‘openvassd --version’)
**gvm-libs:10.0.1
gvm-tools:2.0.0 release version
python-gvm:1.0.0 release version
Please ensure you have installed the required packages e.g. xsltproc and xmlstarlet. There are a lot of topics regarding the missing packages for different distributions in this forum. E.g.
No one?
Note that from the dashboard I correctly download the report in pdf format. The problem is to create the pdf using the pdf-report.gmp script. Thanks
Via GSA, PDF generation works fine. If I use the pdf-report.gmp script respectively embed the code in my own scripts, I sometimes get the same Errors and sometimes a file is created but unreadable (filetype application/octet-stream).
What is conspicuous, is that the size of the unreadable file is almost twice as much as the same pdf report file exported via GSA.
Firstly I temporarily saved the XML response and removed all nodes from <report> but the text node. Parsing of this modified XML worked fine with the pdf-report.gmp code.
But instead of removing nodes I applied the solution suggested from @gormami posted in:
To achieve this, the codeline of pdf-report.gmp
had to be rewritten as follows:
import re
from lxml import etree
# get the content of the report element
report = report_response[0]
report = etree.tostring(report).decode('ascii')
report = re.sub('</report_format>', '</report_format><value>', report)
report = re.sub('</report>', '</value></report>', report)
report = etree.fromstring(report)
content = report.xpath('value')[0].text
In my case, this results in a correct PDF report. Of course, this is just a workaround. But obviously there are some parser which cannot handle the XML structure of <report>. So maybe an adjustment should be considered.