cycode 3.22.1.dev9__py3-none-any.whl → 3.22.2.dev1__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.22.1.dev9' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
8
+ __version__ = '3.22.2.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -4,17 +4,28 @@ import platform
4
4
  import re
5
5
  import socket
6
6
  import subprocess
7
+ import sys
7
8
  import tempfile
8
9
  from pathlib import Path
9
- from typing import Optional
10
+ from typing import Any, Optional
10
11
 
12
+ from cycode.cli.consts import CYCODE_CONFIGURATION_DIRECTORY
11
13
  from cycode.logger import get_logger
12
14
 
13
15
  logger = get_logger('HOST INFO')
14
16
 
17
+ pythoncom: Optional[Any] = None
18
+ win32com_client: Optional[Any] = None
19
+ if sys.platform == 'win32':
20
+ try:
21
+ import pythoncom
22
+ import win32com.client as win32com_client
23
+ except ImportError as e:
24
+ logger.debug('pywin32 is unavailable', exc_info=e)
25
+
15
26
  _SUBPROCESS_TIMEOUT_SEC = 5
16
27
 
17
- _SERIAL_NUMBER_CACHE_FILE_NAME = '.cycode-device-serial'
28
+ _DEVICE_ID_CACHE_FILE_NAME = 'device-id'
18
29
 
19
30
  _PLATFORM_NAMES = {'Darwin': 'macOS', 'Windows': 'Windows', 'Linux': 'Linux'}
20
31
 
@@ -123,8 +134,7 @@ def _resolve_serial_number() -> Optional[str]:
123
134
 
124
135
 
125
136
  def _serial_number_cache_path() -> Path:
126
- # The username suffix avoids collisions on OSes with a shared temp dir
127
- return Path(tempfile.gettempdir()) / f'.cycode-device-serial-{getpass.getuser()}'
137
+ return Path.home() / CYCODE_CONFIGURATION_DIRECTORY / _DEVICE_ID_CACHE_FILE_NAME
128
138
 
129
139
 
130
140
  def _read_serial_number_cache() -> Optional[str]:
@@ -137,14 +147,13 @@ def _read_serial_number_cache() -> Optional[str]:
137
147
  def _write_serial_number_cache(serial: str) -> None:
138
148
  try:
139
149
  cache_path = _serial_number_cache_path()
150
+ cache_path.parent.mkdir(parents=True, exist_ok=True)
140
151
 
141
- # The serial identifies the machine, and the temp dir is shared, so the cache is created
142
- # readable by its owner alone (what mkstemp does) and moved into place atomically - a hook
143
- # racing another one never reads a half-written cache, and the rename can't be redirected
144
- # by a symlink planted at the destination the way an in-place write could.
145
- file_descriptor, temp_path = tempfile.mkstemp(
146
- dir=cache_path.parent, prefix=f'{_SERIAL_NUMBER_CACHE_FILE_NAME}.'
147
- )
152
+ # The serial identifies the machine, so the cache is created readable by its owner alone
153
+ # (what mkstemp does) and moved into place atomically - a hook racing another one never
154
+ # reads a half-written cache, and the rename can't be redirected by a symlink planted at
155
+ # the destination the way an in-place write could.
156
+ file_descriptor, temp_path = tempfile.mkstemp(dir=cache_path.parent, prefix=f'{_DEVICE_ID_CACHE_FILE_NAME}.')
148
157
  try:
149
158
  with os.fdopen(file_descriptor, 'w', encoding='utf-8') as temp_file:
150
159
  temp_file.write(serial)
@@ -165,15 +174,17 @@ def _get_macos_serial_number() -> Optional[str]:
165
174
 
166
175
 
167
176
  def _get_windows_serial_number() -> Optional[str]:
168
- import pythoncom # from pywin32
169
- import win32com.client # from pywin32
177
+ """Read the OEM serial over WMI."""
178
+ if pythoncom is None or win32com_client is None:
179
+ return None
170
180
 
171
181
  pythoncom.CoInitialize()
172
182
  try:
173
- wmi_service = win32com.client.GetObject('winmgmts:')
183
+ wmi_service = win32com_client.GetObject('winmgmts:')
174
184
  for bios in wmi_service.InstancesOf('Win32_BIOS'):
