hello i want to save a report from a script … it worked well, but the report ist different to the pdf report from gsad …
how can I set the filter?
I tried this:
response = gmp.get_report(report_id=report_id, filter="apply_overrides=0 levels=hml rows=100 min_qod=70 first=1 sort-reverse=severity",report_format_id=pdf_report_format_id)
in my create python script … but with no success:
import sys
from base64 import b64decode
from pathlib import Path
import datetime
import time
import os
def create_report(tname,reportid):
time1 = datetime.datetime.now()
timestamp=time1.strftime('%Y-%m-%d_%H_%M')
pdf_filename = "/tmp/" + tname + "-" + timestamp + ".pdf"
pdf_report_format_id = "c402cc3e-b531-11e1-9163-406186ea4fc5"
response = gmp.get_report(report_id=report_id, filter="apply_overrides=0 levels=hml rows=100 min_qod=70 first=1 sort-reverse=severity",report_format_id=pdf_report_format_id)
report_element = response.find("report")
content = report_element.find("report_format").tail
binary_base64_encoded_pdf = content.encode('ascii')
binary_pdf = b64decode(binary_base64_encoded_pdf)
pdf_path = Path(pdf_filename).expanduser()
pdf_path.write_bytes(binary_pdf)
print("PDF: " + pdf_filename + " created")
return pdf_filename
task_name=sys.argv[4]
report_id=sys.argv[5]
create_report(task_name,report_id)
the gvm-cli script worked
#!/bin/bash
REPORTID=$1
PDF=$2
FORMATID="c402cc3e-b531-11e1-9163-406186ea4fc5"
gvm-cli tls --hostname=scanner --xml "<get_reports report_id=\"$REPORTID\" filter=\"apply_overrides=0 levels=hml rows=100 min_qod=70 first=1 sort-reverse=severity\" format_id=\"$FORMATID\" details=\"True\"/>" | grep -oP '(?<=</report_format>)[^<]+'|base64 -d > $PDF