Skip to content

Commit

Permalink
add methods for CWEs and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tjarrettveracode committed Oct 22, 2024
1 parent 783b8ac commit eb2377c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ name: SBOM

on:
workflow_dispatch:
release:

jobs:
sbom:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See the topics below for more information on how to use this library.
* [Healthcheck and Status](healthcheck.md) - access information about the status of Veracode services.
* [Applications and Sandboxes](applications.md) - create, update, access, and delete application profiles and sandboxes.
* [Policy](policy.md) - create, update, access, and delete policy definitions.
* [Findings and Annotations](findings.md) - retrieve findings and propose, accept, and reject mitigations.
* [Findings, Annotations, Summary Reports, and CWE and Category Metadata](findings.md) - retrieve findings and propose, accept, and reject mitigations. Get summary reports for applications. Get CWE and category metadata.
* [Collections](collections.md) - (EARLY ACCESS) create, update, access, and delete collections.
* [SCA Agent](sca.md) - access information about SCA workspaces, projects, issues, vulnerabilities, libraries, and licenses.
* [Dynamic Analysis](dynamic.md) - configure, schedule and start dynamic analyses (use with the Veracode Dynamic Analysis product).
Expand Down
9 changes: 8 additions & 1 deletion docs/findings.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Findings, Annotations, and Summary Reports
# Findings, Annotations, Summary Reports, and CWE and Category Metadata

The following methods call Veracode REST APIs and return JSON.

Expand Down Expand Up @@ -29,4 +29,11 @@ The following methods call Veracode REST APIs and return JSON.
- `ManualScans().get_findings(scanid,include_artifacts(opt))`: get the manual findings detail for `scanid` (int).
- `include_artifacts`: if `True`, includes screenshots and code samples associated with the findings.

## CWEs and Category Metadata

- `CWEs().get_all()`: get metadata for all CWEs.
- `CWEs().get(cwe_id)`: get metadata for the CWE identified by `cwe_id` (int).
- `CWECategories().get_all()`: get metadata for all CWE categories.
- `CWECategories().get(category_id)`: get metadata for the CWE category identified by `category_id` (int).

[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.52'
version = '0.9.53'
authors = [ {name = "Tim Jarrett", email="[email protected]"} ]
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_0952.tar.gz"
"Download" = "https://github.com/veracode/veracode-api-py/archive/v_0953.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.52',
version = '0.9.53',
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 = '[email protected]',
url = 'https://github.com/tjarrettveracode',
download_url = 'https://github.com/veracode/veracode-api-py/archive/v_0952.tar.gz',
download_url = 'https://github.com/veracode/veracode-api-py/archive/v_0953.tar.gz',
keywords = ['veracode', 'veracode-api'],
install_requires=[
'veracode-api-signing'
Expand Down
2 changes: 1 addition & 1 deletion veracode_api_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from veracode_api_py.collections import Collections
from veracode_api_py.dynamic import Analyses, Scans, CodeGroups, Configuration, ScannerVariables, ScanCapacitySummary, Occurrences, DynUtils
from veracode_api_py.exceptions import VeracodeAPIError, VeracodeError
from veracode_api_py.findings import Findings, SummaryReport, ManualScans
from veracode_api_py.findings import Findings, SummaryReport, ManualScans, CWEs, CWECategories
from veracode_api_py.healthcheck import Healthcheck
from veracode_api_py.identity import Users, Teams, BusinessUnits, APICredentials, Roles
from veracode_api_py.sca import Workspaces, ComponentActivity, SBOM, SCAApplications
Expand Down
16 changes: 15 additions & 1 deletion veracode_api_py/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .constants import Constants
from .exceptions import VeracodeAPIError
from .applications import Applications, Sandboxes, CustomFields
from .findings import Findings, SummaryReport, ManualScans
from .findings import Findings, SummaryReport, ManualScans, CWEs, CWECategories
from .policy import Policies
from .sca import ComponentActivity, Workspaces, SBOM, SCAApplications
from .collections import Collections
Expand Down Expand Up @@ -195,6 +195,20 @@ def get_mpt_scan(self, scanid: int):

def get_mpt_findings(self, scanid: int, include_artifacts=False):
return ManualScans().get_findings(scanid=scanid, include_artifacts=include_artifacts)

## CWEs and category metadata

def get_cwes(self):
return CWEs().get_all()

def get_cwe(self,cwe_id:int):
return CWEs().get(cwe_id=cwe_id)

def get_cwecategories(self):
return CWECategories().get_all()

def get_cwecategory(self,category_id:int):
return CWECategories().get(category_id=category_id)

## Collections APIs

Expand Down
21 changes: 20 additions & 1 deletion veracode_api_py/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,23 @@ def get_findings(self,scanid: int, include_artifacts=False):
params = {}
params['include_artifacts'] = include_artifacts
return APIHelper()._rest_paged_request(uri,"GET","findings",params=params)


class CWEs():
base_uri = 'appsec/v1/cwes'
def get_all(self):
params = {}
return APIHelper()._rest_paged_request(self.base_uri,"GET","cwes", params=params)

def get(self,cwe_id: int):
uri = '{}/{}'.format(self.base_uri, cwe_id)
return APIHelper()._rest_request(uri,"GET")

class CWECategories():
base_uri = 'appsec/v1/categories'
def get_all(self):
params = {}
return APIHelper()._rest_paged_request(self.base_uri,"GET", "categories", params=params)

def get(self,category_id: int):
uri = '{}/{}'.format(self.base_uri, category_id)
return APIHelper()._rest_request(uri,"GET")

0 comments on commit eb2377c

Please sign in to comment.