From 22e0de2b3d82951725904cd6549fe2aabc9c046f Mon Sep 17 00:00:00 2001 From: Tim Jarrett Date: Fri, 27 Sep 2024 17:02:41 -0400 Subject: [PATCH] add support for scans report type --- docs/analytics.md | 6 +++++- pyproject.toml | 4 ++-- setup.py | 4 ++-- veracode_api_py/analytics.py | 16 ++++++++++++---- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/analytics.md b/docs/analytics.md index 995c169..5a0d643 100644 --- a/docs/analytics.md +++ b/docs/analytics.md @@ -17,6 +17,10 @@ The following methods call Veracode REST APIs and return JSON. - `application_id`: optional, application ID for which to return results - `rawjson`: optional, defaults to False. Returns full response if True, the GUID of the request if false -- `Analytics().get(guid)`: check the status of the report request and return the report contents when ready. Note that this method returns a tuple of `status` (string) and `results` (list); when `status` is `COMPLETED`, the `results` list will populate with results. +- `Analytics().get(guid, report_type(findings))`: check the status of the report request and return the report contents when ready. Note that this method returns a tuple of `status` (string) and `results` (list); when `status` is `COMPLETED`, the `results` list will populate with results. Also, you need to specify the type of data expected by the GUID with `report_type`; this defaults to `findings`. + +- `Analytics().get_findings(guid)`: check the status of a findings report request specified by `guid` and return the report contents when ready. Note that this method returns a tuple of `status` (string) and `results` (list); when `status` is `COMPLETED`, the `results` list will populate with results. + +- `Analytics().get_scans(guid)`: check the status of a scans report request specified by `guid` and return the report contents when ready. Note that this method returns a tuple of `status` (string) and `results` (list); when `status` is `COMPLETED`, the `results` list will populate with results. [All docs](docs.md) diff --git a/pyproject.toml b/pyproject.toml index 9a96679..c478f74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = 'veracode_api_py' -version = '0.9.49' +version = '0.9.50' authors = [ {name = "Tim Jarrett", email="tjarrett@veracode.com"} ] description = 'Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.' readme = 'README.md' @@ -22,4 +22,4 @@ dependencies = {file = ["requirements.txt"]} [project.urls] "Homepage" = "https://github.com/veracode/veracode-api-py" "Bug Tracker" = "https://github.com/veracode/veracode-api-py/issues" -"Download" = "https://github.com/veracode/veracode-api-py/archive/v_0949.tar.gz" +"Download" = "https://github.com/veracode/veracode-api-py/archive/v_0950.tar.gz" diff --git a/setup.py b/setup.py index 12cf7bb..6b17510 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name = 'veracode_api_py', packages = ['veracode_api_py'], - version = '0.9.49', + version = '0.9.50', license='MIT', description = 'Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.', long_description = long_description, @@ -15,7 +15,7 @@ author = 'Tim Jarrett', author_email = 'tjarrett@veracode.com', url = 'https://github.com/tjarrettveracode', - download_url = 'https://github.com/veracode/veracode-api-py/archive/v_0949.tar.gz', + download_url = 'https://github.com/veracode/veracode-api-py/archive/v_0950.tar.gz', keywords = ['veracode', 'veracode-api'], install_requires=[ 'veracode-api-signing' diff --git a/veracode_api_py/analytics.py b/veracode_api_py/analytics.py index 36a54a8..30bc1f1 100644 --- a/veracode_api_py/analytics.py +++ b/veracode_api_py/analytics.py @@ -55,13 +55,21 @@ def create_report(self,report_type,last_updated_start_date,last_updated_end_date else: return response['_embedded']['id'] #we will usually just need the guid so we can come back and fetch the report - def get(self,guid: UUID): + def get_findings(self, guid: UUID): + thestatus, thefindings = self.get(guid=guid,report_type='findings') + return thestatus, thefindings + + def get_scans(self, guid: UUID): + thestatus, thescans = self.get(guid=guid,report_type='scans') + return thestatus, thescans + + def get(self,guid: UUID,report_type='findings'): # handle multiple scan types uri = "{}/{}".format(self.base_url,guid) - theresponse = APIHelper()._rest_paged_request(uri,"GET","findings",{},fullresponse=True) + theresponse = APIHelper()._rest_paged_request(uri,"GET",report_type,{},fullresponse=True) thestatus = theresponse.get('_embedded',{}).get('status','') - thefindings = theresponse.get('_embedded',{}).get('findings',{}) - return thestatus, thefindings + thebody = theresponse.get('_embedded',{}).get(report_type,{}) + return thestatus, thebody #helper methods def _case_insensitive_list_compare(self,input_list:list, target_list:list):