CheckmarxPythonSDK 1.8.8__py3-none-any.whl → 1.8.9__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 +44 -0
- CheckmarxPythonSDK/CxOne/aiTriageAndRemediationAPI.py +294 -0
- CheckmarxPythonSDK/CxOne/applicationsAPI.py +3 -1
- CheckmarxPythonSDK/CxOne/dto/AiTrProcessResult.py +40 -0
- CheckmarxPythonSDK/CxOne/dto/AiTrProcessStatusResponse.py +33 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerRequest.py +17 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerResponse.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageVulnerability.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/PackageAction.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/PackageActionValue.py +20 -0
- CheckmarxPythonSDK/CxOne/dto/ScaProjectWithConfigurations.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfigRequest.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfigResponse.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfiguration.py +44 -0
- CheckmarxPythonSDK/CxOne/dto/ScaTagWithConfigurations.py +35 -0
- CheckmarxPythonSDK/CxOne/dto/SupplyChainRiskAction.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/UpdatePackageStateBulkRequest.py +39 -0
- CheckmarxPythonSDK/CxOne/dto/UpdatePackageStateRequest.py +37 -0
- CheckmarxPythonSDK/CxOne/dto/UpdateSupplyChainRiskRequest.py +34 -0
- CheckmarxPythonSDK/CxOne/dto/UpdateSupplyChainRisksBulkRequest.py +44 -0
- CheckmarxPythonSDK/CxOne/dto/UpdateVulnerabilitiesBulkRequest.py +44 -0
- CheckmarxPythonSDK/CxOne/dto/UpdateVulnerabilityRequest.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/__init__.py +52 -0
- CheckmarxPythonSDK/CxOne/scaManagementOfRiskAPI.py +380 -0
- CheckmarxPythonSDK/CxOne/scaPrivateRegistryConfigAPI.py +843 -0
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +3 -4
- {checkmarxpythonsdk-1.8.8.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.8.8.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/RECORD +32 -10
- {checkmarxpythonsdk-1.8.8.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/WHEEL +1 -1
- {checkmarxpythonsdk-1.8.8.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.8.8.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/top_level.txt +0 -0
|
@@ -46,6 +46,13 @@ from .aiAssetsAPI import (
|
|
|
46
46
|
get_asset_risks,
|
|
47
47
|
)
|
|
48
48
|
|
|
49
|
+
from .aiTriageAndRemediationAPI import (
|
|
50
|
+
AiTriageAndRemediationAPI,
|
|
51
|
+
retrieve_process_status,
|
|
52
|
+
trigger_ai_triage,
|
|
53
|
+
trigger_ai_remediation,
|
|
54
|
+
)
|
|
55
|
+
|
|
49
56
|
from .accessManagementAPI import (
|
|
50
57
|
AccessManagementAPI,
|
|
51
58
|
create_an_assignment,
|
|
@@ -585,6 +592,43 @@ from .scanConfigurationAPI import (
|
|
|
585
592
|
update_project_token,
|
|
586
593
|
)
|
|
587
594
|
|
|
595
|
+
from .scaPrivateRegistryConfigAPI import (
|
|
596
|
+
ScaPrivateRegistryConfigAPI,
|
|
597
|
+
get_all_configurations,
|
|
598
|
+
create_configuration,
|
|
599
|
+
get_configuration,
|
|
600
|
+
delete_configuration,
|
|
601
|
+
update_configuration,
|
|
602
|
+
get_project_configurations,
|
|
603
|
+
associate_configurations_with_project,
|
|
604
|
+
disassociate_configurations_from_project,
|
|
605
|
+
get_configurations_by_tag,
|
|
606
|
+
associate_configurations_with_tag,
|
|
607
|
+
disassociate_configurations_from_tag,
|
|
608
|
+
get_projects_with_configurations,
|
|
609
|
+
get_projects_by_configuration,
|
|
610
|
+
disassociate_all_projects_from_configuration,
|
|
611
|
+
associate_projects_with_configuration,
|
|
612
|
+
get_tags_with_configurations,
|
|
613
|
+
create_tag,
|
|
614
|
+
get_tag,
|
|
615
|
+
update_tag,
|
|
616
|
+
delete_tag,
|
|
617
|
+
get_tags_by_configuration,
|
|
618
|
+
associate_tags_with_configuration,
|
|
619
|
+
disassociate_all_tags_from_configuration,
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
from .scaManagementOfRiskAPI import (
|
|
623
|
+
ScaManagementOfRiskAPI,
|
|
624
|
+
update_package_state,
|
|
625
|
+
update_package_state_bulk,
|
|
626
|
+
update_supply_chain_risk,
|
|
627
|
+
update_supply_chain_risks_bulk,
|
|
628
|
+
update_vulnerability,
|
|
629
|
+
update_vulnerabilities_bulk,
|
|
630
|
+
)
|
|
631
|
+
|
|
588
632
|
from .scannersResultsAPI import (
|
|
589
633
|
ScannersResultsAPI,
|
|
590
634
|
get_all_scanners_results_by_scan_id,
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
from CheckmarxPythonSDK.api_client import ApiClient
|
|
2
|
+
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
3
|
+
from .dto import (
|
|
4
|
+
AiTrProcessStatusResponse,
|
|
5
|
+
AiTriageTriggerRequest,
|
|
6
|
+
AiTriageTriggerResponse,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AiTriageAndRemediationAPI(object):
|
|
11
|
+
"""API client for the AI Triage & Remediation REST API.
|
|
12
|
+
|
|
13
|
+
These APIs extend the AI Triage & Remediation capability by enabling
|
|
14
|
+
programmatic triggering and status tracking for AI-driven vulnerability
|
|
15
|
+
triage and remediation workflows.
|
|
16
|
+
|
|
17
|
+
When a trigger request is submitted, the API returns a processId, which
|
|
18
|
+
can be used to track the status of the asynchronous process.
|
|
19
|
+
|
|
20
|
+
AI Triage updates the vulnerability risk state and records a changelog
|
|
21
|
+
with a comment. Currently supported for SAST and SCA scanners only.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, api_client: ApiClient = None):
|
|
25
|
+
if api_client is None:
|
|
26
|
+
configuration = construct_configuration()
|
|
27
|
+
api_client = ApiClient(configuration=configuration)
|
|
28
|
+
self.api_client = api_client
|
|
29
|
+
self.base_url = (
|
|
30
|
+
f"{self.api_client.configuration.server_base_url}/api/v1/ai-triage"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def trigger_ai_triage(
|
|
34
|
+
self, trigger_request: AiTriageTriggerRequest
|
|
35
|
+
) -> AiTriageTriggerResponse:
|
|
36
|
+
"""Trigger an AI Triage of one or more vulnerabilities identified in
|
|
37
|
+
your projects.
|
|
38
|
+
|
|
39
|
+
Returns a processId that can be used to track the status of the
|
|
40
|
+
request. Currently supported for SAST and SCA scanners only.
|
|
41
|
+
|
|
42
|
+
For SAST vulnerabilities, similarityId and attackVectorId are mutually
|
|
43
|
+
exclusive. Supplying both values in the same request item returns a
|
|
44
|
+
validation error.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
trigger_request (AiTriageTriggerRequest): Request body containing a
|
|
48
|
+
list of one or more vulnerabilities to triage. Each
|
|
49
|
+
vulnerability requires a projectId and either a similarityId
|
|
50
|
+
or attackVectorId (for SAST).
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
AiTriageTriggerResponse: Response containing the processId
|
|
54
|
+
(unique identifier of the triggered AI Triage process) and
|
|
55
|
+
status (e.g. 'in_progress' or 'rejected').
|
|
56
|
+
|
|
57
|
+
Example:
|
|
58
|
+
from CheckmarxPythonSDK.CxOne.dto import (
|
|
59
|
+
AiTriageTriggerRequest,
|
|
60
|
+
AiTriageVulnerability,
|
|
61
|
+
)
|
|
62
|
+
from CheckmarxPythonSDK.CxOne.aiTriageAndRemediationAPI import AiTriageAndRemediationAPI
|
|
63
|
+
|
|
64
|
+
request = AiTriageTriggerRequest(
|
|
65
|
+
vulnerabilities=[
|
|
66
|
+
AiTriageVulnerability(
|
|
67
|
+
projectId="my-project-id",
|
|
68
|
+
similarityId="my-similarity-id",
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
response = AiTriageAndRemediationAPI().trigger_ai_triage(request)
|
|
73
|
+
print(response.processId)
|
|
74
|
+
"""
|
|
75
|
+
url = f"{self.base_url}/trigger"
|
|
76
|
+
response = self.api_client.call_api(
|
|
77
|
+
method="POST",
|
|
78
|
+
url=url,
|
|
79
|
+
json={
|
|
80
|
+
"vulnerabilities": [
|
|
81
|
+
v.to_dict() for v in trigger_request.vulnerabilities
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
)
|
|
85
|
+
return AiTriageTriggerResponse.from_dict(response.json())
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def trigger_ai_remediation(
|
|
89
|
+
self, trigger_request: AiTriageTriggerRequest
|
|
90
|
+
) -> AiTriageTriggerResponse:
|
|
91
|
+
"""Trigger an AI Remediation of one or more vulnerabilities identified in
|
|
92
|
+
your projects.
|
|
93
|
+
|
|
94
|
+
AI Remediation first runs AI Triage and then, when applicable, opens a
|
|
95
|
+
pull request with the suggested remediation. For manual projects, the
|
|
96
|
+
remediation workflow updates the RO table without opening a pull request.
|
|
97
|
+
|
|
98
|
+
Returns a processId that can be used to track the status of the request.
|
|
99
|
+
Currently supported for SAST and SCA scanners only.
|
|
100
|
+
|
|
101
|
+
For SAST vulnerabilities, similarityId and attackVectorId are mutually
|
|
102
|
+
exclusive. Supplying both values in the same request item returns a
|
|
103
|
+
validation error.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
trigger_request (AiTriageTriggerRequest): Request body containing a
|
|
107
|
+
list of one or more vulnerabilities to remediate. Each
|
|
108
|
+
vulnerability requires a projectId and either a similarityId
|
|
109
|
+
or attackVectorId (for SAST).
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
AiTriageTriggerResponse: Response containing the processId
|
|
113
|
+
(unique identifier of the triggered AI Remediation process) and
|
|
114
|
+
status (e.g. 'in_progress' or 'rejected').
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
from CheckmarxPythonSDK.CxOne.dto import (
|
|
118
|
+
AiTriageTriggerRequest,
|
|
119
|
+
AiTriageVulnerability,
|
|
120
|
+
)
|
|
121
|
+
from CheckmarxPythonSDK.CxOne.aiTriageAndRemediationAPI import AiTriageAndRemediationAPI
|
|
122
|
+
|
|
123
|
+
request = AiTriageTriggerRequest(
|
|
124
|
+
vulnerabilities=[
|
|
125
|
+
AiTriageVulnerability(
|
|
126
|
+
projectId="my-project-id",
|
|
127
|
+
similarityId="my-similarity-id",
|
|
128
|
+
)
|
|
129
|
+
]
|
|
130
|
+
)
|
|
131
|
+
response = AiTriageAndRemediationAPI().trigger_ai_remediation(request)
|
|
132
|
+
print(response.processId)
|
|
133
|
+
"""
|
|
134
|
+
url = f"{self.api_client.configuration.server_base_url}/api/v1/ai-remediation/trigger"
|
|
135
|
+
response = self.api_client.call_api(
|
|
136
|
+
method="POST",
|
|
137
|
+
url=url,
|
|
138
|
+
json={
|
|
139
|
+
"vulnerabilities": [
|
|
140
|
+
v.to_dict() for v in trigger_request.vulnerabilities
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
)
|
|
144
|
+
return AiTriageTriggerResponse.from_dict(response.json())
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def retrieve_process_status(
|
|
148
|
+
self, process_id: str
|
|
149
|
+
) -> AiTrProcessStatusResponse:
|
|
150
|
+
"""Retrieve the status of a triggered AI Triage or Remediation process.
|
|
151
|
+
|
|
152
|
+
Returns the overall batch status and per-vulnerability status results.
|
|
153
|
+
Use this to poll for completion after triggering a process with
|
|
154
|
+
trigger_ai_triage or trigger_ai_remediation.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
process_id (str): Unique identifier of the triggered process,
|
|
158
|
+
returned by trigger_ai_triage or trigger_ai_remediation.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
AiTrProcessStatusResponse: Response containing the overall process
|
|
162
|
+
status (e.g. 'in_progress', 'completed', 'completed_with_errors',
|
|
163
|
+
'failed') and per-vulnerability results.
|
|
164
|
+
|
|
165
|
+
Example:
|
|
166
|
+
from CheckmarxPythonSDK.CxOne.aiTriageAndRemediationAPI import AiTriageAndRemediationAPI
|
|
167
|
+
|
|
168
|
+
status = AiTriageAndRemediationAPI().retrieve_process_status(
|
|
169
|
+
process_id="my-process-id"
|
|
170
|
+
)
|
|
171
|
+
print(status.status) # e.g. 'completed'
|
|
172
|
+
for r in status.results:
|
|
173
|
+
print(r.status, r.error) # per-vulnerability status
|
|
174
|
+
"""
|
|
175
|
+
url = f"{self.api_client.configuration.server_base_url}/api/v1/ai-tr/process/{process_id}"
|
|
176
|
+
response = self.api_client.call_api(method="GET", url=url)
|
|
177
|
+
return AiTrProcessStatusResponse.from_dict(response.json())
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def trigger_ai_triage(trigger_request: AiTriageTriggerRequest) -> AiTriageTriggerResponse:
|
|
181
|
+
"""Trigger an AI Triage of one or more vulnerabilities identified in your
|
|
182
|
+
projects.
|
|
183
|
+
|
|
184
|
+
Returns a processId that can be used to track the status of the request.
|
|
185
|
+
Currently supported for SAST and SCA scanners only.
|
|
186
|
+
|
|
187
|
+
For SAST vulnerabilities, similarityId and attackVectorId are mutually
|
|
188
|
+
exclusive. Supplying both values in the same request item returns a
|
|
189
|
+
validation error.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
trigger_request (AiTriageTriggerRequest): Request body containing a
|
|
193
|
+
list of one or more vulnerabilities to triage. Each vulnerability
|
|
194
|
+
requires a projectId and either a similarityId or attackVectorId
|
|
195
|
+
(for SAST).
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
AiTriageTriggerResponse: Response containing the processId (unique
|
|
199
|
+
identifier of the triggered AI Triage process) and status
|
|
200
|
+
(e.g. 'in_progress' or 'rejected').
|
|
201
|
+
|
|
202
|
+
Example:
|
|
203
|
+
from CheckmarxPythonSDK.CxOne.dto import (
|
|
204
|
+
AiTriageTriggerRequest,
|
|
205
|
+
AiTriageVulnerability,
|
|
206
|
+
)
|
|
207
|
+
from CheckmarxPythonSDK.CxOne import trigger_ai_triage
|
|
208
|
+
|
|
209
|
+
request = AiTriageTriggerRequest(
|
|
210
|
+
vulnerabilities=[
|
|
211
|
+
AiTriageVulnerability(
|
|
212
|
+
projectId="my-project-id",
|
|
213
|
+
similarityId="my-similarity-id",
|
|
214
|
+
)
|
|
215
|
+
]
|
|
216
|
+
)
|
|
217
|
+
response = trigger_ai_triage(request)
|
|
218
|
+
print(response.processId)
|
|
219
|
+
"""
|
|
220
|
+
return AiTriageAndRemediationAPI().trigger_ai_triage(trigger_request)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def trigger_ai_remediation(trigger_request: AiTriageTriggerRequest) -> AiTriageTriggerResponse:
|
|
224
|
+
"""Trigger an AI Remediation of one or more vulnerabilities identified in
|
|
225
|
+
your projects.
|
|
226
|
+
|
|
227
|
+
AI Remediation first runs AI Triage and then, when applicable, opens a
|
|
228
|
+
pull request with the suggested remediation. For manual projects, the
|
|
229
|
+
remediation workflow updates the RO table without opening a pull request.
|
|
230
|
+
|
|
231
|
+
Returns a processId that can be used to track the status of the request.
|
|
232
|
+
Currently supported for SAST and SCA scanners only.
|
|
233
|
+
|
|
234
|
+
For SAST vulnerabilities, similarityId and attackVectorId are mutually
|
|
235
|
+
exclusive. Supplying both values in the same request item returns a
|
|
236
|
+
validation error.
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
trigger_request (AiTriageTriggerRequest): Request body containing a
|
|
240
|
+
list of one or more vulnerabilities to remediate. Each
|
|
241
|
+
vulnerability requires a projectId and either a similarityId
|
|
242
|
+
or attackVectorId (for SAST).
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
AiTriageTriggerResponse: Response containing the processId (unique
|
|
246
|
+
identifier of the triggered AI Remediation process) and status
|
|
247
|
+
(e.g. 'in_progress' or 'rejected').
|
|
248
|
+
|
|
249
|
+
Example:
|
|
250
|
+
from CheckmarxPythonSDK.CxOne.dto import (
|
|
251
|
+
AiTriageTriggerRequest,
|
|
252
|
+
AiTriageVulnerability,
|
|
253
|
+
)
|
|
254
|
+
from CheckmarxPythonSDK.CxOne import trigger_ai_remediation
|
|
255
|
+
|
|
256
|
+
request = AiTriageTriggerRequest(
|
|
257
|
+
vulnerabilities=[
|
|
258
|
+
AiTriageVulnerability(
|
|
259
|
+
projectId="my-project-id",
|
|
260
|
+
similarityId="my-similarity-id",
|
|
261
|
+
)
|
|
262
|
+
]
|
|
263
|
+
)
|
|
264
|
+
response = trigger_ai_remediation(request)
|
|
265
|
+
print(response.processId)
|
|
266
|
+
"""
|
|
267
|
+
return AiTriageAndRemediationAPI().trigger_ai_remediation(trigger_request)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def retrieve_process_status(process_id: str) -> AiTrProcessStatusResponse:
|
|
271
|
+
"""Retrieve the status of a triggered AI Triage or Remediation process.
|
|
272
|
+
|
|
273
|
+
Returns the overall batch status and per-vulnerability status results.
|
|
274
|
+
Use this to poll for completion after triggering a process with
|
|
275
|
+
trigger_ai_triage or trigger_ai_remediation.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
process_id (str): Unique identifier of the triggered process, returned
|
|
279
|
+
by trigger_ai_triage or trigger_ai_remediation.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
AiTrProcessStatusResponse: Response containing the overall process
|
|
283
|
+
status (e.g. 'in_progress', 'completed', 'completed_with_errors',
|
|
284
|
+
'failed') and per-vulnerability results.
|
|
285
|
+
|
|
286
|
+
Example:
|
|
287
|
+
from CheckmarxPythonSDK.CxOne import retrieve_process_status
|
|
288
|
+
|
|
289
|
+
status = retrieve_process_status(process_id="my-process-id")
|
|
290
|
+
print(status.status) # e.g. 'completed'
|
|
291
|
+
for r in status.results:
|
|
292
|
+
print(r.status, r.error) # per-vulnerability status
|
|
293
|
+
"""
|
|
294
|
+
return AiTriageAndRemediationAPI().retrieve_process_status(process_id)
|
|
@@ -85,7 +85,9 @@ class ApplicationsAPI(object):
|
|
|
85
85
|
app_collection = self.get_a_list_of_applications(name=name)
|
|
86
86
|
applications = app_collection.applications
|
|
87
87
|
if applications:
|
|
88
|
-
|
|
88
|
+
for application in applications:
|
|
89
|
+
if application.name == name:
|
|
90
|
+
return application.id
|
|
89
91
|
return None
|
|
90
92
|
|
|
91
93
|
def get_all_application_tags(self) -> dict:
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from .AiTriageVulnerability import AiTriageVulnerability
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class AiTrProcessResult:
|
|
8
|
+
"""A single vulnerability result within a process status response.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
projectId (str): Unique identifier of the project associated with the
|
|
12
|
+
triggered process.
|
|
13
|
+
identifier (AiTriageVulnerability): The vulnerability identifier that
|
|
14
|
+
was submitted for the process.
|
|
15
|
+
status (str): Current status of the process for this vulnerability.
|
|
16
|
+
Allowed values: 'completed', 'failed'.
|
|
17
|
+
error (str or None): Error details if the process failed; otherwise
|
|
18
|
+
None.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
projectId: str = None
|
|
22
|
+
identifier: AiTriageVulnerability = None
|
|
23
|
+
status: str = None
|
|
24
|
+
error: str = None
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def from_dict(cls, item: dict) -> "AiTrProcessResult":
|
|
28
|
+
identifier = None
|
|
29
|
+
if item.get("identifier"):
|
|
30
|
+
identifier = AiTriageVulnerability(
|
|
31
|
+
projectId=item["identifier"].get("projectId"),
|
|
32
|
+
similarityId=item["identifier"].get("similarityId"),
|
|
33
|
+
attackVectorId=item["identifier"].get("attackVectorId"),
|
|
34
|
+
)
|
|
35
|
+
return cls(
|
|
36
|
+
projectId=item.get("projectId"),
|
|
37
|
+
identifier=identifier,
|
|
38
|
+
status=item.get("status"),
|
|
39
|
+
error=item.get("error"),
|
|
40
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .AiTrProcessResult import AiTrProcessResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AiTrProcessStatusResponse:
|
|
9
|
+
"""Response from GET /api/v1/ai-tr/process/{processId}.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
processId (str): Unique identifier of the triggered AI Triage or AI
|
|
13
|
+
Remediation process.
|
|
14
|
+
status (str): Overall status of the triggered process batch. Allowed
|
|
15
|
+
values: 'in_progress', 'completed', 'completed_with_errors',
|
|
16
|
+
'failed'.
|
|
17
|
+
results (List[AiTrProcessResult]): Per-vulnerability status results.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
processId: str = None
|
|
21
|
+
status: str = None
|
|
22
|
+
results: List[AiTrProcessResult] = field(default_factory=list)
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls, item: dict) -> "AiTrProcessStatusResponse":
|
|
26
|
+
return cls(
|
|
27
|
+
processId=item.get("processId"),
|
|
28
|
+
status=item.get("status"),
|
|
29
|
+
results=[
|
|
30
|
+
AiTrProcessResult.from_dict(r)
|
|
31
|
+
for r in item.get("results", [])
|
|
32
|
+
],
|
|
33
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .AiTriageVulnerability import AiTriageVulnerability
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AiTriageTriggerRequest:
|
|
9
|
+
"""Request body for POST /api/v1/ai-triage/trigger.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
vulnerabilities (List[AiTriageVulnerability]): One or more
|
|
13
|
+
vulnerabilities to triage. Currently supported for SAST and SCA
|
|
14
|
+
scanners only.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
vulnerabilities: List[AiTriageVulnerability] = field(default_factory=list)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class AiTriageTriggerResponse:
|
|
6
|
+
"""Response from POST /api/v1/ai-triage/trigger.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
processId (str): Unique identifier of the triggered AI Triage or AI
|
|
10
|
+
Remediation process.
|
|
11
|
+
status (str): Status of the triggered process. Allowed values:
|
|
12
|
+
'in_progress', 'rejected'.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
processId: str = None
|
|
16
|
+
status: str = None
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def from_dict(cls, item: dict) -> "AiTriageTriggerResponse":
|
|
20
|
+
return cls(
|
|
21
|
+
processId=item.get("processId"),
|
|
22
|
+
status=item.get("status"),
|
|
23
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from dataclasses import dataclass, asdict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class AiTriageVulnerability:
|
|
6
|
+
"""A single vulnerability to be triaged by AI Triage.
|
|
7
|
+
|
|
8
|
+
For SAST vulnerabilities, similarityId and attackVectorId are mutually
|
|
9
|
+
exclusive. Supplying both in the same request item returns a validation
|
|
10
|
+
error.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
projectId (str): Unique identifier of the project associated with the
|
|
14
|
+
finding.
|
|
15
|
+
similarityId (str): Unique identifier of the SAST vulnerability finding.
|
|
16
|
+
attackVectorId (str): Alternative SAST vulnerability identifier.
|
|
17
|
+
Mutually exclusive with similarityId.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
projectId: str
|
|
21
|
+
similarityId: str = None
|
|
22
|
+
attackVectorId: str = None
|
|
23
|
+
|
|
24
|
+
def to_dict(self):
|
|
25
|
+
return {k: v for k, v in asdict(self).items() if v is not None}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from dataclasses import dataclass, asdict
|
|
2
|
+
|
|
3
|
+
from .PackageActionValue import PackageActionValue
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class PackageAction:
|
|
8
|
+
"""An action to perform on a package (mute or snooze).
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
actionType (str): Type of action. Currently only 'Ignore' is
|
|
12
|
+
supported, used for muting and snoozing packages.
|
|
13
|
+
value (PackageActionValue): The value for this action, including
|
|
14
|
+
the state ('Ignore' or 'Snooze') and optional endDate.
|
|
15
|
+
comment (str): A comment explaining the rationale for this action.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
actionType: str
|
|
19
|
+
value: PackageActionValue
|
|
20
|
+
comment: str
|
|
21
|
+
|
|
22
|
+
def to_dict(self):
|
|
23
|
+
return {
|
|
24
|
+
"actionType": self.actionType,
|
|
25
|
+
"value": self.value.to_dict() if self.value else None,
|
|
26
|
+
"comment": self.comment,
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from dataclasses import dataclass, asdict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class PackageActionValue:
|
|
6
|
+
"""The value associated with a package action.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
state (str): The state to apply. 'Muted' ignores the package
|
|
10
|
+
indefinitely; 'Snooze' ignores until endDate; 'Monitored'
|
|
11
|
+
restores normal monitoring.
|
|
12
|
+
endDate (str): ISO-8601 timestamp marking the end of the snooze
|
|
13
|
+
period. Required when state is 'Snooze'.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
state: str
|
|
17
|
+
endDate: str = None
|
|
18
|
+
|
|
19
|
+
def to_dict(self):
|
|
20
|
+
return {k: v for k, v in asdict(self).items() if v is not None}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .ScaRegistryConfiguration import ScaRegistryConfiguration
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class ScaProjectWithConfigurations:
|
|
9
|
+
"""A project with its associated private registry configurations.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
id (str): Unique identifier of the project.
|
|
13
|
+
tenantId (str): ID of the tenant account associated with this project.
|
|
14
|
+
configurations (List[ScaRegistryConfiguration]): Configurations
|
|
15
|
+
associated with this project.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
id: str = None
|
|
19
|
+
tenantId: str = None
|
|
20
|
+
configurations: List[ScaRegistryConfiguration] = field(default_factory=list)
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_dict(cls, item: dict) -> "ScaProjectWithConfigurations":
|
|
24
|
+
return cls(
|
|
25
|
+
id=item.get("id"),
|
|
26
|
+
tenantId=item.get("tenantId"),
|
|
27
|
+
configurations=[
|
|
28
|
+
ScaRegistryConfiguration.from_dict(c)
|
|
29
|
+
for c in item.get("configurations", [])
|
|
30
|
+
],
|
|
31
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dataclasses import dataclass, asdict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ScaRegistryConfigRequest:
|
|
6
|
+
"""Request body for creating a private registry configuration.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
configurationName (str): A name for the configuration.
|
|
10
|
+
content (str): The content of the configuration (XML for NuGet/Maven,
|
|
11
|
+
INI-style for NPM).
|
|
12
|
+
packageManager (str): The package manager of the repo associated with
|
|
13
|
+
this configuration (e.g. 'nuget', 'maven', 'npm').
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
configurationName: str
|
|
17
|
+
content: str
|
|
18
|
+
packageManager: str
|
|
19
|
+
|
|
20
|
+
def to_dict(self):
|
|
21
|
+
return {k: v for k, v in asdict(self).items() if v is not None}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ScaRegistryConfigResponse:
|
|
6
|
+
"""Response from creating a private registry configuration.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
id (str): Unique identifier of the created configuration.
|
|
10
|
+
message (str): Human-readable text describing the result.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
id: str = None
|
|
14
|
+
message: str = None
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_dict(cls, item: dict) -> "ScaRegistryConfigResponse":
|
|
18
|
+
return cls(
|
|
19
|
+
id=item.get("id"),
|
|
20
|
+
message=item.get("message"),
|
|
21
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class ScaRegistryConfiguration:
|
|
7
|
+
"""A private registry configuration for SCA.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
id (str): Unique identifier of this configuration.
|
|
11
|
+
configurationName (str): Name of this configuration.
|
|
12
|
+
tenantId (str): ID of the tenant account associated with this
|
|
13
|
+
configuration.
|
|
14
|
+
content (str): The content of this configuration (e.g. XML for NuGet
|
|
15
|
+
config, JSON for npmrc).
|
|
16
|
+
tags (List[dict]): Tags assigned to this configuration.
|
|
17
|
+
packageManager (str): The package manager of registry associated with
|
|
18
|
+
this configuration.
|
|
19
|
+
projects (List[dict]): The projects associated with this configuration.
|
|
20
|
+
lastUpdate (str): Last update of this configuration. ISO-8601 timestamp
|
|
21
|
+
in UTC.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
id: str = None
|
|
25
|
+
configurationName: str = None
|
|
26
|
+
tenantId: str = None
|
|
27
|
+
content: str = None
|
|
28
|
+
tags: List[dict] = field(default_factory=list)
|
|
29
|
+
packageManager: str = None
|
|
30
|
+
projects: List[dict] = field(default_factory=list)
|
|
31
|
+
lastUpdate: str = None
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_dict(cls, item: dict) -> "ScaRegistryConfiguration":
|
|
35
|
+
return cls(
|
|
36
|
+
id=item.get("id"),
|
|
37
|
+
configurationName=item.get("configurationName"),
|
|
38
|
+
tenantId=item.get("tenantId"),
|
|
39
|
+
content=item.get("content"),
|
|
40
|
+
tags=item.get("tags", []),
|
|
41
|
+
packageManager=item.get("packageManager"),
|
|
42
|
+
projects=item.get("projects", []),
|
|
43
|
+
lastUpdate=item.get("lastUpdate"),
|
|
44
|
+
)
|