veracode-api-py icon indicating copy to clipboard operation
veracode-api-py copied to clipboard

please add support for the 'api/4.0/detailedreportpdf.do' api

Open brunzefb opened this issue 3 years ago • 1 comments

please add support for the 'api/4.0/detailedreportpdf.do' api

brunzefb avatar Nov 05 '22 23:11 brunzefb

implementation can be sort of like this:

def download_report(build_id, file_to_be_uploaded):
    print('Downloading the pdf report')
    name = os.path.splitext(file_to_be_uploaded)[0]
    endpoint = 'https://analysiscenter.veracode.com/api/4.0/detailedreportpdf.do'
    try:
        response = requests.get(endpoint,
                                allow_redirects=True,
                                params={'build_id': build_id},
                                auth=RequestsAuthPluginVeracodeHMAC(),
                                headers=HEADERS)
    except requests.RequestException as e:
        print(EXCEPTION_DETAILS_FOLLOW)
        print(e)
        sys.exit(1)

    if response.ok:
        file_name = get_filename_from_content_disposition(response.headers.get('content-disposition'))
        if not file_name:
            file_name = name
        file_name = name + '-' + file_name
        open(file_name, 'wb').write(response.content)
        print("Success! Report filename: " + file_name)

brunzefb avatar Nov 05 '22 23:11 brunzefb