veracode / veracode-api-py

Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.
MIT License
17 stars 24 forks source link

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

Open brunzefb opened 2 years ago

brunzefb commented 2 years ago

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

brunzefb commented 2 years ago

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)