cycode 3.10.1.dev3__py3-none-any.whl → 3.10.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
@@ -1 +1 @@
1
- __version__ = '3.10.1.dev3' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
1
+ __version__ = '3.10.2.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -7,6 +7,9 @@ import typer
7
7
  from cycode.cli.models import Document
8
8
  from cycode.cli.utils.path_utils import get_file_content, get_file_dir, get_path_from_context, join_paths
9
9
  from cycode.cli.utils.shell_executor import shell
10
+ from cycode.logger import get_logger
11
+
12
+ logger = get_logger('SCA Restore')
10
13
 
11
14
 
12
15
  def build_dep_tree_path(path: str, generated_file_name: str) -> str:
@@ -19,6 +22,16 @@ def execute_commands(
19
22
  output_file_path: Optional[str] = None,
20
23
  working_directory: Optional[str] = None,
21
24
  ) -> Optional[str]:
25
+ logger.debug(
26
+ 'Executing restore commands, %s',
27
+ {
28
+ 'commands_count': len(commands),
29
+ 'timeout_sec': timeout,
30
+ 'working_directory': working_directory,
31
+ 'output_file_path': output_file_path,
32
+ },
33
+ )
34
+
22
35
  try:
23
36
  outputs = []
24
37
 
@@ -32,7 +45,8 @@ def execute_commands(
32
45
  if output_file_path:
33
46
  with open(output_file_path, 'w', encoding='UTF-8') as output_file:
34
47
  output_file.writelines(joined_output)
35
- except Exception:
48
+ except Exception as e:
49
+ logger.debug('Unexpected error during command execution', exc_info=e)
36
50
  return None
37
51
 
38
52
  return joined_output
@@ -75,8 +89,21 @@ class BaseRestoreDependencies(ABC):
75
89
  )
76
90
  if output is None: # one of the commands failed
77
91
  return None
92
+ else:
93
+ logger.debug(
94
+ 'Lock file already exists, skipping restore commands, %s',
95
+ {'restore_file_path': restore_file_path},
96
+ )
78
97
 
79
98
  restore_file_content = get_file_content(restore_file_path)
99
+ logger.debug(
100
+ 'Restore file loaded, %s',
101
+ {
102
+ 'restore_file_path': restore_file_path,
103
+ 'content_size': len(restore_file_content) if restore_file_content else 0,
104
+ 'content_empty': not restore_file_content,
105
+ },
106
+ )
80
107
  return Document(relative_restore_file_path, restore_file_content, self.is_git_diff)
81
108
 
82
109
  def get_working_directory(self, document: Document) -> Optional[str]:
@@ -4,8 +4,10 @@ from typing import Optional
4
4
  import typer
5
5
 
6
6
  from cycode.cli.files_collector.sca.base_restore_dependencies import BaseRestoreDependencies
7
- from cycode.cli.logger import logger
8
7
  from cycode.cli.models import Document
8
+ from cycode.logger import get_logger
9
+
10
+ logger = get_logger('Go Restore Dependencies')
9
11
 
10
12
  GO_PROJECT_FILE_EXTENSIONS = ['.mod', '.sum']
11
13
  GO_RESTORE_FILE_NAME = 'go.mod.graph'
