Skip to content
Merged
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
40 changes: 22 additions & 18 deletions cycode/cyclient/scan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ def __init__(
self.scan_cycode_client = scan_cycode_client
self.scan_config = scan_config

self._SCAN_CONTROLLER_PATH = 'api/v1/scan'
self._SCAN_CONTROLLER_PATH_SCA = 'api/v1/cli-scan'
self._SCAN_SERVICE_CONTROLLER_PATH = 'api/v1/scan'
self._SCAN_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/cli-scan'

self._DETECTIONS_SERVICE_CONTROLLER_PATH = 'api/v1/detections'
self._DETECTIONS_SERVICE_CONTROLLER_PATH_SCA = 'api/v1/detections/cli'
self._DETECTIONS_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/detections/cli'

self.POLICIES_SERVICE_CONTROLLER_PATH_V3 = 'api/v3/policies'

self._hide_response_log = hide_response_log

def get_scan_controller_path(self, scan_type: str, should_use_scan_service: bool = False) -> str:
if should_use_scan_service:
return self._SCAN_CONTROLLER_PATH
if scan_type == consts.SCA_SCAN_TYPE:
return self._SCAN_CONTROLLER_PATH_SCA
def get_scan_controller_path(self, scan_type: str) -> str:
if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
# we don't use async flow for IaC scan yet
return self._SCAN_SERVICE_CONTROLLER_PATH

return self._SCAN_CONTROLLER_PATH
return self._SCAN_SERVICE_CLI_CONTROLLER_PATH

def get_detections_service_controller_path(self, scan_type: str) -> str:
if scan_type == consts.SCA_SCAN_TYPE:
return self._DETECTIONS_SERVICE_CONTROLLER_PATH_SCA
if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
# we don't use async flow for IaC scan yet
return self._DETECTIONS_SERVICE_CONTROLLER_PATH

return self._DETECTIONS_SERVICE_CONTROLLER_PATH
return self._DETECTIONS_SERVICE_CLI_CONTROLLER_PATH

def get_scan_service_url_path(self, scan_type: str, should_use_scan_service: bool = False) -> str:
service_path = self.scan_config.get_service_name(scan_type, should_use_scan_service)
controller_path = self.get_scan_controller_path(scan_type, should_use_scan_service)
controller_path = self.get_scan_controller_path(scan_type)
return f'{service_path}/{controller_path}'

def content_scan(self, scan_type: str, file_name: str, content: str, is_git_diff: bool = True) -> models.ScanResult:
Expand Down Expand Up @@ -185,12 +185,16 @@ 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'
@staticmethod
def get_scan_detections_list_path_suffix(scan_type: str) -> str:
# we don't use async flow for IaC scan yet
if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
return ''

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

def get_scan_detections_list_path(self, scan_type: str) -> str:
return f'{self.get_scan_detections_path(scan_type)}{self.get_scan_detections_list_path_suffix(scan_type)}'

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