CheckmarxPythonSDK 1.9.3__py3-none-any.whl → 1.9.4__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 +42 -0
- CheckmarxPythonSDK/CxOne/apisecAPI.py +184 -7
- CheckmarxPythonSDK/CxOne/dto/BreakBuildExemptStateDto.py +28 -0
- CheckmarxPythonSDK/CxOne/dto/EnhancedIncidentsPaginationDTO.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/EnhancedIncidentsWebDTO.py +52 -0
- CheckmarxPythonSDK/CxOne/dto/EvaluatedPolicyWebDto.py +34 -0
- CheckmarxPythonSDK/CxOne/dto/ExportParametersSbom.py +10 -0
- CheckmarxPythonSDK/CxOne/dto/ExportParametersScanReport.py +15 -0
- CheckmarxPythonSDK/CxOne/dto/FindingsWebDto.py +46 -0
- CheckmarxPythonSDK/CxOne/dto/IncidentResultWebDTO.py +64 -0
- CheckmarxPythonSDK/CxOne/dto/IncidentResultsDTO.py +36 -0
- CheckmarxPythonSDK/CxOne/dto/IncidentWebDto.py +47 -0
- CheckmarxPythonSDK/CxOne/dto/IncidentsPaginationDto.py +26 -0
- CheckmarxPythonSDK/CxOne/dto/PackageWebDto.py +45 -0
- CheckmarxPythonSDK/CxOne/dto/PoliciesPaginationDto.py +26 -0
- CheckmarxPythonSDK/CxOne/dto/PoliciesResultWebDto.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/PolicyShortWebDto.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/PolicyViolationWebDto.py +36 -0
- CheckmarxPythonSDK/CxOne/dto/PolicyWebDto.py +104 -0
- CheckmarxPythonSDK/CxOne/dto/ProjectWebDto.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/ProjectsInPolicyDto.py +38 -0
- CheckmarxPythonSDK/CxOne/dto/RuleViolatedWebDto.py +35 -0
- CheckmarxPythonSDK/CxOne/dto/ScaExportFileFormats.py +18 -0
- CheckmarxPythonSDK/CxOne/dto/ScaExportStatus.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/ViolatedPolicyWebDto.py +36 -0
- CheckmarxPythonSDK/CxOne/dto/ViolatingAssocProjectsWebDto.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/ViolationDetailsDTO.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/VulnerabilityWebDto.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/__init__.py +26 -0
- CheckmarxPythonSDK/CxOne/policyManagerAPI.py +765 -0
- CheckmarxPythonSDK/CxOne/projectsAPI.py +14 -15
- CheckmarxPythonSDK/CxOne/repoManagerAPI.py +12 -2
- CheckmarxPythonSDK/CxOne/reportAPI.py +286 -45
- CheckmarxPythonSDK/CxReporting/api.py +82 -10
- CheckmarxPythonSDK/CxRestAPISDK/ScansAPI.py +40 -2
- CheckmarxPythonSDK/CxScaApiSDK/api.py +52 -29
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +140 -5
- {checkmarxpythonsdk-1.9.3.dist-info → checkmarxpythonsdk-1.9.4.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.9.3.dist-info → checkmarxpythonsdk-1.9.4.dist-info}/RECORD +43 -16
- {checkmarxpythonsdk-1.9.3.dist-info → checkmarxpythonsdk-1.9.4.dist-info}/WHEEL +0 -0
- {checkmarxpythonsdk-1.9.3.dist-info → checkmarxpythonsdk-1.9.4.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.9.3.dist-info → checkmarxpythonsdk-1.9.4.dist-info}/top_level.txt +0 -0
|
@@ -63,6 +63,36 @@ from .riskOrchestrationAPI import (
|
|
|
63
63
|
get_risks_aggregate,
|
|
64
64
|
get_risks_ai_insights,
|
|
65
65
|
)
|
|
66
|
+
from .policyManagerAPI import (
|
|
67
|
+
PolicyManagerAPI,
|
|
68
|
+
get_tenant_policies,
|
|
69
|
+
create_policy,
|
|
70
|
+
delete_policies,
|
|
71
|
+
get_policy,
|
|
72
|
+
update_policy,
|
|
73
|
+
delete_policy,
|
|
74
|
+
get_policy_v2,
|
|
75
|
+
update_policy_v2,
|
|
76
|
+
get_tenant_policies_with_pagination,
|
|
77
|
+
create_policy_v2,
|
|
78
|
+
get_tenant_policies_with_pagination_v3,
|
|
79
|
+
get_default_policy,
|
|
80
|
+
assign_projects_to_policy,
|
|
81
|
+
delete_projects_from_policy,
|
|
82
|
+
pin_policy,
|
|
83
|
+
get_tenant_projects,
|
|
84
|
+
get_projects_tags,
|
|
85
|
+
get_policy_violations,
|
|
86
|
+
get_evaluated_policies_by_scan_id_and_project_id,
|
|
87
|
+
get_tenant_incidents,
|
|
88
|
+
get_tenant_incidents_total_count,
|
|
89
|
+
get_tenant_incidents_with_pagination,
|
|
90
|
+
get_tenant_incidents_with_pagination_and_filters,
|
|
91
|
+
get_enhanced_incidents_with_pagination_and_filters,
|
|
92
|
+
get_incident_results,
|
|
93
|
+
delete_data,
|
|
94
|
+
delete_data_for_service,
|
|
95
|
+
)
|
|
66
96
|
|
|
67
97
|
from .accessManagementAPI import (
|
|
68
98
|
AccessManagementAPI,
|
|
@@ -108,7 +138,16 @@ from .accessManagementAPI import (
|
|
|
108
138
|
)
|
|
109
139
|
from .apisecAPI import (
|
|
110
140
|
ApiSecAPI,
|
|
141
|
+
get_risk_summary_by_origin,
|
|
111
142
|
get_scan_apisec_risk_overview,
|
|
143
|
+
get_all_risk_types,
|
|
144
|
+
get_number_of_sensitive_data_apis,
|
|
145
|
+
get_number_of_undocumented_apis,
|
|
146
|
+
get_all_api_scan_metadata,
|
|
147
|
+
get_risk_detail_by_risk_id,
|
|
148
|
+
get_risk_complete,
|
|
149
|
+
get_api_security_risks_by_scan_id,
|
|
150
|
+
get_grouped_risk_summary,
|
|
112
151
|
get_api_parameters,
|
|
113
152
|
get_parameters,
|
|
114
153
|
)
|
|
@@ -443,7 +482,10 @@ from .reportAPI import (
|
|
|
443
482
|
get_report_status,
|
|
444
483
|
get_scan_report,
|
|
445
484
|
get_risk_scan_report,
|
|
485
|
+
get_sca_export_file_formats,
|
|
446
486
|
create_sca_scan_report,
|
|
487
|
+
get_sca_export_status,
|
|
488
|
+
download_sca_export,
|
|
447
489
|
get_sca_scan_report,
|
|
448
490
|
)
|
|
449
491
|
from .repositoryInsightsAPI import (
|
|
@@ -59,9 +59,14 @@ class ApiResponseParameter:
|
|
|
59
59
|
|
|
60
60
|
@dataclass
|
|
61
61
|
class ApiResponsePii:
|
|
62
|
+
"""An entry in Parameter.pii (wire key: "piis").
|
|
63
|
+
|
|
64
|
+
Confirmed live: `count` comes back as a string (e.g. "1"), not an
|
|
65
|
+
integer, despite the field name.
|
|
66
|
+
"""
|
|
62
67
|
name: str = None
|
|
63
68
|
location: str = None
|
|
64
|
-
count:
|
|
69
|
+
count: str = None
|
|
65
70
|
origin: List[str] = None
|
|
66
71
|
|
|
67
72
|
@classmethod
|
|
@@ -69,13 +74,19 @@ class ApiResponsePii:
|
|
|
69
74
|
return cls(
|
|
70
75
|
name=item.get("name"),
|
|
71
76
|
location=item.get("location"),
|
|
72
|
-
count=item.get("count"
|
|
77
|
+
count=item.get("count"),
|
|
73
78
|
origin=item.get("origin"),
|
|
74
79
|
)
|
|
75
80
|
|
|
76
81
|
|
|
77
82
|
@dataclass
|
|
78
83
|
class Parameter:
|
|
84
|
+
"""Response from GET /api/apisec/static/api/parameter/.
|
|
85
|
+
|
|
86
|
+
Confirmed live: the wire key for the PII summary is `piis`
|
|
87
|
+
(plural), not `pii` -- reading `pii` (the old, wrong key) silently
|
|
88
|
+
returned an empty list even when the server sent real PII data.
|
|
89
|
+
"""
|
|
79
90
|
request_parameters: List[ApiRequestParameter] = None
|
|
80
91
|
response_parameters: List[ApiResponseParameter] = None
|
|
81
92
|
pii: List[ApiResponsePii] = None
|
|
@@ -92,7 +103,7 @@ class Parameter:
|
|
|
92
103
|
ApiResponseParameter.from_dict(p)
|
|
93
104
|
for p in (item.get("response_parameters") or [])
|
|
94
105
|
],
|
|
95
|
-
pii=[ApiResponsePii.from_dict(p) for p in (item.get("
|
|
106
|
+
pii=[ApiResponsePii.from_dict(p) for p in (item.get("piis") or [])],
|
|
96
107
|
api_origins=item.get("api_origins"),
|
|
97
108
|
)
|
|
98
109
|
|
|
@@ -169,6 +180,66 @@ class Risk:
|
|
|
169
180
|
)
|
|
170
181
|
|
|
171
182
|
|
|
183
|
+
@dataclass
|
|
184
|
+
class RiskCompleteResponse:
|
|
185
|
+
"""Response from GET /api/risks/risk-orchestration/{scan_id}/{risk_id}
|
|
186
|
+
-- the union of Risk and RiskDetailResponse's fields in one call,
|
|
187
|
+
so callers don't need to make two separate requests."""
|
|
188
|
+
risk_id: str = None
|
|
189
|
+
api_id: str = None
|
|
190
|
+
severity: str = None
|
|
191
|
+
name: str = None
|
|
192
|
+
status: str = None
|
|
193
|
+
http_method: str = None
|
|
194
|
+
url: str = None
|
|
195
|
+
origin: str = None
|
|
196
|
+
documented: bool = None
|
|
197
|
+
authenticated: bool = None
|
|
198
|
+
discovery_date: str = None
|
|
199
|
+
scan_id: str = None
|
|
200
|
+
sast_risk_id: str = None
|
|
201
|
+
project_id: str = None
|
|
202
|
+
state: str = None
|
|
203
|
+
vulnerability: str = None
|
|
204
|
+
source_node: str = None
|
|
205
|
+
source_file: str = None
|
|
206
|
+
total_pii: int = None
|
|
207
|
+
line_number: int = None
|
|
208
|
+
description: str = None
|
|
209
|
+
actual_value: str = None
|
|
210
|
+
expected_value: str = None
|
|
211
|
+
similarity_id: str = None
|
|
212
|
+
|
|
213
|
+
@classmethod
|
|
214
|
+
def from_dict(cls, item: dict) -> "RiskCompleteResponse":
|
|
215
|
+
return cls(
|
|
216
|
+
risk_id=item.get("risk_id"),
|
|
217
|
+
api_id=item.get("api_id"),
|
|
218
|
+
severity=item.get("severity"),
|
|
219
|
+
name=item.get("name"),
|
|
220
|
+
status=item.get("status"),
|
|
221
|
+
http_method=item.get("http_method"),
|
|
222
|
+
url=item.get("url"),
|
|
223
|
+
origin=item.get("origin"),
|
|
224
|
+
documented=item.get("documented"),
|
|
225
|
+
authenticated=item.get("authenticated"),
|
|
226
|
+
discovery_date=item.get("discovery_date"),
|
|
227
|
+
scan_id=item.get("scan_id"),
|
|
228
|
+
sast_risk_id=item.get("sast_risk_id"),
|
|
229
|
+
project_id=item.get("project_id"),
|
|
230
|
+
state=item.get("state"),
|
|
231
|
+
vulnerability=item.get("vulnerability"),
|
|
232
|
+
source_node=item.get("source_node"),
|
|
233
|
+
source_file=item.get("source_file"),
|
|
234
|
+
total_pii=item.get("total_pii"),
|
|
235
|
+
line_number=item.get("line_number"),
|
|
236
|
+
description=item.get("description"),
|
|
237
|
+
actual_value=item.get("actual_value"),
|
|
238
|
+
expected_value=item.get("expected_value"),
|
|
239
|
+
similarity_id=item.get("similarity_id"),
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
|
|
172
243
|
@dataclass
|
|
173
244
|
class RiskResponse:
|
|
174
245
|
entries: List[Risk] = None
|
|
@@ -481,6 +552,12 @@ class ApiSecAPI(object):
|
|
|
481
552
|
Get the number of APIs identified in your source code that aren't
|
|
482
553
|
in your documentation, for a particular scan.
|
|
483
554
|
|
|
555
|
+
Confirmed live: `count` can come back as null (not just 0) --
|
|
556
|
+
observed on several scans, apparently meaning "not computed"
|
|
557
|
+
as distinct from "computed, zero found" (a different scan
|
|
558
|
+
returned a real 0). Despite the doc declaring `count` as a
|
|
559
|
+
plain (non-nullable) integer, treat it as optional.
|
|
560
|
+
|
|
484
561
|
Args:
|
|
485
562
|
scan_id (str)
|
|
486
563
|
|
|
@@ -516,6 +593,30 @@ class ApiSecAPI(object):
|
|
|
516
593
|
response = self.api_client.call_api(method="GET", url=url)
|
|
517
594
|
return RiskDetailResponse.from_dict(response.json())
|
|
518
595
|
|
|
596
|
+
def get_risk_complete(self, scan_id: str, risk_id: str) -> RiskCompleteResponse:
|
|
597
|
+
"""
|
|
598
|
+
Get a risk's summary and detailed information in a single
|
|
599
|
+
response -- the union of what get_api_security_risks_by_scan_id
|
|
600
|
+
and get_risk_detail_by_risk_id return, in one call.
|
|
601
|
+
|
|
602
|
+
Confirmed live: this undocumented endpoint returned a 500
|
|
603
|
+
Internal Server Error, consistently (reproduced twice), for a
|
|
604
|
+
valid scan_id/risk_id pair that get_api_security_risks_by_scan_id
|
|
605
|
+
itself returned successfully. Left as-is since there's no
|
|
606
|
+
documented contract to diagnose against; callers should be
|
|
607
|
+
prepared for this endpoint to be unreliable.
|
|
608
|
+
|
|
609
|
+
Args:
|
|
610
|
+
scan_id (str): Scan UUID
|
|
611
|
+
risk_id (str): Risk UUID
|
|
612
|
+
|
|
613
|
+
Returns:
|
|
614
|
+
RiskCompleteResponse
|
|
615
|
+
"""
|
|
616
|
+
url = f"{self.base_url}/risks/risk-orchestration/{scan_id}/{risk_id}"
|
|
617
|
+
response = self.api_client.call_api(method="GET", url=url)
|
|
618
|
+
return RiskCompleteResponse.from_dict(response.json())
|
|
619
|
+
|
|
519
620
|
def get_api_security_risks_by_scan_id(
|
|
520
621
|
self,
|
|
521
622
|
scan_id: str,
|
|
@@ -562,13 +663,21 @@ class ApiSecAPI(object):
|
|
|
562
663
|
page: int = None,
|
|
563
664
|
per_page: int = None,
|
|
564
665
|
searching: str = None,
|
|
565
|
-
|
|
666
|
+
sorting_order: str = None,
|
|
566
667
|
) -> GroupResponse:
|
|
567
668
|
"""
|
|
568
669
|
Get a summary of the number of API Security risks of each value for
|
|
569
670
|
the specified category (e.g., for severity, returns number of critical,
|
|
570
671
|
high, medium, low)
|
|
571
672
|
|
|
673
|
+
Confirmed live: the sort query param for this endpoint is
|
|
674
|
+
`sorting_order` (plain "asc"/"desc"), NOT `sorting` (the JSON
|
|
675
|
+
array-of-{column,order} string that the sibling
|
|
676
|
+
get_api_security_risks_by_scan_id endpoint uses) -- sending
|
|
677
|
+
`sorting` here doesn't just get ignored, it 500s the server
|
|
678
|
+
("Internal Server Error"). Previously this method sent
|
|
679
|
+
`sorting`, which would have crashed any caller who passed it.
|
|
680
|
+
|
|
572
681
|
Args:
|
|
573
682
|
scan_id (str):
|
|
574
683
|
group_column (str):
|
|
@@ -576,7 +685,7 @@ class ApiSecAPI(object):
|
|
|
576
685
|
page (int):
|
|
577
686
|
per_page (int):
|
|
578
687
|
searching (str):
|
|
579
|
-
|
|
688
|
+
sorting_order (str): "asc" or "desc".
|
|
580
689
|
|
|
581
690
|
Returns:
|
|
582
691
|
GroupResponse
|
|
@@ -587,20 +696,30 @@ class ApiSecAPI(object):
|
|
|
587
696
|
"page": page,
|
|
588
697
|
"per_page": per_page,
|
|
589
698
|
"searching": searching,
|
|
590
|
-
"
|
|
699
|
+
"sorting_order": sorting_order,
|
|
591
700
|
}
|
|
592
701
|
response = self.api_client.call_api(method="GET", url=url, params=params)
|
|
593
702
|
return GroupResponse.from_dict(response.json())
|
|
594
703
|
|
|
595
704
|
def get_api_parameters(self, api_id: str) -> Parameter:
|
|
596
705
|
"""
|
|
706
|
+
Get all parameters for the API.
|
|
707
|
+
|
|
708
|
+
Confirmed live: the previous URL (`{base_url}/risks/parameters`)
|
|
709
|
+
is wrong -- the server routes it to GET /risks/{scan_id} with
|
|
710
|
+
scan_id literally set to the string "parameters", which 400s
|
|
711
|
+
with "Invalid UUID value to scan_id: parameters". Fixed to hit
|
|
712
|
+
the documented GET /api/parameter/ endpoint (same one
|
|
713
|
+
get_parameters calls); kept as a separate method/function for
|
|
714
|
+
backward compatibility with existing callers.
|
|
715
|
+
|
|
597
716
|
Args:
|
|
598
717
|
api_id (str): Specify the unique identifier of the API
|
|
599
718
|
|
|
600
719
|
Returns:
|
|
601
720
|
Parameter
|
|
602
721
|
"""
|
|
603
|
-
url = f"{self.base_url}/
|
|
722
|
+
url = f"{self.base_url}/parameter/"
|
|
604
723
|
params = {"api_id": api_id}
|
|
605
724
|
response = self.api_client.call_api(method="GET", url=url, params=params)
|
|
606
725
|
return Parameter.from_dict(response.json())
|
|
@@ -621,10 +740,68 @@ class ApiSecAPI(object):
|
|
|
621
740
|
return Parameter.from_dict(response.json())
|
|
622
741
|
|
|
623
742
|
|
|
743
|
+
def get_risk_summary_by_origin(scan_id: str) -> ScanRisksOriginsResult:
|
|
744
|
+
return ApiSecAPI().get_risk_summary_by_origin(scan_id=scan_id)
|
|
745
|
+
|
|
746
|
+
|
|
624
747
|
def get_scan_apisec_risk_overview(scan_id: str) -> ApiSecRisksOverview:
|
|
625
748
|
return ApiSecAPI().get_scan_apisec_risk_overview(scan_id)
|
|
626
749
|
|
|
627
750
|
|
|
751
|
+
def get_all_risk_types(scan_id: str) -> RisksTypesResponse:
|
|
752
|
+
return ApiSecAPI().get_all_risk_types(scan_id=scan_id)
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
def get_number_of_sensitive_data_apis(scan_id: str) -> ScanSensitiveData:
|
|
756
|
+
return ApiSecAPI().get_number_of_sensitive_data_apis(scan_id=scan_id)
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def get_number_of_undocumented_apis(scan_id: str) -> ScanUndocumentedApis:
|
|
760
|
+
return ApiSecAPI().get_number_of_undocumented_apis(scan_id=scan_id)
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
def get_all_api_scan_metadata() -> List[ScanMetadataResponse]:
|
|
764
|
+
return ApiSecAPI().get_all_api_scan_metadata()
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
def get_risk_detail_by_risk_id(risk_id: str) -> RiskDetailResponse:
|
|
768
|
+
return ApiSecAPI().get_risk_detail_by_risk_id(risk_id=risk_id)
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def get_risk_complete(scan_id: str, risk_id: str) -> RiskCompleteResponse:
|
|
772
|
+
return ApiSecAPI().get_risk_complete(scan_id=scan_id, risk_id=risk_id)
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
def get_api_security_risks_by_scan_id(
|
|
776
|
+
scan_id: str,
|
|
777
|
+
filtering: str = None,
|
|
778
|
+
page: int = None,
|
|
779
|
+
per_page: int = None,
|
|
780
|
+
searching: str = None,
|
|
781
|
+
sorting: str = None,
|
|
782
|
+
) -> RiskResponse:
|
|
783
|
+
return ApiSecAPI().get_api_security_risks_by_scan_id(
|
|
784
|
+
scan_id=scan_id, filtering=filtering, page=page, per_page=per_page,
|
|
785
|
+
searching=searching, sorting=sorting,
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
def get_grouped_risk_summary(
|
|
790
|
+
scan_id: str,
|
|
791
|
+
group_column: str,
|
|
792
|
+
filtering: str = None,
|
|
793
|
+
page: int = None,
|
|
794
|
+
per_page: int = None,
|
|
795
|
+
searching: str = None,
|
|
796
|
+
sorting_order: str = None,
|
|
797
|
+
) -> GroupResponse:
|
|
798
|
+
return ApiSecAPI().get_grouped_risk_summary(
|
|
799
|
+
scan_id=scan_id, group_column=group_column, filtering=filtering,
|
|
800
|
+
page=page, per_page=per_page, searching=searching,
|
|
801
|
+
sorting_order=sorting_order,
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
|
|
628
805
|
def get_api_parameters(api_id: str) -> Parameter:
|
|
629
806
|
return ApiSecAPI().get_api_parameters(api_id=api_id)
|
|
630
807
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from dataclasses import dataclass, field, asdict
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class BreakBuildExemptStateDto:
|
|
7
|
+
"""A result state that is exempt from breaking the build for a rule.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
scanner (Optional[str]): The scanner the exemption applies to.
|
|
11
|
+
ruleName (Optional[str]): The policy rule the exemption applies to.
|
|
12
|
+
stateName (List[str]): Result states exempt from breaking the build.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
scanner: Optional[str] = None
|
|
16
|
+
ruleName: Optional[str] = None
|
|
17
|
+
stateName: List[str] = field(default_factory=list)
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_dict(cls, item: dict) -> "BreakBuildExemptStateDto":
|
|
21
|
+
return cls(
|
|
22
|
+
scanner=item.get("scanner"),
|
|
23
|
+
ruleName=item.get("ruleName"),
|
|
24
|
+
stateName=list(item.get("stateName") or []),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def to_dict(self) -> dict:
|
|
28
|
+
return {k: v for k, v in asdict(self).items() if v is not None}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from .EnhancedIncidentsWebDTO import EnhancedIncidentsWebDTO
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class EnhancedIncidentsPaginationDTO:
|
|
9
|
+
"""Paginated response from GET /incidents/filters/v2.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
incidents (List[EnhancedIncidentsWebDTO]): Incidents on the current page.
|
|
13
|
+
filteredIncidentsCount (Optional[int]): Total count after filtering.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
incidents: List[EnhancedIncidentsWebDTO] = field(default_factory=list)
|
|
17
|
+
filteredIncidentsCount: Optional[int] = None
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_dict(cls, item: dict) -> "EnhancedIncidentsPaginationDTO":
|
|
21
|
+
return cls(
|
|
22
|
+
incidents=[
|
|
23
|
+
EnhancedIncidentsWebDTO.from_dict(i)
|
|
24
|
+
for i in (item.get("incidents") or [])
|
|
25
|
+
],
|
|
26
|
+
filteredIncidentsCount=item.get("filteredIncidentsCount"),
|
|
27
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class EnhancedIncidentsWebDTO:
|
|
7
|
+
"""A policy incident, as returned by the enhanced (v2) incidents endpoint.
|
|
8
|
+
|
|
9
|
+
Same shape as IncidentWebDto plus the originating scanner engine.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
id (Optional[int]): Incident ID.
|
|
13
|
+
policyName (Optional[str]): Name of the violated policy.
|
|
14
|
+
projectName (Optional[str]): Name of the project scanned.
|
|
15
|
+
branch (Optional[str]): Branch scanned.
|
|
16
|
+
ruleName (Optional[str]): Name of the violated rule.
|
|
17
|
+
scanId (Optional[str]): The scan's UUID.
|
|
18
|
+
scanDate (Optional[str]): When the scan ran (date-time).
|
|
19
|
+
policyTags (List[str]): Tags on the violated policy.
|
|
20
|
+
defaultPolicy (Optional[bool]): Whether the policy is the tenant default.
|
|
21
|
+
defaultPolicyEvaluation (Optional[bool]): Whether the default policy
|
|
22
|
+
was the one evaluated.
|
|
23
|
+
engine (Optional[str]): The scanner engine that produced the incident.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
id: Optional[int] = None
|
|
27
|
+
policyName: Optional[str] = None
|
|
28
|
+
projectName: Optional[str] = None
|
|
29
|
+
branch: Optional[str] = None
|
|
30
|
+
ruleName: Optional[str] = None
|
|
31
|
+
scanId: Optional[str] = None
|
|
32
|
+
scanDate: Optional[str] = None
|
|
33
|
+
policyTags: List[str] = field(default_factory=list)
|
|
34
|
+
defaultPolicy: Optional[bool] = None
|
|
35
|
+
defaultPolicyEvaluation: Optional[bool] = None
|
|
36
|
+
engine: Optional[str] = None
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def from_dict(cls, item: dict) -> "EnhancedIncidentsWebDTO":
|
|
40
|
+
return cls(
|
|
41
|
+
id=item.get("id"),
|
|
42
|
+
policyName=item.get("policyName"),
|
|
43
|
+
projectName=item.get("projectName"),
|
|
44
|
+
branch=item.get("branch"),
|
|
45
|
+
ruleName=item.get("ruleName"),
|
|
46
|
+
scanId=item.get("scanId"),
|
|
47
|
+
scanDate=item.get("scanDate"),
|
|
48
|
+
policyTags=list(item.get("policyTags") or []),
|
|
49
|
+
defaultPolicy=item.get("defaultPolicy"),
|
|
50
|
+
defaultPolicyEvaluation=item.get("defaultPolicyEvaluation"),
|
|
51
|
+
engine=item.get("engine"),
|
|
52
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class EvaluatedPolicyWebDto:
|
|
7
|
+
"""A single policy's evaluation result for one scan/project.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
policyName (Optional[str]): The evaluated policy's name.
|
|
11
|
+
description (Optional[str]): The policy's description.
|
|
12
|
+
rulesViolated (List[str]): Names of rules that were violated.
|
|
13
|
+
tags (List[str]): The policy's tags.
|
|
14
|
+
breakBuild (Optional[bool]): Whether this policy breaks the build.
|
|
15
|
+
status (Optional[str]): Evaluation status. Values: PASSED, FAILED.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
policyName: Optional[str] = None
|
|
19
|
+
description: Optional[str] = None
|
|
20
|
+
rulesViolated: List[str] = field(default_factory=list)
|
|
21
|
+
tags: List[str] = field(default_factory=list)
|
|
22
|
+
breakBuild: Optional[bool] = None
|
|
23
|
+
status: Optional[str] = None
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_dict(cls, item: dict) -> "EvaluatedPolicyWebDto":
|
|
27
|
+
return cls(
|
|
28
|
+
policyName=item.get("policyName"),
|
|
29
|
+
description=item.get("description"),
|
|
30
|
+
rulesViolated=list(item.get("rulesViolated") or []),
|
|
31
|
+
tags=list(item.get("tags") or []),
|
|
32
|
+
breakBuild=item.get("breakBuild"),
|
|
33
|
+
status=item.get("status"),
|
|
34
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ExportParametersSbom:
|
|
6
|
+
"""exportParameters for POST /api/sca/export/requests when
|
|
7
|
+
fileFormat is CycloneDxJson, CycloneDxXml, or SpdxJson.
|
|
8
|
+
"""
|
|
9
|
+
hideDevAndTestDependencies: bool = False
|
|
10
|
+
showOnlyEffectiveLicenses: bool = False
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ExportParametersScanReport:
|
|
6
|
+
"""exportParameters for POST /api/sca/export/requests when
|
|
7
|
+
fileFormat is ScanReportJson, ScanReportXml, ScanReportCsv, or
|
|
8
|
+
ScanReportPdf.
|
|
9
|
+
"""
|
|
10
|
+
hideDevAndTestDependencies: bool = False
|
|
11
|
+
showOnlyEffectiveLicenses: bool = False
|
|
12
|
+
excludePackages: bool = False
|
|
13
|
+
excludeLicenses: bool = True
|
|
14
|
+
excludeVulnerabilities: bool = False
|
|
15
|
+
excludePolicies: bool = True
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class FindingsWebDto:
|
|
7
|
+
"""A SAST/IaC finding as referenced from a policy violation.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
resultId (Optional[str]): The result ID.
|
|
11
|
+
similarityId (Optional[str]): The similarity ID.
|
|
12
|
+
queryId (Optional[str]): The query ID that produced the finding.
|
|
13
|
+
queryName (Optional[str]): The query name.
|
|
14
|
+
severity (Optional[str]): Severity. Values: CRITICAL, HIGH, MEDIUM, LOW, INFO.
|
|
15
|
+
cweId (Optional[int]): CWE ID, if applicable.
|
|
16
|
+
fileName (Optional[str]): File the finding was detected in.
|
|
17
|
+
line (Optional[int]): Line number of the finding.
|
|
18
|
+
description (Optional[str]): Finding description.
|
|
19
|
+
stateName (Optional[str]): Current result state.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
resultId: Optional[str] = None
|
|
23
|
+
similarityId: Optional[str] = None
|
|
24
|
+
queryId: Optional[str] = None
|
|
25
|
+
queryName: Optional[str] = None
|
|
26
|
+
severity: Optional[str] = None
|
|
27
|
+
cweId: Optional[int] = None
|
|
28
|
+
fileName: Optional[str] = None
|
|
29
|
+
line: Optional[int] = None
|
|
30
|
+
description: Optional[str] = None
|
|
31
|
+
stateName: Optional[str] = None
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_dict(cls, item: dict) -> "FindingsWebDto":
|
|
35
|
+
return cls(
|
|
36
|
+
resultId=item.get("resultId"),
|
|
37
|
+
similarityId=item.get("similarityId"),
|
|
38
|
+
queryId=item.get("queryId"),
|
|
39
|
+
queryName=item.get("queryName"),
|
|
40
|
+
severity=item.get("severity"),
|
|
41
|
+
cweId=item.get("cweId"),
|
|
42
|
+
fileName=item.get("fileName"),
|
|
43
|
+
line=item.get("line"),
|
|
44
|
+
description=item.get("description"),
|
|
45
|
+
stateName=item.get("stateName"),
|
|
46
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class IncidentResultWebDTO:
|
|
7
|
+
"""A single result underlying a policy incident.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
id (Optional[int]): Result ID.
|
|
11
|
+
severity (Optional[str]): Result severity.
|
|
12
|
+
issue (Optional[str]): Issue/query name.
|
|
13
|
+
issueLink (Optional[str]): Link to the issue in the CxOne UI.
|
|
14
|
+
cweLink (Optional[str]): Link to the CWE reference.
|
|
15
|
+
sourceFilePackage (Optional[str]): Source file or package name.
|
|
16
|
+
sourceFileLink (Optional[str]): Link to the source file in the CxOne UI.
|
|
17
|
+
lineNumber (Optional[int]): Line number of the finding.
|
|
18
|
+
insight (Optional[str]): Remediation insight text.
|
|
19
|
+
insightLink (Optional[str]): Link to the remediation insight.
|
|
20
|
+
resultId (Optional[str]): The underlying result's ID.
|
|
21
|
+
recommendedVersion (Optional[str]): Recommended package version (SCA).
|
|
22
|
+
attackVector (Optional[str]): Attack vector description.
|
|
23
|
+
attackComplexity (Optional[str]): Attack complexity description.
|
|
24
|
+
riskOrchestrationLink (Optional[str]): Link to Risk Orchestration.
|
|
25
|
+
sastResultsLink (Optional[str]): Link to the SAST result.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
id: Optional[int] = None
|
|
29
|
+
severity: Optional[str] = None
|
|
30
|
+
issue: Optional[str] = None
|
|
31
|
+
issueLink: Optional[str] = None
|
|
32
|
+
cweLink: Optional[str] = None
|
|
33
|
+
sourceFilePackage: Optional[str] = None
|
|
34
|
+
sourceFileLink: Optional[str] = None
|
|
35
|
+
lineNumber: Optional[int] = None
|
|
36
|
+
insight: Optional[str] = None
|
|
37
|
+
insightLink: Optional[str] = None
|
|
38
|
+
resultId: Optional[str] = None
|
|
39
|
+
recommendedVersion: Optional[str] = None
|
|
40
|
+
attackVector: Optional[str] = None
|
|
41
|
+
attackComplexity: Optional[str] = None
|
|
42
|
+
riskOrchestrationLink: Optional[str] = None
|
|
43
|
+
sastResultsLink: Optional[str] = None
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def from_dict(cls, item: dict) -> "IncidentResultWebDTO":
|
|
47
|
+
return cls(
|
|
48
|
+
id=item.get("id"),
|
|
49
|
+
severity=item.get("severity"),
|
|
50
|
+
issue=item.get("issue"),
|
|
51
|
+
issueLink=item.get("issueLink"),
|
|
52
|
+
cweLink=item.get("cweLink"),
|
|
53
|
+
sourceFilePackage=item.get("sourceFilePackage"),
|
|
54
|
+
sourceFileLink=item.get("sourceFileLink"),
|
|
55
|
+
lineNumber=item.get("lineNumber"),
|
|
56
|
+
insight=item.get("insight"),
|
|
57
|
+
insightLink=item.get("insightLink"),
|
|
58
|
+
resultId=item.get("resultId"),
|
|
59
|
+
recommendedVersion=item.get("recommendedVersion"),
|
|
60
|
+
attackVector=item.get("attackVector"),
|
|
61
|
+
attackComplexity=item.get("attackComplexity"),
|
|
62
|
+
riskOrchestrationLink=item.get("riskOrchestrationLink"),
|
|
63
|
+
sastResultsLink=item.get("sastResultsLink"),
|
|
64
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from .IncidentResultWebDTO import IncidentResultWebDTO
|
|
5
|
+
from .ViolationDetailsDTO import ViolationDetailsDTO
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class IncidentResultsDTO:
|
|
10
|
+
"""Response from GET /incidents/{incidentId}/results.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
violationDetails (Optional[ViolationDetailsDTO]): The violated
|
|
14
|
+
policy/rule details common to all results.
|
|
15
|
+
results (List[IncidentResultWebDTO]): Results on the current page.
|
|
16
|
+
filteredResultsCount (Optional[int]): Total count after filtering.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
violationDetails: Optional[ViolationDetailsDTO] = None
|
|
20
|
+
results: List[IncidentResultWebDTO] = field(default_factory=list)
|
|
21
|
+
filteredResultsCount: Optional[int] = None
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def from_dict(cls, item: dict) -> "IncidentResultsDTO":
|
|
25
|
+
return cls(
|
|
26
|
+
violationDetails=(
|
|
27
|
+
ViolationDetailsDTO.from_dict(item["violationDetails"])
|
|
28
|
+
if item.get("violationDetails")
|
|
29
|
+
else None
|
|
30
|
+
),
|
|
31
|
+
results=[
|
|
32
|
+
IncidentResultWebDTO.from_dict(r)
|
|
33
|
+
for r in (item.get("results") or [])
|
|
34
|
+
],
|
|
35
|
+
filteredResultsCount=item.get("filteredResultsCount"),
|
|
36
|
+
)
|