Skip to content

Commit

Permalink
add support for scans report type
Browse files Browse the repository at this point in the history
  • Loading branch information
tjarrettveracode committed Sep 27, 2024
1 parent eb6ab9f commit 22e0de2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 5 additions & 1 deletion docs/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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,
long_description_content_type="text/markdown",
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'
Expand Down
16 changes: 12 additions & 4 deletions veracode_api_py/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 22e0de2

Please sign in to comment.