CheckmarxPythonSDK 1.8.7__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.
Files changed (45) hide show
  1. CheckmarxPythonSDK/CxOne/__init__.py +54 -10
  2. CheckmarxPythonSDK/CxOne/aiTriageAndRemediationAPI.py +294 -0
  3. CheckmarxPythonSDK/CxOne/applicationsAPI.py +3 -1
  4. CheckmarxPythonSDK/CxOne/dto/AiTrProcessResult.py +40 -0
  5. CheckmarxPythonSDK/CxOne/dto/AiTrProcessStatusResponse.py +33 -0
  6. CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerRequest.py +17 -0
  7. CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerResponse.py +23 -0
  8. CheckmarxPythonSDK/CxOne/dto/AiTriageVulnerability.py +25 -0
  9. CheckmarxPythonSDK/CxOne/dto/CommentJSON.py +12 -0
  10. CheckmarxPythonSDK/CxOne/dto/PackageAction.py +27 -0
  11. CheckmarxPythonSDK/CxOne/dto/PackageActionValue.py +20 -0
  12. CheckmarxPythonSDK/CxOne/dto/PredicateHistory.py +23 -3
  13. CheckmarxPythonSDK/CxOne/dto/PredicateHistoryResponse.py +25 -0
  14. CheckmarxPythonSDK/CxOne/dto/PredicateInitialValues.py +14 -0
  15. CheckmarxPythonSDK/CxOne/dto/PredicateWithCommentJSON.py +18 -0
  16. CheckmarxPythonSDK/CxOne/dto/ScaProjectWithConfigurations.py +31 -0
  17. CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfigRequest.py +21 -0
  18. CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfigResponse.py +21 -0
  19. CheckmarxPythonSDK/CxOne/dto/ScaRegistryConfiguration.py +44 -0
  20. CheckmarxPythonSDK/CxOne/dto/ScaTagWithConfigurations.py +35 -0
  21. CheckmarxPythonSDK/CxOne/dto/SupplyChainRiskAction.py +27 -0
  22. CheckmarxPythonSDK/CxOne/dto/UpdatePackageStateBulkRequest.py +39 -0
  23. CheckmarxPythonSDK/CxOne/dto/UpdatePackageStateRequest.py +37 -0
  24. CheckmarxPythonSDK/CxOne/dto/UpdateSupplyChainRiskRequest.py +34 -0
  25. CheckmarxPythonSDK/CxOne/dto/UpdateSupplyChainRisksBulkRequest.py +44 -0
  26. CheckmarxPythonSDK/CxOne/dto/UpdateVulnerabilitiesBulkRequest.py +44 -0
  27. CheckmarxPythonSDK/CxOne/dto/UpdateVulnerabilityRequest.py +31 -0
  28. CheckmarxPythonSDK/CxOne/dto/__init__.py +54 -0
  29. CheckmarxPythonSDK/CxOne/sastQueriesAPI.py +12 -3
  30. CheckmarxPythonSDK/CxOne/sastResultsPredicatesAPI.py +21 -9
  31. CheckmarxPythonSDK/CxOne/scaManagementOfRiskAPI.py +380 -0
  32. CheckmarxPythonSDK/CxOne/scaPrivateRegistryConfigAPI.py +843 -0
  33. CheckmarxPythonSDK/CxPortalSoapApiSDK/CxAuditWebService.py +511 -0
  34. CheckmarxPythonSDK/CxPortalSoapApiSDK/CxPortalWebService.py +1074 -5
  35. CheckmarxPythonSDK/CxPortalSoapApiSDK/__init__.py +75 -7
  36. CheckmarxPythonSDK/CxRestAPISDK/ProjectsAPI.py +21 -2
  37. CheckmarxPythonSDK/CxRestAPISDK/ScansAPI.py +41 -0
  38. CheckmarxPythonSDK/__version__.py +1 -1
  39. CheckmarxPythonSDK/api_client.py +9 -4
  40. {checkmarxpythonsdk-1.8.7.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/METADATA +1 -1
  41. {checkmarxpythonsdk-1.8.7.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/RECORD +44 -21
  42. {checkmarxpythonsdk-1.8.7.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/WHEEL +1 -1
  43. CheckmarxPythonSDK/CxOne/sastPresetManagerAPI.py +0 -261
  44. {checkmarxpythonsdk-1.8.7.dist-info → checkmarxpythonsdk-1.8.9.dist-info}/licenses/LICENSE +0 -0
  45. {checkmarxpythonsdk-1.8.7.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,
@@ -367,16 +374,16 @@ from .projectsOverviewAPI import (
367
374
  get_tenant_projects_overview,
368
375
  get_project_counters,
369
376
  )
370
- from .sastPresetManagerAPI import (
371
- SastPresetManagerAPI,
372
- get_sast_presets,
373
- get_sast_preset_by_id,
374
- create_sast_preset,
375
- update_sast_preset,
376
- delete_sast_preset,
377
- clone_sast_preset,
378
- get_sast_query_families,
379
- get_sast_queries_by_family,
377
+ from .presetManagerAPI import (
378
+ PresetManagerAPI,
379
+ get_scanner_presets,
380
+ get_scanner_preset_by_id,
381
+ create_scanner_preset,
382
+ update_scanner_preset,
383
+ delete_scanner_preset,
384
+ clone_scanner_preset,
385
+ get_scanner_query_families,
386
+ get_scanner_queries_by_family,
380
387
  )
381
388
  from .queryEditorAPI import (
382
389
  QueryEditorAPI,
@@ -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
- return applications[0].id
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}
@@ -8,3 +8,15 @@ class CommentJSON:
8
8
  user: str = None
9
9
  content: str = None
10
10
  is_deleted: bool = None
11
+
12
+ @classmethod
13
+ def from_dict(cls, item: dict) -> "CommentJSON":
14
+ if not item:
15
+ return None
16
+ return cls(
17
+ id=item.get("id"),
18
+ date=item.get("date"),
19
+ user=item.get("user"),
20
+ content=item.get("content"),
21
+ is_deleted=item.get("isDeleted", False),
22
+ )
@@ -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}
@@ -1,12 +1,32 @@
1
- from dataclasses import dataclass
1
+ from dataclasses import dataclass, field
2
2
  from typing import List
3
+
4
+ from .PredicateInitialValues import PredicateInitialValues
3
5
  from .PredicateWithCommentJSON import PredicateWithCommentJSON
4
6
 
5
7
 
6
8
  @dataclass
7
9
  class PredicateHistory:
8
-
10
+ """Predicates for one similarity ID within one project."""
9
11
  similarity_id: str = None
10
12
  project_id: str = None
11
- predicates: List[PredicateWithCommentJSON] = None
13
+ predicates: List[PredicateWithCommentJSON] = field(default_factory=list)
12
14
  total_count: int = None
15
+ initial_predicate_values: PredicateInitialValues = None
16
+
17
+ @classmethod
18
+ def from_dict(cls, item: dict) -> "PredicateHistory":
19
+ if not item:
20
+ return None
21
+ return cls(
22
+ similarity_id=item.get("similarityId"),
23
+ project_id=item.get("projectId"),
24
+ predicates=[
25
+ PredicateWithCommentJSON.from_dict(p)
26
+ for p in (item.get("predicates") or [])
27
+ ],
28
+ total_count=item.get("totalCount"),
29
+ initial_predicate_values=PredicateInitialValues.from_dict(
30
+ item.get("initialPredicateValues")
31
+ ),
32
+ )
@@ -0,0 +1,25 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import List
3
+
4
+ from .PredicateHistory import PredicateHistory
5
+
6
+
7
+ @dataclass
8
+ class PredicateHistoryResponse:
9
+ """Full response from GET /sast-results-predicates/{similarityId}
10
+ and GET /sast-results-predicates/{similarityId}/latest."""
11
+
12
+ predicate_history_per_project: List[PredicateHistory] = field(default_factory=list)
13
+ total_count: int = 0
14
+
15
+ @classmethod
16
+ def from_dict(cls, item: dict) -> "PredicateHistoryResponse":
17
+ if not item:
18
+ return None
19
+ return cls(
20
+ predicate_history_per_project=[
21
+ PredicateHistory.from_dict(p)
22
+ for p in (item.get("predicateHistoryPerProject") or [])
23
+ ],
24
+ total_count=item.get("totalCount", 0),
25
+ )
@@ -0,0 +1,14 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class PredicateInitialValues:
6
+ """Initial state/severity before triage."""
7
+ state: str = None
8
+ severity: str = None
9
+
10
+ @classmethod
11
+ def from_dict(cls, item: dict) -> "PredicateInitialValues":
12
+ if not item:
13
+ return None
14
+ return cls(state=item.get("state"), severity=item.get("severity"))