Gvm-tool export report in csv format

I did take report in xml format but I didn’t find any example that shows how to have report in csv format.
Actually I did try --csv but it is not a valid option.

can you help me to have my csv report?

Hi,

you could take a look at this PR Add export-csv-report by doracpphp · Pull Request #692 · greenbone/gvm-tools · GitHub where a community user posted a script for downloading a CSV report. In general downloading a CSV report works exactly the same as downloading a pdf (gvm-tools/export-pdf-report.gmp.py at main · greenbone/gvm-tools · GitHub) but requires a different UUID for the report format.

2 Likes

thanks for showing me!
I did try to do it with bash script since I use docker installation and this is what I did:

        format_id="c1645568-627a-11e3-a660-406186ea4fc5"
        get_report_cmd="<get_reports report_id=\"$report_id\" format_id=\"$format_id\" ignore_pagination=\"1\" details=\"1\" />"
        output_file="result_$date.csv"

docker compose -f docker-compose-22.4.yml -p greenbone-community-edition run --rm -it gvm-tools gvm-cli     --gmp-username "$user"     --gmp-password "$pass"     socket     --xml "$get_report_cmd" > $output_file

but it returns error after a while and file is empty. this is the error:
ERROR:gvmtools.cli:timed out

Try to increase the timeout by setting --timeout. The default is 60 seconds which is often to low for report requests.

2 Likes

for making this clear for myself I ask related question here and don’t make another topic:

for now i can export csv format report but it returns data in base64 encoding as I understand. is there any option that i can use to have decoded format?

No. Because it’s returned within XML it needs to be encoded in a XML safe data format. Therefore we did choose base64.

It’s just a two liner in Python gvm-tools/export-pdf-report.gmp.py at main · greenbone/gvm-tools · GitHub

2 Likes

Script works well, however added ignore_pagination=True, details=True, so that the report_id line now looks like this: report_id=report_id, report_format_id=csv_report_format_id, ignore_pagination=True, details=True to get the full report (same is true for the pdf version in my testing).