Difficulties creating a PDF Repport after using Python-GVM

Hello, I’m trying to find a way to automate scan and report creation with Python-GVM.

I think I succeed to do a scan with the API, but when it’s time to convert the report to PDF I just found the following function here

def create_report(tname, report_id, gmp, path):
    time1 = datetime.datetime.now()
    timestamp = time1.strftime('%Y-%m-%d_%H_%M')
    pdf_filename = path + "/" + tname + "-" + timestamp + ".pdf"
    pdf_report_format_id = "c402cc3e-b531-11e1-9163-406186ea4fc5"
    response = gmp.get_report(report_id=report_id,
                              details=True,
                              report_format_id=pdf_report_format_id)
    response = ET.fromstring(response)
    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

The fact is that this code always give me reports with just Logs and not any vulnerability or anything. All the reports are the same, even if I use every time a new report id.
Can you help me find a way to create a real PDF Report ?

Hi, could you try

    response = gmp.get_report(report_id=report_id,
                              details=True,
                              filter_string="levels=hmlg",
                              report_format_id=pdf_report_format_id)
3 Likes

That was the solution thank you