Skip to content

Commit 473e4e6

Browse files
Add support for sandbox_ids filter in Analytics.create_report (fixes #99)
1 parent 2bb64f8 commit 473e4e6

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

docs/analytics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following methods call Veracode REST APIs and return JSON.
1818
- `rawjson`: optional, defaults to False. Returns full response if True, the GUID of the request if false
1919
- `deletion_start_date`: required for `deletedscans` report type, beginning of date range for deleted scans.
2020
- `deletion_end_date`: optional, end of date range for deleted scans.
21+
- `sandbox_ids`: optional, array of sandbox IDs (integers) for which to return results
2122

2223
- `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`.
2324

docs/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ As an alternative to importing individual objects into your library, you can acc
3939
- `policy_sandbox`: optional, 'Policy' or 'Sandbox'
4040
- `application_id`: optional, application ID for which to return results
4141
- `rawjson`: optional, defaults to False. Returns full response if True, the GUID of the request if false
42+
- `deletion_start_date`: required for `deletedscans` report type, beginning of date range for deleted scans.
43+
- `deletion_end_date`: optional, end of date range for deleted scans.
44+
- `sandbox_ids`: optional, array of sandbox IDs (integers) for which to return results
4245

4346
- `get_analytics_report(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.
4447

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = 'veracode_api_py'
3-
version = '0.9.58'
3+
version = '0.9.59'
44
authors = [ {name = "Tim Jarrett", email="[email protected]"} ]
55
description = 'Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.'
66
readme = 'README.md'
@@ -22,4 +22,4 @@ dependencies = {file = ["requirements.txt"]}
2222
[project.urls]
2323
"Homepage" = "https://github.com/veracode/veracode-api-py"
2424
"Bug Tracker" = "https://github.com/veracode/veracode-api-py/issues"
25-
"Download" = "https://github.com/veracode/veracode-api-py/archive/v_0958.tar.gz"
25+
"Download" = "https://github.com/veracode/veracode-api-py/archive/v_0959.tar.gz"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
setup(
88
name = 'veracode_api_py',
99
packages = ['veracode_api_py'],
10-
version = '0.9.58',
10+
version = '0.9.59',
1111
license='MIT',
1212
description = 'Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.',
1313
long_description = long_description,
1414
long_description_content_type="text/markdown",
1515
author = 'Tim Jarrett',
1616
author_email = '[email protected]',
1717
url = 'https://github.com/tjarrettveracode',
18-
download_url = 'https://github.com/veracode/veracode-api-py/archive/v_09578tar.gz',
18+
download_url = 'https://github.com/veracode/veracode-api-py/archive/v_0959tar.gz',
1919
keywords = ['veracode', 'veracode-api'],
2020
install_requires=[
2121
'veracode-api-signing'

veracode_api_py/analytics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Analytics():
1717
def create_report(self,report_type,last_updated_start_date=None,last_updated_end_date=None,
1818
scan_type:list = [], finding_status=None,passed_policy=None,
1919
policy_sandbox=None,application_id=None,rawjson=False, deletion_start_date=None,
20-
deletion_end_date=None):
20+
deletion_end_date=None, sandbox_ids:list = []):
2121

2222
if report_type not in self.report_types:
2323
raise ValueError("{} is not in the list of valid report types ({})".format(report_type,self.report_types))
@@ -48,7 +48,7 @@ def create_report(self,report_type,last_updated_start_date=None,last_updated_end
4848
elif report_type in [ 'scans', 'deletedscans' ]:
4949
valid_scan_types = self.scan_scan_types
5050
if not(self._case_insensitive_list_compare(scan_type,valid_scan_types)):
51-
raise ValueError("{} is not in the list of valid scan types ({})".format(report_type,valid_scan_types))
51+
raise ValueError("{} is not in the list of valid scan types ({})".format(scan_type,valid_scan_types))
5252
report_def['scan_type'] = scan_type
5353

5454
if finding_status:
@@ -62,6 +62,9 @@ def create_report(self,report_type,last_updated_start_date=None,last_updated_end
6262

6363
if application_id:
6464
report_def['application_id'] = application_id
65+
66+
if sandbox_ids:
67+
report_def['sandbox_ids'] = sandbox_ids
6568

6669
payload = json.dumps(report_def)
6770
response = APIHelper()._rest_request(url=self.base_url,method="POST",body=payload)

veracode_api_py/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,13 @@ def dyn_start_scan(self, length, unit):
645645
def create_analytics_report(self,report_type,last_updated_start_date=None,last_updated_end_date=None,
646646
scan_type:list = [], finding_status=None,passed_policy=None,
647647
policy_sandbox=None,application_id=None,rawjson=False,deletion_start_date=None,
648-
deletion_end_date=None):
648+
deletion_end_date=None, sandbox_ids:list = []):
649649
return Analytics().create_report(report_type=report_type,last_updated_start_date=last_updated_start_date,
650650
last_updated_end_date=last_updated_end_date,scan_type=scan_type,
651651
finding_status=finding_status,passed_policy=passed_policy,
652652
policy_sandbox=policy_sandbox,application_id=application_id,
653653
rawjson=rawjson, deletion_start_date=deletion_start_date,
654-
deletion_end_date=deletion_end_date)
654+
deletion_end_date=deletion_end_date, sandbox_ids=sandbox_ids)
655655

656656
def get_analytics_report(self,guid: UUID):
657657
status, findings = Analytics().get(guid=guid)

0 commit comments

Comments
 (0)