PDF report with gvm-script error

Hallo,

I’ve been doing some tinkering with using OpenVAS from the CLI through the use of GVM-tools and gvm-script. Most of what I want seems to work but the creation of .pdf reports seems to be “broken”. I’ve used the provided script from the gvm-tools github page (and manuals) gvm-tools/scripts/pdf-report. But this leaves me with the error “Uncorrect padding”. To fix this i’ve used a “filler” to fix the numbers of “=” at the end of the file.

content += “=” * ((4 - len(content) % 4) % 4)

This allows me to be able to create the pdf, but when this has finished the actual pdf is broken (As in, the file is the correct size, but no pdf reader can open it). What I also notice is than when opening the pdf in a HEX editor i’m missing the file signature (25 50 44 46 2d) at the top of the document. (adding this manually does not fix the error)

Is anyone aware of this issue, am I the only one or does some1 know how I could fix this?

Which version of GVM do you use? Did you check if all dependencies for generating the pdf report are installed? Are you able to download the pdf via GSA?

HI, thx for the quick reply

GVM version: 11https://community.greenbone.net/t/gvm-11-stable-initial-release-2019-10-14/3674
GMP version: 9

Downloading from GSA works as it should (Using ubuntu 19.04)

As with dependencies, I do not know what I would need (mainly since I did not find any “special” requirements on the gvm-tools github page). At the moment i’m using the base pdf-report.gmp.py script which uses base64 and pathlib.

Using the gvm-cli tool with:

gvm-cli socket --xml ‘<get_reports report_id=“b9f8a2f2-2969-4ff2-bb3f-52e7765ac4cc” format_id=“c402cc3e-b531-11e1-9163-406186ea4fc5” details=“True”/>’ | grep -oP ‘(?<=</report_format>)[^<]+’|base64 -d > reports/test.pdf

Does generate a proper pdf file.

If you can download the file via GSA all dependencies are fine.

Not sure what’s wrong in pdf-report.py. It should be the same as we are doing in GSA.