cycode 3.11.1.dev1__py3-none-any.whl → 3.11.2.dev3__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
@@ -1 +1 @@
1
- __version__ = '3.11.1.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
1
+ __version__ = '3.11.2.dev3' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -0,0 +1,72 @@
1
+ _CONTROL_CHARS = b'\n\r\t\f\b'
2
+ _PRINTABLE_ASCII = _CONTROL_CHARS + bytes(range(32, 127))
3
+ _PRINTABLE_HIGH_ASCII = bytes(range(127, 256))
4
+
5
+ # BOM signatures for encodings that legitimately contain null bytes
6
+ _BOM_ENCODINGS = (
7
+ (b'\xff\xfe\x00\x00', 'utf-32-le'),
8
+ (b'\x00\x00\xfe\xff', 'utf-32-be'),
9
+ (b'\xff\xfe', 'utf-16-le'),
10
+ (b'\xfe\xff', 'utf-16-be'),
11
+ )
12
+
13
+
14
+ def _has_bom_encoding(bytes_to_check: bytes) -> bool:
15
+ """Check if bytes start with a BOM and can be decoded as that encoding."""
16
+ for bom, encoding in _BOM_ENCODINGS:
17
+ if bytes_to_check.startswith(bom):
18
+ try:
19
+ bytes_to_check.decode(encoding)
20
+ return True
21
+ except (UnicodeDecodeError, LookupError):
22
+ pass
23
+ return False
24
+
25
+
26
+ def _is_decodable_as_utf8(bytes_to_check: bytes) -> bool:
27
+ """Try to decode bytes as UTF-8."""
28
+ try:
29
+ bytes_to_check.decode('utf-8')
30
+ return True
31
+ except UnicodeDecodeError:
32
+ return False
33
+
34
+
35
+ def is_binary_string(bytes_to_check: bytes) -> bool:
36
+ """Check if a chunk of bytes appears to be binary content.
37
+
38
+ Uses a simplified version of the Perl detection algorithm, matching
39
+ the structure of binaryornot's is_binary_string.
40
+ """
41
+ if not bytes_to_check:
42
+ return False
43
+
44
+ # Binary if control chars are > 30% of the string
45
+ low_chars = bytes_to_check.translate(None, _PRINTABLE_ASCII)
46
+ nontext_ratio1 = len(low_chars) / len(bytes_to_check)
47
+
48
+ # Binary if high ASCII chars are < 5% of the string
49
+ high_chars = bytes_to_check.translate(None, _PRINTABLE_HIGH_ASCII)
50
+ nontext_ratio2 = len(high_chars) / len(bytes_to_check)
51
+
52
+ is_likely_binary = (nontext_ratio1 > 0.3 and nontext_ratio2 < 0.05) or (
53
+ nontext_ratio1 > 0.8 and nontext_ratio2 > 0.8
54
+ )
55
+
56
+ # BOM-marked UTF-16/32 files legitimately contain null bytes.
57
+ # Check this first so they aren't misdetected as binary.
58
+ if _has_bom_encoding(bytes_to_check):
59
+ return False
60
+
61
+ has_null_or_xff = b'\x00' in bytes_to_check or b'\xff' in bytes_to_check
62
+
63
+ if is_likely_binary:
64
+ # Only let UTF-8 rescue data that doesn't contain null bytes.
65
+ # Null bytes are valid UTF-8 but almost never appear in real text files,
66
+ # whereas binary formats (e.g. .DS_Store) are full of them.
67
+ if has_null_or_xff:
68
+ return True
69
+ return not _is_decodable_as_utf8(bytes_to_check)
70
+
71
+ # Null bytes or 0xff in otherwise normal-looking data indicate binary
72
+ return bool(has_null_or_xff)
@@ -4,9 +4,9 @@ from functools import cache
4
4
  from typing import TYPE_CHECKING, AnyStr, Optional, Union
5
5
 
6
6
  import typer
7
- from binaryornot.helpers import is_binary_string
8
7
 
9
8
  from cycode.cli.logger import logger
9
+ from cycode.cli.utils.binary_utils import is_binary_string
10
10
 
11
11
  if TYPE_CHECKING:
12
12
  from os import PathLike
@@ -5,9 +5,8 @@ import re
5
5
  import string
6
6
  from sys import getsizeof
7
7
 
8
- from binaryornot.check import is_binary_string
9
-
10
8
  from cycode.cli.consts import SCA_SHORTCUT_DEPENDENCY_PATHS
9
+ from cycode.cli.utils.binary_utils import is_binary_string
11
10
 
12
11
 
13
12
  def obfuscate_text(text: str) -> str:
cycode/logger.py CHANGED
@@ -31,8 +31,6 @@ logging.getLogger('urllib3').setLevel(logging.WARNING)
31
31
  logging.getLogger('werkzeug').setLevel(logging.WARNING)
32
32
  logging.getLogger('schedule').setLevel(logging.WARNING)
33
33
  logging.getLogger('kubernetes').setLevel(logging.WARNING)
34
- logging.getLogger('binaryornot').setLevel(logging.WARNING)
35
- logging.getLogger('chardet').setLevel(logging.WARNING)
36
34
  logging.getLogger('git.cmd').setLevel(logging.WARNING)
37
35
  logging.getLogger('git.util').setLevel(logging.WARNING)
38
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.11.1.dev1
3
+ Version: 3.11.2.dev3
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
@@ -21,7 +21,6 @@ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Programming Language :: Python :: 3.14
23
23
  Requires-Dist: arrow (>=1.0.0,<1.4.0)
24
- Requires-Dist: binaryornot (>=0.4.4,<0.5.0)
25
24
  Requires-Dist: click (>=8.1.0,<8.2.0)
