Skip to content

Commit 53d3d64

Browse files
committed
CM-53929 - Extend ScanConfiguration endpoint to accept remote url and a new result prop
1 parent 57880b4 commit 53d3d64

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

cycode/cli/apps/scan/scan_command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23
from typing import Annotated, Optional
34

@@ -13,6 +14,7 @@
1314
from cycode.cli.utils import scan_utils
1415
from cycode.cli.utils.get_api_client import get_scan_cycode_client
1516
from cycode.cli.utils.sentry import add_breadcrumb
17+
from cycode.cli.apps.scan.remote_url_resolver import _try_get_git_remote_url
1618

1719
_EXPORT_RICH_HELP_PANEL = 'Export options'
1820
_SCA_RICH_HELP_PANEL = 'SCA options'
@@ -161,7 +163,10 @@ def scan_command(
161163
scan_client = get_scan_cycode_client(ctx)
162164
ctx.obj['client'] = scan_client
163165

164-
remote_scan_config = scan_client.get_scan_configuration_safe(scan_type)
166+
# Get remote URL from current working directory
167+
remote_url = _try_get_git_remote_url(os.getcwd())
168+
169+
remote_scan_config = scan_client.get_scan_configuration_safe(scan_type, remote_url)
165170
if remote_scan_config:
166171
excluder.apply_scan_config(str(scan_type), remote_scan_config)
167172

cycode/cyclient/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,15 @@ def build_dto(self, data: dict[str, Any], **_) -> 'SupportedModulesPreferences':
505505
@dataclass
506506
class ScanConfiguration:
507507
scannable_extensions: list[str]
508+
is_repository_ignore_configuration_allowed: bool
508509

509510

510511
class ScanConfigurationSchema(Schema):
511512
class Meta:
512513
unknown = EXCLUDE
513514

514515
scannable_extensions = fields.List(fields.String(), allow_none=True)
516+
is_repository_ignore_configuration_allowed = fields.Boolean(load_default=False)
515517

516518
@post_load
517519
def build_dto(self, data: dict[str, Any], **_) -> 'ScanConfiguration':

cycode/cyclient/scan_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,21 @@ def get_scan_configuration_path(self, scan_type: str) -> str:
280280
correct_scan_type = self.scan_config.get_async_scan_type(scan_type)
281281
return f'{self.get_scan_service_url_path(scan_type)}/{correct_scan_type}/configuration'
282282

283-
def get_scan_configuration(self, scan_type: str) -> models.ScanConfiguration:
283+
def get_scan_configuration(self, scan_type: str, remote_url: Optional[str] = None) -> models.ScanConfiguration:
284+
params = {}
285+
if remote_url:
286+
params['remote_url'] = remote_url
287+
284288
response = self.scan_cycode_client.get(
285289
url_path=self.get_scan_configuration_path(scan_type),
290+
params=params,
286291
hide_response_content_log=self._hide_response_log,
287292
)
288293
return models.ScanConfigurationSchema().load(response.json())
289294

290-
def get_scan_configuration_safe(self, scan_type: str) -> Optional['models.ScanConfiguration']:
295+
def get_scan_configuration_safe(self, scan_type: str, remote_url: Optional[str] = None) -> Optional['models.ScanConfiguration']:
291296
try:
292-
return self.get_scan_configuration(scan_type)
297+
return self.get_scan_configuration(scan_type, remote_url)
293298
except RequestHttpError as e:
294299
if e.status_code == 404:
295300
logger.debug(

0 commit comments

Comments
 (0)