175
185
  serial = bios.SerialNumber
176
- return serial.strip() if serial else None
186
+ # whitespace-only is what whiteboxes and some hypervisors report
187
+ return serial.strip() or None if serial else None
177
188
  finally:
178
189
  pythoncom.CoUninitialize()
179
190
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.22.1.dev9
3
+ Version: 3.22.2.dev1
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
@@ -31,6 +31,7 @@ Requires-Dist: patch-ng (==1.19.1)
31
31
  Requires-Dist: pathvalidate (>=3.3.1,<4.0.0)
32
32
  Requires-Dist: pydantic (>=2.11.5,<3.0.0)
33
33
  Requires-Dist: pyjwt (>=2.8.0,<3.0)
34
+ Requires-Dist: pywin32 (>=312,<313) ; python_version >= "3.10" and sys_platform == "win32"
34
35
  Requires-Dist: pyyaml (>=6.0,<7.0)
35
36
  Requires-Dist: requests (>=2.32.4,<3.0)
36
37
  Requires-Dist: rich (>=15.0.0,<16.0.0)
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=iAjqbqSdZ4uVb_yXz3TvQhIR1SZTNWO5X0HG8mjm9qg,396
1
+ cycode/__init__.py,sha256=IbX4HQYnASwTZbZGmXccsZTYx86SWJuZrmMHgzWQShQ,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
@@ -178,7 +178,7 @@ cycode/cli/utils/binary_utils.py,sha256=PxP-rVJ1lEiOam-DQ1XU68oWtfwup4sCFHXv54cf
178
178
  cycode/cli/utils/enum_utils.py,sha256=h_VTCfJ-0hnhwDsEznmx56rJrCb5FQ8u6PrI6p8MP3E,187
179
179
  cycode/cli/utils/get_api_client.py,sha256=wwHabfVCDbFjcIwOn5Raho8MEPiOAgkHlGUEfXKpl8U,3542
180
180
  cycode/cli/utils/git_proxy.py,sha256=FPHMBiyLFK9X9vKYpKySRKJH6Dc9Cb3nO241Q95dASE,2911
181
- cycode/cli/utils/host_info.py,sha256=0YhSh2gCS7PoVK0pcBFZkjjczHX48j1n4Uck8JPGDR0,5868
181
+ cycode/cli/utils/host_info.py,sha256=ba3scmnOJQOtNpVT-rf2-FKb0ocGzpPUONsG-uxmhro,6249
182
182
  cycode/cli/utils/ignore_utils.py,sha256=cODqhnOHA2kRo8rMY0YcmcKkmXNPOC9UTCmFu62RRqE,15567
183
183
  cycode/cli/utils/jwt_utils.py,sha256=EGI-0CKhCGY8hIcZ9b9diq9hqtOUf8Ha8ukeVJIf974,818
184
184
  cycode/cli/utils/path_utils.py,sha256=U5te1unzhs9pnU5d9BWExgFWElHQkgKvFxKiOF-lp-w,3245
@@ -215,8 +215,8 @@ cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ
215
215
  cycode/cyclient/scan_client.py,sha256=DqAZ7u6Z_cvw9A9RlLkAQUgLRwPCCAsUq5U9umt4F7Y,16955
216
216
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
217
217
  cycode/logger.py,sha256=EfZGRK6VC5rE_LAjIcRrHFiQCueylCDXoG6bvGkrIME,2111
218
- cycode-3.22.1.dev9.dist-info/METADATA,sha256=LXtTUVmEVKmVB8mYYx7Kkj3XoIIwnoHjbn-rbPOmxmw,93596
219
- cycode-3.22.1.dev9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
220
- cycode-3.22.1.dev9.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
221
- cycode-3.22.1.dev9.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
222
- cycode-3.22.1.dev9.dist-info/RECORD,,
218
+ cycode-3.22.2.dev1.dist-info/METADATA,sha256=s_JlmuVuOTttmb8LRd1cY_D5t6tMC_SR6qkpTe2HYhs,93687
219
+ cycode-3.22.2.dev1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
220
+ cycode-3.22.2.dev1.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
221
+ cycode-3.22.2.dev1.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
222
+ cycode-3.22.2.dev1.dist-info/RECORD,,