Skip to content

Commit 292a719

Browse files
authored
CM-32048 - Fix scans runs for non-admin users (#208)
1 parent 9465e88 commit 292a719

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

cycode/cyclient/scan_client.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@ def __init__(
2020
self.scan_cycode_client = scan_cycode_client
2121
self.scan_config = scan_config
2222

23-
self._SCAN_CONTROLLER_PATH = 'api/v1/scan'
24-
self._SCAN_CONTROLLER_PATH_SCA = 'api/v1/cli-scan'
23+
self._SCAN_SERVICE_CONTROLLER_PATH = 'api/v1/scan'
24+
self._SCAN_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/cli-scan'
2525

2626
self._DETECTIONS_SERVICE_CONTROLLER_PATH = 'api/v1/detections'
27-
self._DETECTIONS_SERVICE_CONTROLLER_PATH_SCA = 'api/v1/detections/cli'
27+
self._DETECTIONS_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/detections/cli'
2828

2929
self.POLICIES_SERVICE_CONTROLLER_PATH_V3 = 'api/v3/policies'
3030

3131
self._hide_response_log = hide_response_log
3232

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

39-
return self._SCAN_CONTROLLER_PATH
38+
return self._SCAN_SERVICE_CLI_CONTROLLER_PATH
4039

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

45-
return self._DETECTIONS_SERVICE_CONTROLLER_PATH
45+
return self._DETECTIONS_SERVICE_CLI_CONTROLLER_PATH
4646

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

5252
def content_scan(self, scan_type: str, file_name: str, content: str, is_git_diff: bool = True) -> models.ScanResult:
@@ -185,12 +185,16 @@ def get_detection_rules(
185185
def get_scan_detections_path(self, scan_type: str) -> str:
186186
return f'{self.scan_config.get_detections_prefix()}/{self.get_detections_service_controller_path(scan_type)}'
187187

188-
def get_scan_detections_list_path(self, scan_type: str) -> str:
189-
suffix = ''
190-
if scan_type == consts.SCA_SCAN_TYPE:
191-
suffix = '/detections'
188+
@staticmethod
189+
def get_scan_detections_list_path_suffix(scan_type: str) -> str:
190+
# we don't use async flow for IaC scan yet
191+
if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
192+
return ''
192193

193-
return f'{self.get_scan_detections_path(scan_type)}{suffix}'
194+
return '/detections'
195+
196+
def get_scan_detections_list_path(self, scan_type: str) -> str:
197+
return f'{self.get_scan_detections_path(scan_type)}{self.get_scan_detections_list_path_suffix(scan_type)}'
194198

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

0 commit comments

Comments
 (0)