Skip to content

Commit c6091e2

Browse files
authored
CM-31107 - Fix detections endpoint suffix for SCA (#194)
1 parent 908f5b8 commit c6091e2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

cycode/cyclient/scan_client.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def get_detection_rules(
171171
def get_scan_detections_path(self, scan_type: str) -> str:
172172
return f'{self.scan_config.get_detections_prefix()}/{self.get_detections_service_controller_path(scan_type)}'
173173

174+
def get_scan_detections_list_path(self, scan_type: str) -> str:
175+
suffix = ''
176+
if scan_type == consts.SCA_SCAN_TYPE:
177+
suffix = '/detections'
178+
179+
return f'{self.get_scan_detections_path(scan_type)}{suffix}'
180+
174181
def get_scan_detections(self, scan_type: str, scan_id: str) -> List[dict]:
175182
params = {'scan_id': scan_id}
176183

@@ -184,9 +191,8 @@ def get_scan_detections(self, scan_type: str, scan_id: str) -> List[dict]:
184191
params['page_size'] = page_size
185192
params['page_number'] = page_number
186193

187-
path = f'{self.get_scan_detections_path(scan_type)}/detections'
188194
response = self.scan_cycode_client.get(
189-
url_path=path,
195+
url_path=self.get_scan_detections_list_path(scan_type),
190196
params=params,
191197
hide_response_content_log=self._hide_response_log,
192198
).json()
@@ -197,12 +203,12 @@ def get_scan_detections(self, scan_type: str, scan_id: str) -> List[dict]:
197203

198204
return detections
199205

200-
def get_get_scan_detections_count_path(self, scan_type: str) -> str:
206+
def get_scan_detections_count_path(self, scan_type: str) -> str:
201207
return f'{self.get_scan_detections_path(scan_type)}/count'
202208

203209
def get_scan_detections_count(self, scan_type: str, scan_id: str) -> int:
204210
response = self.scan_cycode_client.get(
205-
url_path=self.get_get_scan_detections_count_path(scan_type), params={'scan_id': scan_id}
211+
url_path=self.get_scan_detections_count_path(scan_type), params={'scan_id': scan_id}
206212
)
207213
return response.json().get('count', 0)
208214

tests/cyclient/mocked_responses/scan_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_scan_details_response(url: str, scan_id: Optional[UUID] = None) -> respo
109109

110110
def get_scan_detections_count_url(scan_client: ScanClient) -> str:
111111
api_url = scan_client.scan_cycode_client.api_url
112-
service_url = scan_client.get_get_scan_detections_count_path()
112+
service_url = scan_client.get_scan_detections_count_path()
113113
return f'{api_url}/{service_url}'
114114

115115

0 commit comments

Comments
 (0)