Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cycode/cyclient/scan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def get_detection_rules(
def get_scan_detections_path(self, scan_type: str) -> str:
return f'{self.scan_config.get_detections_prefix()}/{self.get_detections_service_controller_path(scan_type)}'

def get_scan_detections_list_path(self, scan_type: str) -> str:
suffix = ''
if scan_type == consts.SCA_SCAN_TYPE:
suffix = '/detections'

return f'{self.get_scan_detections_path(scan_type)}{suffix}'

def get_scan_detections(self, scan_type: str, scan_id: str) -> List[dict]:
params = {'scan_id': scan_id}

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

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

return detections

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

def get_scan_detections_count(self, scan_type: str, scan_id: str) -> int:
response = self.scan_cycode_client.get(
url_path=self.get_get_scan_detections_count_path(scan_type), params={'scan_id': scan_id}
url_path=self.get_scan_detections_count_path(scan_type), params={'scan_id': scan_id}
)
return response.json().get('count', 0)

Expand Down
2 changes: 1 addition & 1 deletion tests/cyclient/mocked_responses/scan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_scan_details_response(url: str, scan_id: Optional[UUID] = None) -> respo

def get_scan_detections_count_url(scan_client: ScanClient) -> str:
api_url = scan_client.scan_cycode_client.api_url
service_url = scan_client.get_get_scan_detections_count_path()
service_url = scan_client.get_scan_detections_count_path()
return f'{api_url}/{service_url}'


Expand Down