CheckmarxPythonSDK 1.8.7__py3-none-any.whl → 1.8.8__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.
@@ -367,16 +367,16 @@ from .projectsOverviewAPI import (
367
367
  get_tenant_projects_overview,
368
368
  get_project_counters,
369
369
  )
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,
370
+ from .presetManagerAPI import (
371
+ PresetManagerAPI,
372
+ get_scanner_presets,
373
+ get_scanner_preset_by_id,
374
+ create_scanner_preset,
375
+ update_scanner_preset,
376
+ delete_scanner_preset,
377
+ clone_scanner_preset,
378
+ get_scanner_query_families,
379
+ get_scanner_queries_by_family,
380
380
  )
381
381
  from .queryEditorAPI import (
382
382
  QueryEditorAPI,
@@ -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
+ )
@@ -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"))
@@ -15,3 +15,21 @@ class PredicateWithCommentJSON:
15
15
  created_at: str = None
16
16
  change_origin_type: int = None
17
17
  change_origin_name: str = None
18
+
19
+ @classmethod
20
+ def from_dict(cls, item: dict) -> "PredicateWithCommentJSON":
21
+ if not item:
22
+ return None
23
+ return cls(
24
+ id=item.get("ID"),
25
+ similarity_id=item.get("similarityId"),
26
+ project_id=item.get("projectId"),
27
+ severity=item.get("severity"),
28
+ state=item.get("state"),
29
+ comment=item.get("comment"),
30
+ comment_json=CommentJSON.from_dict(item.get("commentJSON")),
31
+ created_by=item.get("createdBy"),
32
+ created_at=item.get("createdAt"),
33
+ change_origin_type=item.get("changeOriginType"),
34
+ change_origin_name=item.get("changeOriginName"),
35
+ )
@@ -165,6 +165,8 @@ from .Permission import Permission
165
165
  from .PlatformSummary import PlatformSummary
166
166
  from .Predicate import Predicate
167
167
  from .PredicateHistory import PredicateHistory
168
+ from .PredicateInitialValues import PredicateInitialValues
169
+ from .PredicateHistoryResponse import PredicateHistoryResponse
168
170
  from .PredicateWithCommentJSON import PredicateWithCommentJSON
169
171
  from .PredicateWithCommentsJSON import PredicateWithCommentsJSON
170
172
  from .Preset import Preset
@@ -48,17 +48,22 @@ class SastQueriesAPI(object):
48
48
  ]
49
49
 
50
50
  def get_sast_query_description(
51
- self, ids: List[str]
51
+ self,
52
+ ids: List[str],
53
+ scan_id: str = None,
54
+ tenant_id: str = None,
52
55
  ) -> List[QueryDescription]:
53
56
  """
54
57
  Args:
55
58
  ids (List[str]): list of query ids.
59
+ scan_id (str): optional scan ID for context.
60
+ tenant_id (str): optional tenant ID.
56
61
 
57
62
  Returns:
58
63
  List[QueryDescription]
59
64
  """
60
65
  url = f"{self.base_url}/descriptions"
61
- params = {"ids": ids}
66
+ params = {"ids": ids, "scan-id": scan_id, "tenant-id": tenant_id}
62
67
  response = self.api_client.call_api(
63
68
  method="GET", url=url, params=params
64
69
  )
@@ -121,8 +126,12 @@ def get_sast_queries_presets() -> List[Preset]:
121
126
 
122
127
  def get_sast_query_description(
123
128
  ids: List[str],
129
+ scan_id: str = None,
130
+ tenant_id: str = None,
124
131
  ) -> List[QueryDescription]:
125
- return SastQueriesAPI().get_sast_query_description(ids=ids)
132
+ return SastQueriesAPI().get_sast_query_description(
133
+ ids=ids, scan_id=scan_id, tenant_id=tenant_id,
134
+ )
126
135
 
127
136
 
128
137
  def get_mapping_between_ast_and_sast_query_ids() -> List[dict]:
@@ -1,7 +1,9 @@
1
+ from typing import List
2
+
1
3
  from CheckmarxPythonSDK.api_client import ApiClient
2
4
  from CheckmarxPythonSDK.CxOne.config import construct_configuration
3
5
  from CheckmarxPythonSDK.utilities.compat import NO_CONTENT, CREATED, OK
4
- from typing import List
6
+ from .dto import PredicateHistoryResponse
5
7
 
6
8
 
7
9
  class SastResultsPredicatesAPI(object):
@@ -22,34 +24,40 @@ class SastResultsPredicatesAPI(object):
22
24
  project_ids: List[str] = None,
23
25
  include_comment_json: bool = None,
24
26
  scan_id: str = None,
25
- ) -> dict:
27
+ offset: int = 0,
28
+ limit: int = 100,
29
+ ) -> PredicateHistoryResponse:
26
30
  """
27
31
  Args:
28
32
  similarity_id (str):
29
33
  project_ids (list of str):
30
34
  include_comment_json (bool):
31
35
  scan_id (str):
36
+ offset (int):
37
+ limit (int):
32
38
 
33
39
  Returns:
34
- dict
40
+ PredicateHistoryResponse
35
41
  """
36
42
  url = f"{self.base_url}/{similarity_id}"
37
43
  params = {
38
44
  "project-ids": project_ids,
39
45
  "include-comment-json": include_comment_json,
40
46
  "scan-id": scan_id,
47
+ "offset": offset,
48
+ "limit": limit,
41
49
  }
42
50
  response = self.api_client.call_api(
43
51
  method="GET", url=url, params=params
44
52
  )
45
- return response.json()
53
+ return PredicateHistoryResponse.from_dict(response.json())
46
54
 
47
55
  def get_latest_predicates_for_similarity_id(
48
56
  self,
49
57
  similarity_id: str,
50
58
  project_ids: List[str] = None,
51
59
  scan_id: str = None,
52
- ) -> dict:
60
+ ) -> PredicateHistoryResponse:
53
61
  """
54
62
  Args:
55
63
  similarity_id (str):
@@ -57,14 +65,14 @@ class SastResultsPredicatesAPI(object):
57
65
  scan_id (str):
58
66
 
59
67
  Returns:
60
- dict
68
+ PredicateHistoryResponse
61
69
  """
62
70
  url = f"{self.base_url}/{similarity_id}/latest"
63
71
  params = {"project-ids": project_ids, "scan-id": scan_id}
64
72
  response = self.api_client.call_api(
65
73
  method="GET", url=url, params=params
66
74
  )
67
- return response.json()
75
+ return PredicateHistoryResponse.from_dict(response.json())
68
76
 
69
77
  def predicate_severity_and_state_by_similarity_id_and_project_id(
70
78
  self, data: List[dict]
@@ -245,12 +253,16 @@ def get_all_predicates_for_similarity_id(
245
253
  project_ids: List[str] = None,
246
254
  include_comment_json: bool = None,
247
255
  scan_id: str = None,
248
- ) -> dict:
256
+ offset: int = 0,
257
+ limit: int = 100,
258
+ ) -> PredicateHistoryResponse:
249
259
  return SastResultsPredicatesAPI().get_all_predicates_for_similarity_id(
250
260
  similarity_id=similarity_id,
251
261
  project_ids=project_ids,
252
262
  include_comment_json=include_comment_json,
253
263
  scan_id=scan_id,
264
+ offset=offset,
265
+ limit=limit,
254
266
  )
255
267
 
256
268
 
@@ -258,7 +270,7 @@ def get_latest_predicates_for_similarity_id(
258
270
  similarity_id: str,
259
271
  project_ids: List[str] = None,
260
272
  scan_id: str = None,
261
- ) -> dict:
273
+ ) -> PredicateHistoryResponse:
262
274
  return SastResultsPredicatesAPI().get_latest_predicates_for_similarity_id(
263
275
  similarity_id=similarity_id,
264
276
  project_ids=project_ids,