26
25
  Requires-Dist: colorama (>=0.4.3,<0.5.0)
27
26
  Requires-Dist: gitpython (>=3.1.30,<3.2.0)
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=LmEv_eTnVWIpaj8EspLxK9RsVZ4218lM_KAUQhtZu3Q,115
1
+ cycode/__init__.py,sha256=uskWVsGbIZ6nDtSOuv-mU-bVAnJ1o7esn0JsYiFZmHk,115
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=euQuMmLSM7Flq-mIPrie1ogdk09t1l6R_B6PQE_ib8w,6348
@@ -157,17 +157,18 @@ cycode/cli/user_settings/configuration_manager.py,sha256=8nTogrLRAMXKM13Zd_lvaL9
157
157
  cycode/cli/user_settings/credentials_manager.py,sha256=gDCyaBTT4qaayKmRBk65kPB2pRG6GalrO5GvnVL3NiI,3958
158
158
  cycode/cli/user_settings/jwt_creator.py,sha256=xEkFLFqhwbNJnXuIi02XDxoj2E-4Nw-m10uJaHl3luA,745
159
159
  cycode/cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
160
+ cycode/cli/utils/binary_utils.py,sha256=PxP-rVJ1lEiOam-DQ1XU68oWtfwup4sCFHXv54cfZkY,2528
160
161
  cycode/cli/utils/enum_utils.py,sha256=h_VTCfJ-0hnhwDsEznmx56rJrCb5FQ8u6PrI6p8MP3E,187
161
162
  cycode/cli/utils/get_api_client.py,sha256=wwHabfVCDbFjcIwOn5Raho8MEPiOAgkHlGUEfXKpl8U,3542
162
163
  cycode/cli/utils/git_proxy.py,sha256=FPHMBiyLFK9X9vKYpKySRKJH6Dc9Cb3nO241Q95dASE,2911
163
164
  cycode/cli/utils/ignore_utils.py,sha256=cODqhnOHA2kRo8rMY0YcmcKkmXNPOC9UTCmFu62RRqE,15567
164
165
  cycode/cli/utils/jwt_utils.py,sha256=TfTHCCCxKO6RvSKT2qspx4577Gax3n9YRj2UgigpGuQ,537
165
- cycode/cli/utils/path_utils.py,sha256=OmAOtZwvPmYqqhBnB4jI6hkSnCkGpSOibY7PtP213Cc,3235
166
+ cycode/cli/utils/path_utils.py,sha256=U5te1unzhs9pnU5d9BWExgFWElHQkgKvFxKiOF-lp-w,3245
166
167
  cycode/cli/utils/progress_bar.py,sha256=bKBWHHdZsVkdDdWMJLfgLGR0cBYeB44P_DpRM8pvWqU,9528
167
168
  cycode/cli/utils/scan_batch.py,sha256=5xKGVDVqoRxdKhuZkK11x4QrNqKmU20Q83E_fy8Nndk,5188
168
169
  cycode/cli/utils/scan_utils.py,sha256=sTj7j9dVHcgeMqfYp8sO78ZiWX8LnhpgjCOi1N1gmAM,2248
169
170
  cycode/cli/utils/shell_executor.py,sha256=VkzzQPZCmTkFvDjhgJrkv-Icej3U1wLW9LLN6k6OahA,1848
170
- cycode/cli/utils/string_utils.py,sha256=0kvu_apAfHjwd7dUhZl8k1pr57aCiO1MhzBYnA2keK4,2434
171
+ cycode/cli/utils/string_utils.py,sha256=KyPSAHDRPEGNCCcKTF0v99vad5z9djpVGc8nxpBqdYo,2445
171
172
  cycode/cli/utils/task_timer.py,sha256=wxfM2TtJGjc1F17CIja_Qmt6zd4a1qdMwuz0ltgTDAg,2722
172
173
  cycode/cli/utils/url_utils.py,sha256=2ZhRCbQsKnvAl5MBugQ5CrwuALP8uivsCI6chlqxahM,2304
173
174
  cycode/cli/utils/version_checker.py,sha256=0f5PaTk02ZkDxzBqZOeMV9mU_CWcx6HKW80jUKFOOZs,8239
@@ -193,9 +194,9 @@ cycode/cyclient/models.py,sha256=pHiJpj9TVPmn7bAK3uhx4Yc4unyo9llUoCoJKeDhDnM,154
193
194
  cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ-cM,4399
194
195
  cycode/cyclient/scan_client.py,sha256=iLBLFO9IyAroLAMAo51FLaCHkquYNsSlEqumznW9k9A,15552
195
196
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
196
- cycode/logger.py,sha256=xAzpkWLZhixO4egRcYn4HXM9lIfx5wHdpkHxNc5jrX8,2225
197
- cycode-3.11.1.dev1.dist-info/METADATA,sha256=frtjLiDKOl18jo1NqScwO-D7eqHKbxjsBuJEPl9pmdM,81596
198
- cycode-3.11.1.dev1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
199
- cycode-3.11.1.dev1.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
200
- cycode-3.11.1.dev1.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
201
- cycode-3.11.1.dev1.dist-info/RECORD,,
197
+ cycode/logger.py,sha256=EfZGRK6VC5rE_LAjIcRrHFiQCueylCDXoG6bvGkrIME,2111
198
+ cycode-3.11.2.dev3.dist-info/METADATA,sha256=3V2Be-u5RnIHT-gC3S9jcxNwwVCPTQzvNK_fmNDltg8,81552
199
+ cycode-3.11.2.dev3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
200
+ cycode-3.11.2.dev3.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
201
+ cycode-3.11.2.dev3.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
202
+ cycode-3.11.2.dev3.dist-info/RECORD,,