CheckmarxPythonSDK 1.7.8__py3-none-any.whl → 1.8.0__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/CxODataApiSDK/Utilities.py +1 -1
- CheckmarxPythonSDK/CxODataApiSDK/config.py +7 -2
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientRoleMappingsApi.py +8 -5
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientRolesApi.py +17 -18
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientScopesApi.py +3 -1
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientsApi.py +35 -16
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ComponentApi.py +2 -2
- CheckmarxPythonSDK/CxOne/KeycloakAPI/GroupsApi.py +10 -10
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RoleMapperApi.py +118 -40
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RolesApi.py +266 -134
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RolesByIdApi.py +103 -43
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ScopeMappingsApi.py +328 -114
- CheckmarxPythonSDK/CxOne/KeycloakAPI/UsersApi.py +299 -97
- CheckmarxPythonSDK/CxOne/accessControlAPI.py +143 -48
- CheckmarxPythonSDK/CxOne/accessManagementAPI.py +1229 -463
- CheckmarxPythonSDK/CxOne/apisecAPI.py +429 -5
- CheckmarxPythonSDK/CxOne/config.py +15 -2
- CheckmarxPythonSDK/CxOne/dto/EntityRolesRequest.py +4 -2
- CheckmarxPythonSDK/CxOne/dto/MultipleAssignmentInput.py +7 -4
- CheckmarxPythonSDK/CxOne/projectsAPI.py +527 -174
- CheckmarxPythonSDK/CxOne/repoManagerAPI.py +267 -19
- CheckmarxPythonSDK/CxRestAPISDK/config.py +7 -2
- CheckmarxPythonSDK/__init__.py +3 -17
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +85 -10
- CheckmarxPythonSDK/configuration.py +4 -1
- CheckmarxPythonSDK/logger_setup.py +64 -0
- CheckmarxPythonSDK/rate_limiter.py +95 -0
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/RECORD +33 -31
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/WHEEL +1 -1
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/top_level.txt +0 -0
|
@@ -206,7 +206,7 @@ def get_result(project, filter_false_positive=False, threshold=0):
|
|
|
206
206
|
"ScanId": last_scan_id,
|
|
207
207
|
"DirectLink": f"{ResultsODataAPI().api_client.configuration.server_base_url}/cxwebclient"
|
|
208
208
|
f"/ViewerMain.aspx?scanid={last_scan_id}&projectid={project_id}"
|
|
209
|
-
f"&pathid={result.get(
|
|
209
|
+
f"&pathid={result.get('PathId')}"
|
|
210
210
|
}
|
|
211
211
|
)
|
|
212
212
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from CheckmarxPythonSDK.configuration import Configuration
|
|
2
2
|
from CheckmarxPythonSDK.utilities.configUtility import get_config
|
|
3
|
+
from CheckmarxPythonSDK.logger_setup import set_module_logger_level
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def construct_configuration() -> Configuration:
|
|
@@ -20,13 +21,14 @@ def construct_configuration() -> Configuration:
|
|
|
20
21
|
"verify": True,
|
|
21
22
|
"cert": None,
|
|
22
23
|
"proxy": None,
|
|
24
|
+
"logging_level": "ERROR",
|
|
23
25
|
}
|
|
24
26
|
old_config = get_config(config_default=config_default, section="checkmarx", prefix="cxsast_")
|
|
25
27
|
new_config = get_config(config_default=config_default, section="CxSAST", prefix="cxsast_")
|
|
26
28
|
config = old_config
|
|
27
29
|
if new_config.get("base_url"):
|
|
28
30
|
config = new_config
|
|
29
|
-
|
|
31
|
+
configuration = Configuration(
|
|
30
32
|
server_base_url=config.get("base_url"),
|
|
31
33
|
token_url=f"{config.get('base_url')}/cxrestapi/auth/identity/connect/token",
|
|
32
34
|
username=config.get("username"),
|
|
@@ -41,5 +43,8 @@ def construct_configuration() -> Configuration:
|
|
|
41
43
|
proxies={
|
|
42
44
|
"http": config.get("proxy"),
|
|
43
45
|
"https": config.get("proxy"),
|
|
44
|
-
}
|
|
46
|
+
},
|
|
47
|
+
logging_level=config.get("logging_level"),
|
|
45
48
|
)
|
|
49
|
+
set_module_logger_level("CxODataApiSDK", configuration.logging_level)
|
|
50
|
+
return configuration
|
|
@@ -197,7 +197,7 @@ class ClientRoleMappingsApi:
|
|
|
197
197
|
realm: str,
|
|
198
198
|
id: str,
|
|
199
199
|
client: str,
|
|
200
|
-
|
|
200
|
+
role_representations: List[RoleRepresentation]
|
|
201
201
|
) -> bool:
|
|
202
202
|
"""
|
|
203
203
|
Add client-level roles to the user role mapping
|
|
@@ -206,7 +206,7 @@ class ClientRoleMappingsApi:
|
|
|
206
206
|
realm (str): [required]
|
|
207
207
|
id (str): [required]
|
|
208
208
|
client (str): [required]
|
|
209
|
-
|
|
209
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
210
210
|
|
|
211
211
|
Returns:
|
|
212
212
|
bool
|
|
@@ -217,16 +217,17 @@ class ClientRoleMappingsApi:
|
|
|
217
217
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/clients/{client}"
|
|
218
218
|
response = self.api_client.post_request(
|
|
219
219
|
relative_url=relative_url,
|
|
220
|
-
json=role_representation.to_dict(),
|
|
220
|
+
json=[role_representation.to_dict() for role_representation in role_representations],
|
|
221
221
|
is_iam=True
|
|
222
222
|
)
|
|
223
|
-
return response.status_code ==
|
|
223
|
+
return response.status_code == 204
|
|
224
224
|
|
|
225
225
|
def delete_user_role_mappings_client(
|
|
226
226
|
self,
|
|
227
227
|
realm: str,
|
|
228
228
|
id: str,
|
|
229
|
-
client: str
|
|
229
|
+
client: str,
|
|
230
|
+
role_representations: List[RoleRepresentation]
|
|
230
231
|
) -> bool:
|
|
231
232
|
"""
|
|
232
233
|
Delete client-level roles from user role mapping
|
|
@@ -235,6 +236,7 @@ class ClientRoleMappingsApi:
|
|
|
235
236
|
realm (str): [required]
|
|
236
237
|
id (str): [required]
|
|
237
238
|
client (str): [required]
|
|
239
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
238
240
|
|
|
239
241
|
Returns:
|
|
240
242
|
bool
|
|
@@ -245,6 +247,7 @@ class ClientRoleMappingsApi:
|
|
|
245
247
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/clients/{client}"
|
|
246
248
|
response = self.api_client.delete_request(
|
|
247
249
|
relative_url=relative_url,
|
|
250
|
+
json=[role_representation.to_dict() for role_representation in role_representations],
|
|
248
251
|
is_iam=True
|
|
249
252
|
)
|
|
250
253
|
return response.status_code == 204
|
|
@@ -19,9 +19,9 @@ class ClientRolesApi:
|
|
|
19
19
|
self,
|
|
20
20
|
realm: str,
|
|
21
21
|
id: str,
|
|
22
|
-
brief_representation:
|
|
23
|
-
first: int =
|
|
24
|
-
max: int =
|
|
22
|
+
brief_representation: bool = False,
|
|
23
|
+
first: int = 0,
|
|
24
|
+
max: int = 100,
|
|
25
25
|
search: str = None
|
|
26
26
|
) -> List[RoleRepresentation]:
|
|
27
27
|
"""
|
|
@@ -30,10 +30,10 @@ class ClientRolesApi:
|
|
|
30
30
|
Args:
|
|
31
31
|
realm (str): [required]
|
|
32
32
|
id (str): [required]
|
|
33
|
-
brief_representation (
|
|
34
|
-
first (int):
|
|
35
|
-
max (int):
|
|
36
|
-
search (str):
|
|
33
|
+
brief_representation (bool): [optional]
|
|
34
|
+
first (int): [optional]
|
|
35
|
+
max (int): [optional]
|
|
36
|
+
search (str): [optional]
|
|
37
37
|
|
|
38
38
|
Returns:
|
|
39
39
|
List[RoleRepresentation]
|
|
@@ -48,7 +48,6 @@ class ClientRolesApi:
|
|
|
48
48
|
"search": search
|
|
49
49
|
}
|
|
50
50
|
relative_url = f"{api_url}/{realm}/clients/{id}/roles"
|
|
51
|
-
|
|
52
51
|
response = self.api_client.get_request(
|
|
53
52
|
relative_url=relative_url,
|
|
54
53
|
params=params
|
|
@@ -336,8 +335,8 @@ class ClientRolesApi:
|
|
|
336
335
|
id: str,
|
|
337
336
|
role_name: str,
|
|
338
337
|
brief_representation: bool = None,
|
|
339
|
-
first: int =
|
|
340
|
-
max: int =
|
|
338
|
+
first: int = 0,
|
|
339
|
+
max: int = 100
|
|
341
340
|
) -> List[GroupRepresentation]:
|
|
342
341
|
"""
|
|
343
342
|
Returns a stream of groups that have the specified role name
|
|
@@ -434,8 +433,8 @@ class ClientRolesApi:
|
|
|
434
433
|
realm: str,
|
|
435
434
|
id: str,
|
|
436
435
|
role_name: str,
|
|
437
|
-
first: int =
|
|
438
|
-
max: int =
|
|
436
|
+
first: int = 0,
|
|
437
|
+
max: int = 100
|
|
439
438
|
) -> List[UserRepresentation]:
|
|
440
439
|
"""
|
|
441
440
|
Returns a stream of users that have the specified role name.
|
|
@@ -468,8 +467,8 @@ class ClientRolesApi:
|
|
|
468
467
|
self,
|
|
469
468
|
realm: str,
|
|
470
469
|
brief_representation: str = None,
|
|
471
|
-
first: int =
|
|
472
|
-
max: int =
|
|
470
|
+
first: int = 0,
|
|
471
|
+
max: int = 100,
|
|
473
472
|
search: str = None
|
|
474
473
|
) -> List[RoleRepresentation]:
|
|
475
474
|
"""
|
|
@@ -767,8 +766,8 @@ class ClientRolesApi:
|
|
|
767
766
|
realm: str,
|
|
768
767
|
role_name: str,
|
|
769
768
|
brief_representation: bool = None,
|
|
770
|
-
first: int =
|
|
771
|
-
max: int =
|
|
769
|
+
first: int = 0,
|
|
770
|
+
max: int = 100
|
|
772
771
|
) -> List[GroupRepresentation]:
|
|
773
772
|
"""
|
|
774
773
|
Returns a stream of groups that have the specified role name
|
|
@@ -862,8 +861,8 @@ class ClientRolesApi:
|
|
|
862
861
|
self,
|
|
863
862
|
realm: str,
|
|
864
863
|
role_name: str,
|
|
865
|
-
first: int =
|
|
866
|
-
max: int =
|
|
864
|
+
first: int = 0,
|
|
865
|
+
max: int = 100
|
|
867
866
|
) -> List[UserRepresentation]:
|
|
868
867
|
"""
|
|
869
868
|
Returns a stream of users that have the specified role name.
|
|
@@ -33,7 +33,9 @@ class ClientScopesApi:
|
|
|
33
33
|
relative_url=relative_url,
|
|
34
34
|
is_iam=True
|
|
35
35
|
)
|
|
36
|
-
return [
|
|
36
|
+
return [
|
|
37
|
+
ClientScopeRepresentation.from_dict(item) for item in response.json()
|
|
38
|
+
]
|
|
37
39
|
|
|
38
40
|
def post_client_scopes(
|
|
39
41
|
self,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
1
3
|
from CheckmarxPythonSDK.api_client import ApiClient
|
|
2
4
|
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
3
|
-
from typing import Dict, List, Any, Optional
|
|
5
|
+
from typing import Dict, List, Any, Optional, Union
|
|
4
6
|
from .dto.AccessToken import AccessToken
|
|
5
7
|
from .dto.ClientRepresentation import ClientRepresentation
|
|
6
8
|
from .dto.ClientScopeRepresentation import ClientScopeRepresentation
|
|
@@ -14,9 +16,11 @@ from .dto.UserRepresentation import UserRepresentation
|
|
|
14
16
|
from .dto.UserSessionRepresentation import UserSessionRepresentation
|
|
15
17
|
from .api_url import api_url
|
|
16
18
|
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
17
21
|
|
|
18
22
|
class ClientsApi:
|
|
19
|
-
def __init__(self, api_client: ApiClient = None):
|
|
23
|
+
def __init__(self, api_client: Optional[ApiClient] = None):
|
|
20
24
|
if api_client is None:
|
|
21
25
|
configuration = construct_configuration()
|
|
22
26
|
api_client = ApiClient(configuration=configuration)
|
|
@@ -26,8 +30,8 @@ class ClientsApi:
|
|
|
26
30
|
self,
|
|
27
31
|
realm: str,
|
|
28
32
|
client_id: str = None,
|
|
29
|
-
first:
|
|
30
|
-
max:
|
|
33
|
+
first: int = 0,
|
|
34
|
+
max: int = 100,
|
|
31
35
|
q: str = None,
|
|
32
36
|
search: bool = None,
|
|
33
37
|
viewable_only: str = None
|
|
@@ -38,8 +42,8 @@ class ClientsApi:
|
|
|
38
42
|
Args:
|
|
39
43
|
realm (str): [required]
|
|
40
44
|
client_id (str): filter by clientId
|
|
41
|
-
first (
|
|
42
|
-
max (
|
|
45
|
+
first (int): the first result
|
|
46
|
+
max (int): the max results to return
|
|
43
47
|
q (str):
|
|
44
48
|
search (bool): whether this is a search query or a getClientById query
|
|
45
49
|
viewable_only (str): filter clients that cannot be viewed in full by admin
|
|
@@ -87,12 +91,14 @@ class ClientsApi:
|
|
|
87
91
|
Relative path: /{realm}/clients
|
|
88
92
|
"""
|
|
89
93
|
relative_url = f"{api_url}/{realm}/clients"
|
|
94
|
+
print(f"Post request to {relative_url}")
|
|
95
|
+
print(f"Request body: {client_representation.to_dict()}")
|
|
90
96
|
response = self.api_client.post_request(
|
|
91
97
|
relative_url=relative_url,
|
|
92
98
|
json=client_representation.to_dict(),
|
|
93
99
|
is_iam=True
|
|
94
100
|
)
|
|
95
|
-
return response.status_code ==
|
|
101
|
+
return response.status_code == 201
|
|
96
102
|
|
|
97
103
|
def get_client_by_realm_by_id(
|
|
98
104
|
self,
|
|
@@ -145,7 +151,7 @@ class ClientsApi:
|
|
|
145
151
|
json=client_representation.to_dict(),
|
|
146
152
|
is_iam=True
|
|
147
153
|
)
|
|
148
|
-
return response.status_code ==
|
|
154
|
+
return response.status_code == 204
|
|
149
155
|
|
|
150
156
|
def delete_client_by_realm_by_id(
|
|
151
157
|
self,
|
|
@@ -165,11 +171,24 @@ class ClientsApi:
|
|
|
165
171
|
URL:
|
|
166
172
|
Relative path: /{realm}/clients/{id}
|
|
167
173
|
"""
|
|
174
|
+
if id in ['ast-app', 'cb-app', 'realm-management', 'superset-kpi']:
|
|
175
|
+
logger.error(
|
|
176
|
+
"Forbid to delete builtin-in clients ast-app, cb-app, "
|
|
177
|
+
"realm-management, superset-kpi which are system clients"
|
|
178
|
+
)
|
|
179
|
+
return False
|
|
180
|
+
if id.startswith(tuple(['saml-helper-'])):
|
|
181
|
+
logger.error(
|
|
182
|
+
"Forbid to delete clients with saml-helper- prefix, "
|
|
183
|
+
"which are intended for internal use"
|
|
184
|
+
)
|
|
185
|
+
return False
|
|
168
186
|
relative_url = f"{api_url}/{realm}/clients/{id}"
|
|
169
187
|
response = self.api_client.delete_request(
|
|
170
188
|
relative_url=relative_url,
|
|
171
189
|
is_iam=True
|
|
172
190
|
)
|
|
191
|
+
logger.info(f"Delete client {id} successful in realm {realm}")
|
|
173
192
|
return response.status_code == 204
|
|
174
193
|
|
|
175
194
|
def get_client_secret(
|
|
@@ -700,8 +719,8 @@ class ClientsApi:
|
|
|
700
719
|
self,
|
|
701
720
|
realm: str,
|
|
702
721
|
id: str,
|
|
703
|
-
first:
|
|
704
|
-
max:
|
|
722
|
+
first: int = 0,
|
|
723
|
+
max: int = 100
|
|
705
724
|
) -> List[UserSessionRepresentation]:
|
|
706
725
|
"""
|
|
707
726
|
Get offline sessions for client Returns a list of offline user sessions
|
|
@@ -710,8 +729,8 @@ class ClientsApi:
|
|
|
710
729
|
Args:
|
|
711
730
|
realm (str): [required]
|
|
712
731
|
id (str): [required]
|
|
713
|
-
first (
|
|
714
|
-
max (
|
|
732
|
+
first (int): Paging offset
|
|
733
|
+
max (int): Maximum results size (defaults to 100)
|
|
715
734
|
|
|
716
735
|
Returns:
|
|
717
736
|
List[UserSessionRepresentation]
|
|
@@ -930,8 +949,8 @@ class ClientsApi:
|
|
|
930
949
|
def get_client_user_sessions(self,
|
|
931
950
|
realm: str,
|
|
932
951
|
id: str,
|
|
933
|
-
first:
|
|
934
|
-
max:
|
|
952
|
+
first: int = 0,
|
|
953
|
+
max: int = 100
|
|
935
954
|
) -> List[UserSessionRepresentation]:
|
|
936
955
|
"""
|
|
937
956
|
Get user sessions for client Returns a list of user sessions
|
|
@@ -940,8 +959,8 @@ class ClientsApi:
|
|
|
940
959
|
Args:
|
|
941
960
|
realm (str): [required]
|
|
942
961
|
id (str): [required]
|
|
943
|
-
first (
|
|
944
|
-
max (
|
|
962
|
+
first (int): Paging offset
|
|
963
|
+
max (int): Maximum results size (defaults to 100)
|
|
945
964
|
|
|
946
965
|
Returns:
|
|
947
966
|
List[UserSessionRepresentation]
|
|
@@ -68,7 +68,7 @@ class ComponentApi:
|
|
|
68
68
|
json=component_representation.to_dict(),
|
|
69
69
|
is_iam=True
|
|
70
70
|
)
|
|
71
|
-
return response.status_code ==
|
|
71
|
+
return response.status_code == 204
|
|
72
72
|
|
|
73
73
|
def get_component(self,
|
|
74
74
|
realm: str,
|
|
@@ -114,7 +114,7 @@ class ComponentApi:
|
|
|
114
114
|
json=component_representation.to_dict(),
|
|
115
115
|
is_iam=True
|
|
116
116
|
)
|
|
117
|
-
return response.status_code ==
|
|
117
|
+
return response.status_code == 204
|
|
118
118
|
|
|
119
119
|
def delete_component(self,
|
|
120
120
|
realm: str,
|
|
@@ -17,10 +17,10 @@ class GroupsApi:
|
|
|
17
17
|
def get_groups_by_realm(
|
|
18
18
|
self,
|
|
19
19
|
realm: str,
|
|
20
|
-
brief_representation:
|
|
20
|
+
brief_representation: bool = False,
|
|
21
21
|
exact: str = None,
|
|
22
|
-
first:
|
|
23
|
-
max:
|
|
22
|
+
first: int = 0,
|
|
23
|
+
max: int = 100,
|
|
24
24
|
populate_hierarchy: str = None,
|
|
25
25
|
q: str = None,
|
|
26
26
|
search: str = None
|
|
@@ -30,10 +30,10 @@ class GroupsApi:
|
|
|
30
30
|
|
|
31
31
|
Args:
|
|
32
32
|
realm (str): [required]
|
|
33
|
-
brief_representation (
|
|
33
|
+
brief_representation (bool):
|
|
34
34
|
exact (str):
|
|
35
|
-
first (
|
|
36
|
-
max (
|
|
35
|
+
first (int):
|
|
36
|
+
max (int):
|
|
37
37
|
populate_hierarchy (str):
|
|
38
38
|
q (str):
|
|
39
39
|
search (str):
|
|
@@ -201,8 +201,8 @@ class GroupsApi:
|
|
|
201
201
|
realm: str,
|
|
202
202
|
id: str,
|
|
203
203
|
brief_representation: str = None,
|
|
204
|
-
first:
|
|
205
|
-
max:
|
|
204
|
+
first: int = 0,
|
|
205
|
+
max: int = 100
|
|
206
206
|
) -> List[GroupRepresentation]:
|
|
207
207
|
"""
|
|
208
208
|
Return a paginated list of subgroups that have a parent group
|
|
@@ -212,8 +212,8 @@ class GroupsApi:
|
|
|
212
212
|
realm (str): [required]
|
|
213
213
|
id (str): [required]
|
|
214
214
|
brief_representation (str):
|
|
215
|
-
first (
|
|
216
|
-
max (
|
|
215
|
+
first (int):
|
|
216
|
+
max (int):
|
|
217
217
|
|
|
218
218
|
Returns:
|
|
219
219
|
List[GroupRepresentation]
|