cycode 3.24.3.dev1__py3-none-any.whl → 3.24.3.dev2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cycode/__init__.py CHANGED
@@ -5,4 +5,4 @@ import time as _time
5
5
  # end-to-end scan duration from the moment the user actually triggered it.
6
6
  _BOOT_WALL: float = _time.time()
7
7
 
8
- __version__ = '3.24.3.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
8
+ __version__ = '3.24.3.dev2' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -7,7 +7,7 @@ from cycode.cli import consts
7
7
  from cycode.cli.apps.scan.aggregation_report import try_get_aggregation_report_url_if_needed
8
8
  from cycode.cli.apps.scan.detection_excluder import exclude_irrelevant_document_detections
9
9
  from cycode.cli.models import Document, DocumentDetections, LocalScanResult
10
- from cycode.cli.utils.path_utils import concat_unique_id, get_path_by_os, normalize_file_path
10
+ from cycode.cli.utils.path_utils import concat_unique_id, normalize_file_path
11
11
  from cycode.cyclient.models import (
12
12
  Detection,
13
13
  DetectionSchema,
@@ -49,7 +49,7 @@ def _get_document_detections(
49
49
 
50
50
  document_detections = []
51
51
  for detections_per_file in scan_result.detections_per_file:
52
- file_name = get_path_by_os(detections_per_file.file_name)
52
+ file_name = detections_per_file.file_name
53
53
  commit_id = detections_per_file.commit_id
54
54
 
55
55
  logger.debug(
cycode/cli/consts.py CHANGED
@@ -1,7 +1,27 @@
1
+ import sys
2
+ from enum import Enum
3
+
1
4
  PROGRAM_NAME = 'cycode'
2
5
  APP_NAME = 'CycodeCLI'
3
6
  CLI_CONTEXT_SETTINGS = {'terminal_width': 10**9, 'max_content_width': 10**9, 'help_option_names': ['-h', '--help']}
4
7
 
8
+
9
+ class OperatingSystem(str, Enum):
10
+ WINDOWS = 'windows'
11
+ MACOS = 'macos'
12
+ LINUX = 'linux'
13
+
14
+
15
+ def _detect_operating_system() -> OperatingSystem:
16
+ if sys.platform == 'win32':
17
+ return OperatingSystem.WINDOWS
18
+ if sys.platform == 'darwin':
19
+ return OperatingSystem.MACOS
20
+ return OperatingSystem.LINUX
21
+
22
+
23
+ OPERATING_SYSTEM = _detect_operating_system()
24
+
5
25
  PRE_COMMIT_COMMAND_SCAN_TYPE = 'pre-commit'
6
26
  PRE_COMMIT_COMMAND_SCAN_TYPE_OLD = 'pre_commit'
7
27
  PRE_RECEIVE_COMMAND_SCAN_TYPE = 'pre-receive'
@@ -2,10 +2,12 @@ import json
2
2
  import os
3
3
  import tempfile
4
4
  from functools import cache
5
+ from pathlib import PurePath, PurePosixPath, PureWindowsPath
5
6
  from typing import TYPE_CHECKING, AnyStr, Optional, Union
6
7
 
7
8
  import typer
8
9
 
10
+ from cycode.cli.consts import OPERATING_SYSTEM, OperatingSystem
9
11
  from cycode.cli.logger import logger
10
12
  from cycode.cli.utils.binary_utils import is_binary_string
11
13
 
@@ -125,12 +127,29 @@ def change_filename_extension(filename: str, extension: str) -> str:
125
127
  return f'{base_name}.{extension}'
126
128
 
127
129
 
130
+ def _to_relative_posix_parts(path: str, operating_system: OperatingSystem = OPERATING_SYSTEM) -> tuple[str, ...]:
131
+ """Split a path into OS-agnostic components: drop the root, keep the UNC server and share.
132
+
133
+ The archive entry name is read back by the server as ``<unique id>/<path>``, so it must use forward slashes
134
+ and must never start with a root. The flavor comes from the running OS rather than from the path itself, so
135
+ a colon in a POSIX file name is not mistaken for a drive letter.
136
+ """
137
+ pure: PurePath = PureWindowsPath(path) if operating_system is OperatingSystem.WINDOWS else PurePosixPath(path)
138
+ if not pure.anchor:
139
+ return pure.parts
140
+
141
+ # the anchor is 'C:\\', '/' or '\\\\server\\share\\': keep the names it carries, drop the drive and separators
142
+ anchor_parts = tuple(p for p in pure.anchor.replace('\\', '/').split('/') if p and not p.endswith(':'))
143
+ return anchor_parts + pure.parts[1:]
144
+
145
+
128
146
  def concat_unique_id(filename: str, unique_id: str) -> str:
129
- if filename.startswith(os.sep):
130
- # remove leading slash to join the path correctly
131
- filename = filename[len(os.sep) :]
147
+ """Prefix the file name with the unique id (e.g. a commit SHA) to build the name of the archive entry.
132
148
 
133
- return os.path.join(unique_id, filename)
149
+ The server reads the unique id back from the first path component, so the file name must become relative
150
+ before joining; otherwise the prefix is lost and a Windows drive letter is reported as the commit id.
151
+ """
152
+ return str(PurePosixPath(unique_id, *_to_relative_posix_parts(filename)))
134
153
 
135
154
 
136
155
  def get_path_from_context(ctx: typer.Context) -> Optional[str]:
@@ -141,8 +160,6 @@ def get_path_from_context(ctx: typer.Context) -> Optional[str]:
141
160
 
142
161
 
143
162
  def normalize_file_path(path: str) -> str:
144
- if path.startswith('/'):
145
- return path[1:]
146
- if path.startswith('./'):
147
- return path[2:]
148
- return path
163
+ """Make a path comparable with the file name the server reports back: no drive, no root, forward slashes."""
164
+ parts = _to_relative_posix_parts(path)
165
+ return str(PurePosixPath(*parts)) if parts else ''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.24.3.dev1
3
+ Version: 3.24.3.dev2
4
4
  Summary: Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning.
5
5
  License-Expression: MIT
6
6
  License-File: LICENCE
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=wtCAJfg1G9S77BjTZnEOGdvsx7uh8NyJbPhKu69su18,396
1
+ cycode/__init__.py,sha256=HK6TLsMHRMhqe6vN-erC38DYM3L6-4xpzMznXT18zCk,396
2
2
  cycode/__main__.py,sha256=Z3bD5yrA7yPvAChcADQrqCaZd0ChGI1gdiwALwbWJ6U,104
3
3
  cycode/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cycode/cli/app.py,sha256=AlR2durAEbsa47PDfIj7JtMvJDWA_Dq6wPtVuMJYSCs,10250
@@ -89,7 +89,7 @@ cycode/cli/apps/scan/scan_ci/ci_integrations.py,sha256=3ZUv1uLsHC13KTNQ4erQKKDXA
89
89
  cycode/cli/apps/scan/scan_ci/scan_ci_command.py,sha256=37I6YTs5UWYtbnDe1EeYZnhV1twFTDUrniZ4Sf2_6Kk,562
90
90
  cycode/cli/apps/scan/scan_command.py,sha256=_XN1Pz21-rRFKYxN-Bn_iDtEd1zE4drcSfSa1b4b5Us,7988
91
91
  cycode/cli/apps/scan/scan_parameters.py,sha256=F7SCTuTR_iGfztvwapVJjjq9mXhuQv9EvcaX-YyiILI,1481
92
- cycode/cli/apps/scan/scan_result.py,sha256=13gmFugcQ_ksgpImhiLOfuQ1bEp0gcJhTiszl6dBy14,9167
92
+ cycode/cli/apps/scan/scan_result.py,sha256=pnepGlmsJEl9jRFCsQzyBvlwpZYvi5PzkCAfvaLZeL0,9135
93
93
  cycode/cli/apps/status/__init__.py,sha256=uxfkEBafO7Da0mPc1fZhwoO0RTtyXp2a5T3LJTZxubU,371
94
94
  cycode/cli/apps/status/get_cli_status.py,sha256=1UAVyKPpYk2S8nQYshKD1x5xgWR-hCTchLChxNU0JVA,2577
95
95
  cycode/cli/apps/status/models.py,sha256=2SBpJlh_MNCPxv8aXMV5D4GfK6-G-XB0GlMFZ3Nep_o,1907
@@ -98,7 +98,7 @@ cycode/cli/apps/status/version_command.py,sha256=c6Iko_rmZo9T_kQSd3HUloBi40Qv7cj
98
98
  cycode/cli/cli_types.py,sha256=Xqf2eSx3yUvFoQG29ObUZ3QLVBhtZ4mkqxf_cJXpntU,3406
99
99
  cycode/cli/config.py,sha256=Op-lX_neanJtvPvoOEx4ByBdveh5ygElIga1FdSHhOI,299
100
100
  cycode/cli/console.py,sha256=vp-DHwlkwpwdsPyfwGdjsPF-6-Bi3f8W7G-W_YXCMH8,1914
101
- cycode/cli/consts.py,sha256=UnYIqdoYbfSBP64UTwNhVzhyNdJA0N-0-dOgOR3eI98,10754
101
+ cycode/cli/consts.py,sha256=jI1M2PolPIIodJMphQYrTbzCOrjO3umjb6R92h1Ntww,11163
102
102
  cycode/cli/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  cycode/cli/exceptions/custom_exceptions.py,sha256=ko1A5vw6s5Q1OVtQirjWV_3igTL1_Y5bzvT39WPOB2U,4913
104
104
  cycode/cli/exceptions/handle_ai_remediation_errors.py,sha256=mA70upSYXK3rL_fmanzKYeUzLENhpXdkW8k3aIHrKzU,785
@@ -183,7 +183,7 @@ cycode/cli/utils/git_proxy.py,sha256=FPHMBiyLFK9X9vKYpKySRKJH6Dc9Cb3nO241Q95dASE
183
183
  cycode/cli/utils/host_info.py,sha256=Clln3qCJR00rw6HndD0bAIv329n_bOEx42TKW6FqXFQ,6379
184
184
  cycode/cli/utils/ignore_utils.py,sha256=cODqhnOHA2kRo8rMY0YcmcKkmXNPOC9UTCmFu62RRqE,15567
185
185
  cycode/cli/utils/jwt_utils.py,sha256=EGI-0CKhCGY8hIcZ9b9diq9hqtOUf8Ha8ukeVJIf974,818
186
- cycode/cli/utils/path_utils.py,sha256=zc48CSU7hxqjSgfH6h5M1B0kIcKW44BOJrUa_6z-mAo,4317
186
+ cycode/cli/utils/path_utils.py,sha256=YlAUz2seaKT25ggqcnAjxqQd1oUlXTn1LIebBOht4nQ,5699
187
187
  cycode/cli/utils/progress_bar.py,sha256=bKBWHHdZsVkdDdWMJLfgLGR0cBYeB44P_DpRM8pvWqU,9528
188
188
  cycode/cli/utils/scan_batch.py,sha256=5xKGVDVqoRxdKhuZkK11x4QrNqKmU20Q83E_fy8Nndk,5188
189
189
  cycode/cli/utils/scan_utils.py,sha256=_VkZ7maLVST6J8dsqDsKYWQj2EVfqI3iPPsA1QJOGEU,1259
@@ -217,8 +217,8 @@ cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ
217
217
  cycode/cyclient/scan_client.py,sha256=DqAZ7u6Z_cvw9A9RlLkAQUgLRwPCCAsUq5U9umt4F7Y,16955
218
218
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
219
219
  cycode/logger.py,sha256=EfZGRK6VC5rE_LAjIcRrHFiQCueylCDXoG6bvGkrIME,2111
220
- cycode-3.24.3.dev1.dist-info/METADATA,sha256=A9vzVVmsboZ4zKuuDIw4JT2uc7tj9yzLZyZcP5_Lpb8,94757
221
- cycode-3.24.3.dev1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
222
- cycode-3.24.3.dev1.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
223
- cycode-3.24.3.dev1.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
224
- cycode-3.24.3.dev1.dist-info/RECORD,,
220
+ cycode-3.24.3.dev2.dist-info/METADATA,sha256=v_UoGBhf9pWwpmMaE8u9wNCX07CnnGT9XgQA2Hbq2BM,94757
221
+ cycode-3.24.3.dev2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
222
+ cycode-3.24.3.dev2.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
223
+ cycode-3.24.3.dev2.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
224
+ cycode-3.24.3.dev2.dist-info/RECORD,,