@@ -106,11 +106,17 @@ def _try_restore_dependencies(
106
106
 
107
107
  restore_dependencies_document = restore_dependencies.restore(document)
108
108
  if restore_dependencies_document is None:
109
- logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
109
+ logger.warning(
110
+ 'Error occurred while trying to generate dependencies tree, %s',
111
+ {'filename': document.path, 'handler': type(restore_dependencies).__name__},
112
+ )
110
113
  return None
111
114
 
112
115
  if restore_dependencies_document.content is None:
113
- logger.warning('Error occurred while trying to generate dependencies tree, %s', {'filename': document.path})
116
+ logger.warning(
117
+ 'Error occurred while trying to generate dependencies tree, %s',
118
+ {'filename': document.path, 'handler': type(restore_dependencies).__name__},
119
+ )
114
120
  restore_dependencies_document.content = ''
115
121
  else:
116
122
  is_monitor_action = ctx.obj.get('monitor', False)
@@ -124,6 +130,13 @@ def _try_restore_dependencies(
124
130
 
125
131
  def _get_restore_handlers(ctx: typer.Context, is_git_diff: bool) -> list[BaseRestoreDependencies]:
126
132
  build_dep_tree_timeout = int(os.getenv('CYCODE_BUILD_DEP_TREE_TIMEOUT_SECONDS', BUILD_DEP_TREE_TIMEOUT))
133
+ logger.debug(
134
+ 'SCA restore handler timeout, %s',
135
+ {
136
+ 'timeout_sec': build_dep_tree_timeout,
137
+ 'source': 'env' if os.getenv('CYCODE_BUILD_DEP_TREE_TIMEOUT_SECONDS') else 'default',
138
+ },
139
+ )
127
140
  return [
128
141
  RestoreGradleDependencies(ctx, is_git_diff, build_dep_tree_timeout),
129
142
  RestoreMavenDependencies(ctx, is_git_diff, build_dep_tree_timeout),
@@ -1,4 +1,5 @@
1
1
  import subprocess
2
+ import time
2
3
  from typing import Optional, Union
3
4
 
4
5
  import click
@@ -21,15 +22,27 @@ def shell(
21
22
  logger.debug('Executing shell command: %s', command)
22
23
 
23
24
  try:
25
+ start = time.monotonic()
24
26
  result = subprocess.run( # noqa: S603
25
27
  command, cwd=working_directory, timeout=timeout, check=True, capture_output=True
26
28
  )
27
- logger.debug('Shell command executed successfully')
29
+ duration_sec = round(time.monotonic() - start, 2)
30
+ stdout = result.stdout.decode('UTF-8').strip()
31
+ stderr = result.stderr.decode('UTF-8').strip()
28
32
 
29
- return result.stdout.decode('UTF-8').strip()
33
+ logger.debug(
34
+ 'Shell command executed successfully, %s',
35
+ {'duration_sec': duration_sec, 'stdout': stdout if stdout else '', 'stderr': stderr if stderr else ''},
36
+ )
37
+
38
+ return stdout
30
39
  except subprocess.CalledProcessError as e:
31
40
  if not silent_exc_info:
32
41
  logger.debug('Error occurred while running shell command', exc_info=e)
42
+ if e.stdout:
43
+ logger.debug('Shell command stdout: %s', e.stdout.decode('UTF-8').strip())
44
+ if e.stderr:
45
+ logger.debug('Shell command stderr: %s', e.stderr.decode('UTF-8').strip())
33
46
  except subprocess.TimeoutExpired as e:
34
47
  logger.debug('Command timed out', exc_info=e)
35
48
  raise typer.Abort(f'Command "{command}" timed out') from e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.10.1.dev3
3
+ Version: 3.10.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
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=vAAZe6uHmMgzfuFS07mdMtflsmVnaJ8kyzukXDITFD0,115
1
+ cycode/__init__.py,sha256=90HcfqmT0_usCPxHlppFCbiu6IWXpbxpFH8ViXVNyS4,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
@@ -102,9 +102,9 @@ cycode/cli/files_collector/models/in_memory_zip.py,sha256=a56bTdOgg7E3PpWRh0ixVX
102
102
  cycode/cli/files_collector/path_documents.py,sha256=LLmuHf2h6glXwmf44pMnFq1-3HipQXFByfn8lWEO2sA,4782
103
103
  cycode/cli/files_collector/repository_documents.py,sha256=53QQsfCzXXSV6F3EcInaN8G6aCwEVzceWiYwasG8CgM,860
104
104
  cycode/cli/files_collector/sca/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
- cycode/cli/files_collector/sca/base_restore_dependencies.py,sha256=JFZomuJ3DWhxzaOai1meLgHS3y39IQHOY_49OO3LBjM,4148
105
+ cycode/cli/files_collector/sca/base_restore_dependencies.py,sha256=bm3lCaZ9g80iLm7VA5dIza-RLOJfM_JXxHurWuqD-Q8,5067
106
106
  cycode/cli/files_collector/sca/go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- cycode/cli/files_collector/sca/go/restore_go_dependencies.py,sha256=LEck4XPFl9DQ-LcR8-2ZBRfYeKP1XwgATMiuAogfmlE,1848
107
+ cycode/cli/files_collector/sca/go/restore_go_dependencies.py,sha256=_VSSOzTHPnVHhJl7E4NVYUcu9w_qnPmOS3yPLONpyvQ,1896
108
108
  cycode/cli/files_collector/sca/maven/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
109
  cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py,sha256=hwsdJby0_7i3s6YmCU-tB6B3TfsfbyQyeTVwEy6c6SA,2699
110
110
  cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py,sha256=-kCvjVIDGI_eX-l6I0M0OPI6OOhPGyga0e02FQgiFwM,3320
@@ -116,7 +116,7 @@ cycode/cli/files_collector/sca/ruby/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
116
116
  cycode/cli/files_collector/sca/ruby/restore_ruby_dependencies.py,sha256=Vqswcxte9YjGnvIm9oZ8r91jNyhuiYDf1mouaTaLg3U,694
117
117
  cycode/cli/files_collector/sca/sbt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
118
  cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py,sha256=cfBUR4iQcfplX_O2QPjYh2wSyBteze8wZcT_dG9d1d4,709
119
- cycode/cli/files_collector/sca/sca_file_collector.py,sha256=lM7lGNd7AyhyA4-NnS4CbVihSZF0X-Vj04OxqJnsODM,7912
119
+ cycode/cli/files_collector/sca/sca_file_collector.py,sha256=fsxguIdpBHGFZ_HIBCCY2uGAMgOydBW74h86coURIB4,8315
120
120
  cycode/cli/files_collector/walk_ignore.py,sha256=nvOM6oDmT2SxSI4pU-bLlc9LwTgkfTd2egse69ixf3g,2464
121
121
  cycode/cli/files_collector/zip_documents.py,sha256=WTNLp4yHY6zeVYkE2QTOO8K93cJEA9I-BmD39sRdo5k,1837
122
122
  cycode/cli/logger.py,sha256=mlaYEQGYd582fTCc3SC3cFMj0PKTB6EsaI12Q4VL1z8,65
@@ -157,7 +157,7 @@ cycode/cli/utils/path_utils.py,sha256=OmAOtZwvPmYqqhBnB4jI6hkSnCkGpSOibY7PtP213C
157
157
  cycode/cli/utils/progress_bar.py,sha256=bKBWHHdZsVkdDdWMJLfgLGR0cBYeB44P_DpRM8pvWqU,9528
158
158
  cycode/cli/utils/scan_batch.py,sha256=jIG3jPYBptcwPHcTze0goFs4etCAOyKahdhUNPBsufw,5106
159
159
  cycode/cli/utils/scan_utils.py,sha256=j3nkm7KxO1nCjPDppdTWzmo7gNw1XfRUlhfeY66xGNw,2100
160
- cycode/cli/utils/shell_executor.py,sha256=CuHeXoYM6VaYtDernWtf49_s1EfuU8nWxj4MPIAciww,1290
160
+ cycode/cli/utils/shell_executor.py,sha256=VkzzQPZCmTkFvDjhgJrkv-Icej3U1wLW9LLN6k6OahA,1848
161
161
  cycode/cli/utils/string_utils.py,sha256=0kvu_apAfHjwd7dUhZl8k1pr57aCiO1MhzBYnA2keK4,2434
162
162
  cycode/cli/utils/task_timer.py,sha256=wxfM2TtJGjc1F17CIja_Qmt6zd4a1qdMwuz0ltgTDAg,2722
163
163
  cycode/cli/utils/url_utils.py,sha256=2ZhRCbQsKnvAl5MBugQ5CrwuALP8uivsCI6chlqxahM,2304
@@ -185,8 +185,8 @@ cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ
185
185
  cycode/cyclient/scan_client.py,sha256=uTBEjgfaCVuJREo73p_zkIVA23NQfdJ1d1-bzc7nSKk,12682
186
186
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
187
187
  cycode/logger.py,sha256=xAzpkWLZhixO4egRcYn4HXM9lIfx5wHdpkHxNc5jrX8,2225
188
- cycode-3.10.1.dev3.dist-info/METADATA,sha256=KFvBjEj-TI39dNW2OvoYXyAU7zzP4UNcE9iKVsCnxgk,79688
189
- cycode-3.10.1.dev3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
190
- cycode-3.10.1.dev3.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
191
- cycode-3.10.1.dev3.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
192
- cycode-3.10.1.dev3.dist-info/RECORD,,
188
+ cycode-3.10.2.dev1.dist-info/METADATA,sha256=_mlzUsuS3HjQ-_wiT-ACp0mnLjwgUDZxxvDBseayvNI,79688
189
+ cycode-3.10.2.dev1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
190
+ cycode-3.10.2.dev1.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
191
+ cycode-3.10.2.dev1.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
192
+ cycode-3.10.2.dev1.dist-info/RECORD,,