CheckmarxPythonSDK 1.8.4__py3-none-any.whl → 1.8.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CheckmarxPythonSDK/CxOne/__init__.py +26 -0
- CheckmarxPythonSDK/CxOne/dastResultsAPI.py +209 -0
- CheckmarxPythonSDK/CxOne/dastScanAPI.py +636 -0
- CheckmarxPythonSDK/CxOne/dto/DastAlertRiskLevel.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/DastApplication.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/DastAuthSettings.py +32 -0
- CheckmarxPythonSDK/CxOne/dto/DastAuthSuccess.py +8 -0
- CheckmarxPythonSDK/CxOne/dto/DastAutomationAction.py +6 -0
- CheckmarxPythonSDK/CxOne/dto/DastAutomationEngine.py +6 -0
- CheckmarxPythonSDK/CxOne/dto/DastAutomationScript.py +36 -0
- CheckmarxPythonSDK/CxOne/dto/DastAutomationScriptType.py +10 -0
- CheckmarxPythonSDK/CxOne/dto/DastAutomationType.py +6 -0
- CheckmarxPythonSDK/CxOne/dto/DastCliSettings.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/DastConfigFileSettings.py +12 -0
- CheckmarxPythonSDK/CxOne/dto/DastCustomHeader.py +16 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironment.py +98 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentFilter.py +54 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentGroupCount.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentInput.py +38 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentSettings.py +42 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentUpdate.py +46 -0
- CheckmarxPythonSDK/CxOne/dto/DastEnvironmentsCollection.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/DastGroupBy.py +12 -0
- CheckmarxPythonSDK/CxOne/dto/DastLastRiskRating.py +8 -0
- CheckmarxPythonSDK/CxOne/dto/DastPollHeader.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/DastResult.py +59 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultChangelogEntry.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultDetail.py +84 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultNote.py +17 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultSeverity.py +10 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultState.py +11 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultStatus.py +7 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsChangelogInput.py +51 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsChangelogType.py +13 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsCollection.py +19 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsFilter.py +45 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsGroupBy.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsGroupCount.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/DastResultsSortBy.py +13 -0
- CheckmarxPythonSDK/CxOne/dto/DastRunScanInput.py +24 -0
- CheckmarxPythonSDK/CxOne/dto/DastScan.py +74 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanAuth.py +18 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanAuthParameters.py +28 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanAuthVerification.py +30 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanConfig.py +28 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanFilter.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanGroupBy.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanGroupCount.py +20 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanGroupFilter.py +29 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanInsight.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanOption.py +9 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanOptions.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanSortBy.py +13 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanStatus.py +15 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanType.py +7 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanUpdate.py +32 -0
- CheckmarxPythonSDK/CxOne/dto/DastScanUser.py +15 -0
- CheckmarxPythonSDK/CxOne/dto/DastScansCollection.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/DastSessionManagement.py +17 -0
- CheckmarxPythonSDK/CxOne/dto/DastSessionManagementHeader.py +17 -0
- CheckmarxPythonSDK/CxOne/dto/DastSortBy.py +13 -0
- CheckmarxPythonSDK/CxOne/dto/DastSortOrder.py +6 -0
- CheckmarxPythonSDK/CxOne/dto/DastTotpField.py +12 -0
- CheckmarxPythonSDK/CxOne/dto/DastTunnelState.py +7 -0
- CheckmarxPythonSDK/CxOne/dto/DastUserCredentials.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/RiskLevel.py +20 -0
- CheckmarxPythonSDK/CxOne/dto/TenantOverview.py +16 -0
- CheckmarxPythonSDK/CxOne/dto/__init__.py +64 -0
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +4 -2
- {checkmarxpythonsdk-1.8.4.dist-info → checkmarxpythonsdk-1.8.6.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.8.4.dist-info → checkmarxpythonsdk-1.8.6.dist-info}/RECORD +75 -9
- {checkmarxpythonsdk-1.8.4.dist-info → checkmarxpythonsdk-1.8.6.dist-info}/WHEEL +0 -0
- {checkmarxpythonsdk-1.8.4.dist-info → checkmarxpythonsdk-1.8.6.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.8.4.dist-info → checkmarxpythonsdk-1.8.6.dist-info}/top_level.txt +0 -0
|
@@ -119,6 +119,32 @@ from .customStateAPI import (
|
|
|
119
119
|
create_a_custom_state,
|
|
120
120
|
delete_a_custom_state,
|
|
121
121
|
)
|
|
122
|
+
from .dastScanAPI import (
|
|
123
|
+
DastScanAPI,
|
|
124
|
+
get_tenant_overview,
|
|
125
|
+
create_environment,
|
|
126
|
+
update_environment,
|
|
127
|
+
delete_environment,
|
|
128
|
+
get_environment_by_id,
|
|
129
|
+
get_environments,
|
|
130
|
+
get_environments_count_by_group,
|
|
131
|
+
get_scans,
|
|
132
|
+
run_scan,
|
|
133
|
+
run_public_scan,
|
|
134
|
+
update_scan,
|
|
135
|
+
dast_cancel_scan,
|
|
136
|
+
dast_delete_scan,
|
|
137
|
+
get_scans_count_by_group,
|
|
138
|
+
dast_get_scan_by_id,
|
|
139
|
+
get_scan_log,
|
|
140
|
+
)
|
|
141
|
+
from .dastResultsAPI import (
|
|
142
|
+
DastResultsAPI,
|
|
143
|
+
get_results,
|
|
144
|
+
update_results,
|
|
145
|
+
get_result_info,
|
|
146
|
+
get_results_count_by_group,
|
|
147
|
+
)
|
|
122
148
|
from .flagsAPI import (
|
|
123
149
|
FeatureFlagAPI,
|
|
124
150
|
get_all_feature_flags,
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""DAST Results Service REST API.
|
|
2
|
+
|
|
3
|
+
Endpoints under <server>/api/dast/mfe-results. Endpoints with
|
|
4
|
+
documented response shapes return DTO objects; the rest are stubs
|
|
5
|
+
that return the raw parsed JSON response until their schemas are
|
|
6
|
+
pinned down.
|
|
7
|
+
"""
|
|
8
|
+
from typing import List
|
|
9
|
+
from CheckmarxPythonSDK.api_client import ApiClient
|
|
10
|
+
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
11
|
+
from .dto import (
|
|
12
|
+
DastResultDetail,
|
|
13
|
+
DastResultsChangelogInput,
|
|
14
|
+
DastResultsCollection,
|
|
15
|
+
DastResultsFilter,
|
|
16
|
+
DastResultsGroupBy,
|
|
17
|
+
DastResultsGroupCount,
|
|
18
|
+
DastResultsSortBy,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _flatten_filter(name: str, obj_filter) -> dict:
|
|
23
|
+
"""Expand a filter DTO into bracketed nested query params
|
|
24
|
+
(e.g. filter[severity]=HIGH) — the wire format the DAST APIs use."""
|
|
25
|
+
if obj_filter is None:
|
|
26
|
+
return {}
|
|
27
|
+
return {f"{name}[{k}]": v for k, v in obj_filter.to_dict().items()}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DastResultsAPI(object):
|
|
31
|
+
|
|
32
|
+
def __init__(self, api_client: ApiClient = None):
|
|
33
|
+
if api_client is None:
|
|
34
|
+
configuration = construct_configuration()
|
|
35
|
+
api_client = ApiClient(configuration=configuration)
|
|
36
|
+
self.api_client = api_client
|
|
37
|
+
self.base_url = (
|
|
38
|
+
f"{self.api_client.configuration.server_base_url}/api/dast/mfe-results"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def get_results(
|
|
42
|
+
self,
|
|
43
|
+
scan_id: str,
|
|
44
|
+
filter_: DastResultsFilter = None,
|
|
45
|
+
page: int = None,
|
|
46
|
+
per_page: int = None,
|
|
47
|
+
search: str = None,
|
|
48
|
+
sort_by: List[DastResultsSortBy] = None,
|
|
49
|
+
group: str = None,
|
|
50
|
+
) -> DastResultsCollection:
|
|
51
|
+
"""GET /results/{scan_id} — paged results (risks) identified by
|
|
52
|
+
a specific DAST scan.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
scan_id (str): UUID of the scan.
|
|
56
|
+
filter_ (DastResultsFilter, optional): partial-match filter
|
|
57
|
+
on severity, path, name, method, status, state, url,
|
|
58
|
+
owasp, alert_similarity_id.
|
|
59
|
+
page (int, optional): 1-based page number. Default 1.
|
|
60
|
+
per_page (int, optional): page size, 1-100. Default 10.
|
|
61
|
+
search (str, optional): substring search across multiple
|
|
62
|
+
columns.
|
|
63
|
+
sort_by (list of DastResultsSortBy, optional): sort columns.
|
|
64
|
+
Each entry is serialized as "<col>:asc"; pass a raw
|
|
65
|
+
"col:desc" string for per-column descending order.
|
|
66
|
+
group (str, optional): filter by groups.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
DastResultsCollection
|
|
70
|
+
"""
|
|
71
|
+
params = {
|
|
72
|
+
"page": page,
|
|
73
|
+
"per_page": per_page,
|
|
74
|
+
"search": search,
|
|
75
|
+
"sort_by": (
|
|
76
|
+
[s if ":" in str(s) else f"{s.value if isinstance(s, DastResultsSortBy) else s}:asc"
|
|
77
|
+
for s in sort_by]
|
|
78
|
+
if sort_by else None
|
|
79
|
+
),
|
|
80
|
+
"group": group,
|
|
81
|
+
}
|
|
82
|
+
params.update(_flatten_filter("filter", filter_))
|
|
83
|
+
response = self.api_client.call_api(
|
|
84
|
+
method="GET", url=f"{self.base_url}/results/{scan_id}",
|
|
85
|
+
params=params,
|
|
86
|
+
)
|
|
87
|
+
return DastResultsCollection.from_dict(response.json())
|
|
88
|
+
|
|
89
|
+
def update_results(self, changelog: DastResultsChangelogInput) -> bool:
|
|
90
|
+
"""POST /changelog — update severity/state/notes on one or more
|
|
91
|
+
results (single or batch).
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
changelog (DastResultsChangelogInput): the update payload.
|
|
95
|
+
similarity_id_2 / environment_id / scan_id are required;
|
|
96
|
+
severity / state / note / type / alert_similarity_id /
|
|
97
|
+
custom_state_id are optional. When type=ALERT,
|
|
98
|
+
alert_similarity_id is required.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
bool: True if the API returned a 2xx status. Response body
|
|
102
|
+
is plain-text "OK" on success.
|
|
103
|
+
"""
|
|
104
|
+
response = self.api_client.call_api(
|
|
105
|
+
method="POST", url=f"{self.base_url}/changelog",
|
|
106
|
+
json=changelog.to_dict(),
|
|
107
|
+
)
|
|
108
|
+
return 200 <= response.status_code < 300
|
|
109
|
+
|
|
110
|
+
def get_result_info(self, result_id: str, scan_id: str) -> DastResultDetail:
|
|
111
|
+
"""GET /results/info/{result_id}/{scan_id} — detailed info about
|
|
112
|
+
a specific result.
|
|
113
|
+
|
|
114
|
+
Doc shows the response wrapped as {"results": {...}}, but live
|
|
115
|
+
returns the fields at the top level. Unwraps defensively in
|
|
116
|
+
case the API ever matches the doc.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
result_id (str): UUID of the result.
|
|
120
|
+
scan_id (str): UUID of the scan it belongs to.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
DastResultDetail
|
|
124
|
+
"""
|
|
125
|
+
response = self.api_client.call_api(
|
|
126
|
+
method="GET",
|
|
127
|
+
url=f"{self.base_url}/results/info/{result_id}/{scan_id}",
|
|
128
|
+
)
|
|
129
|
+
data = response.json()
|
|
130
|
+
# Doc says wrapped under "results"; live returns flat. Handle both.
|
|
131
|
+
if isinstance(data, dict) and isinstance(data.get("results"), dict):
|
|
132
|
+
data = data["results"]
|
|
133
|
+
return DastResultDetail.from_dict(data)
|
|
134
|
+
|
|
135
|
+
def get_results_count_by_group(
|
|
136
|
+
self,
|
|
137
|
+
scan_id: str,
|
|
138
|
+
group_by: List[DastResultsGroupBy] = None,
|
|
139
|
+
filter_: DastResultsFilter = None,
|
|
140
|
+
search: str = None,
|
|
141
|
+
) -> List[DastResultsGroupCount]:
|
|
142
|
+
"""GET /results/{scan_id}/group — count of results per group.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
scan_id (str): UUID of the scan.
|
|
146
|
+
group_by (list of DastResultsGroupBy, optional): columns to
|
|
147
|
+
group by. The wire param is `group` (singular) — this
|
|
148
|
+
SDK uses `group_by` for consistency with sibling
|
|
149
|
+
endpoints.
|
|
150
|
+
filter_ (DastResultsFilter, optional): partial-match filter
|
|
151
|
+
(severity, name, method, status, state, url, path,
|
|
152
|
+
owasp). alert_similarity_id is on the shared DTO but
|
|
153
|
+
ignored by this endpoint.
|
|
154
|
+
search (str, optional): substring search.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
list of DastResultsGroupCount. Each bucket has `count` and
|
|
158
|
+
`group` (a list of values — one entry per group_by column
|
|
159
|
+
in the order they were requested).
|
|
160
|
+
"""
|
|
161
|
+
params = {
|
|
162
|
+
"group": (
|
|
163
|
+
[g.value if isinstance(g, DastResultsGroupBy) else g for g in group_by]
|
|
164
|
+
if group_by else None
|
|
165
|
+
),
|
|
166
|
+
"search": search,
|
|
167
|
+
}
|
|
168
|
+
params.update(_flatten_filter("filter", filter_))
|
|
169
|
+
response = self.api_client.call_api(
|
|
170
|
+
method="GET", url=f"{self.base_url}/results/{scan_id}/group",
|
|
171
|
+
params=params,
|
|
172
|
+
)
|
|
173
|
+
return [DastResultsGroupCount.from_dict(b) for b in (response.json() or [])]
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# ----- Module-level conveniences -----
|
|
177
|
+
|
|
178
|
+
def get_results(
|
|
179
|
+
scan_id: str,
|
|
180
|
+
filter_: DastResultsFilter = None,
|
|
181
|
+
page: int = None,
|
|
182
|
+
per_page: int = None,
|
|
183
|
+
search: str = None,
|
|
184
|
+
sort_by: List[DastResultsSortBy] = None,
|
|
185
|
+
group: str = None,
|
|
186
|
+
) -> DastResultsCollection:
|
|
187
|
+
return DastResultsAPI().get_results(
|
|
188
|
+
scan_id=scan_id, filter_=filter_, page=page, per_page=per_page,
|
|
189
|
+
search=search, sort_by=sort_by, group=group,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def update_results(changelog: DastResultsChangelogInput) -> bool:
|
|
194
|
+
return DastResultsAPI().update_results(changelog=changelog)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def get_result_info(result_id: str, scan_id: str) -> DastResultDetail:
|
|
198
|
+
return DastResultsAPI().get_result_info(result_id=result_id, scan_id=scan_id)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def get_results_count_by_group(
|
|
202
|
+
scan_id: str,
|
|
203
|
+
group_by: List[DastResultsGroupBy] = None,
|
|
204
|
+
filter_: DastResultsFilter = None,
|
|
205
|
+
search: str = None,
|
|
206
|
+
) -> List[DastResultsGroupCount]:
|
|
207
|
+
return DastResultsAPI().get_results_count_by_group(
|
|
208
|
+
scan_id=scan_id, group_by=group_by, filter_=filter_, search=search,
|
|
209
|
+
)
|