cycode 3.0.0rc2__tar.gz → 3.0.1__tar.gz

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.
Files changed (155) hide show
  1. {cycode-3.0.0rc2 → cycode-3.0.1}/PKG-INFO +1 -1
  2. cycode-3.0.1/cycode/__init__.py +1 -0
  3. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/app.py +5 -3
  4. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/code_scanner.py +10 -6
  5. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/base_restore_dependencies.py +23 -28
  6. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/go/restore_go_dependencies.py +0 -3
  7. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py +4 -7
  8. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py +12 -14
  9. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py +0 -3
  10. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/nuget/restore_nuget_dependencies.py +0 -5
  11. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/ruby/restore_ruby_dependencies.py +0 -3
  12. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py +0 -3
  13. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/shell_executor.py +6 -2
  14. {cycode-3.0.0rc2 → cycode-3.0.1}/pyproject.toml +1 -1
  15. cycode-3.0.0rc2/cycode/__init__.py +0 -1
  16. {cycode-3.0.0rc2 → cycode-3.0.1}/LICENCE +0 -0
  17. {cycode-3.0.0rc2 → cycode-3.0.1}/README.md +0 -0
  18. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/__main__.py +0 -0
  19. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/__init__.py +0 -0
  20. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/__init__.py +0 -0
  21. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ai_remediation/__init__.py +0 -0
  22. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ai_remediation/ai_remediation_command.py +0 -0
  23. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ai_remediation/apply_fix.py +0 -0
  24. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ai_remediation/print_remediation.py +0 -0
  25. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/auth/__init__.py +0 -0
  26. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/auth/auth_command.py +0 -0
  27. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/auth/auth_common.py +0 -0
  28. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/auth/auth_manager.py +0 -0
  29. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/auth/models.py +0 -0
  30. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/configure/__init__.py +0 -0
  31. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/configure/configure_command.py +0 -0
  32. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/configure/consts.py +0 -0
  33. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/configure/messages.py +0 -0
  34. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/configure/prompts.py +0 -0
  35. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ignore/__init__.py +0 -0
  36. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/ignore/ignore_command.py +0 -0
  37. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/__init__.py +0 -0
  38. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/report_command.py +0 -0
  39. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/__init__.py +0 -0
  40. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/common.py +0 -0
  41. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/path/__init__.py +0 -0
  42. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/path/path_command.py +0 -0
  43. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/repository_url/__init__.py +0 -0
  44. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/repository_url/repository_url_command.py +0 -0
  45. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/sbom_command.py +0 -0
  46. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/report/sbom/sbom_report_file.py +0 -0
  47. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/__init__.py +0 -0
  48. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/commit_history/__init__.py +0 -0
  49. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/commit_history/commit_history_command.py +0 -0
  50. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/path/__init__.py +0 -0
  51. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/path/path_command.py +0 -0
  52. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/pre_commit/__init__.py +0 -0
  53. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/pre_commit/pre_commit_command.py +0 -0
  54. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/pre_receive/__init__.py +0 -0
  55. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/pre_receive/pre_receive_command.py +0 -0
  56. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/repository/__init__.py +0 -0
  57. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/repository/repository_command.py +0 -0
  58. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/scan_ci/__init__.py +0 -0
  59. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/scan_ci/ci_integrations.py +0 -0
  60. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/scan_ci/scan_ci_command.py +0 -0
  61. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/scan/scan_command.py +0 -0
  62. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/status/__init__.py +0 -0
  63. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/status/get_cli_status.py +0 -0
  64. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/status/models.py +0 -0
  65. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/status/status_command.py +0 -0
  66. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/apps/status/version_command.py +0 -0
  67. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/cli_types.py +0 -0
  68. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/config.py +0 -0
  69. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/console.py +0 -0
  70. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/consts.py +0 -0
  71. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/__init__.py +0 -0
  72. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/custom_exceptions.py +0 -0
  73. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/handle_ai_remediation_errors.py +0 -0
  74. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/handle_auth_errors.py +0 -0
  75. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/handle_errors.py +0 -0
  76. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/handle_report_sbom_errors.py +0 -0
  77. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/exceptions/handle_scan_errors.py +0 -0
  78. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/__init__.py +0 -0
  79. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/excluder.py +0 -0
  80. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/iac/__init__.py +0 -0
  81. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/iac/tf_content_generator.py +0 -0
  82. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/models/__init__.py +0 -0
  83. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/models/in_memory_zip.py +0 -0
  84. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/path_documents.py +0 -0
  85. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/repository_documents.py +0 -0
  86. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/__init__.py +0 -0
  87. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/go/__init__.py +0 -0
  88. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/maven/__init__.py +0 -0
  89. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/npm/__init__.py +0 -0
  90. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/nuget/__init__.py +0 -0
  91. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/ruby/__init__.py +0 -0
  92. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/sbt/__init__.py +0 -0
  93. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/sca/sca_code_scanner.py +0 -0
  94. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/walk_ignore.py +0 -0
  95. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/files_collector/zip_documents.py +0 -0
  96. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/logger.py +0 -0
  97. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/main.py +0 -0
  98. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/models.py +0 -0
  99. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/__init__.py +0 -0
  100. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/console_printer.py +0 -0
  101. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/json_printer.py +0 -0
  102. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/printer_base.py +0 -0
  103. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/rich_printer.py +0 -0
  104. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/__init__.py +0 -0
  105. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/sca_table_printer.py +0 -0
  106. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/table.py +0 -0
  107. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/table_models.py +0 -0
  108. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/table_printer.py +0 -0
  109. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/tables/table_printer_base.py +0 -0
  110. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/text_printer.py +0 -0
  111. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/__init__.py +0 -0
  112. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/code_snippet_syntax.py +0 -0
  113. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/detection_data.py +0 -0
  114. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/detection_ordering/__init__.py +0 -0
  115. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/detection_ordering/common_ordering.py +0 -0
  116. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/detection_ordering/sca_ordering.py +0 -0
  117. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/printers/utils/rich_helpers.py +0 -0
  118. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/__init__.py +0 -0
  119. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/base_file_manager.py +0 -0
  120. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/config_file_manager.py +0 -0
  121. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/configuration_manager.py +0 -0
  122. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/credentials_manager.py +0 -0
  123. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/user_settings/jwt_creator.py +0 -0
  124. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/__init__.py +0 -0
  125. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/enum_utils.py +0 -0
  126. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/get_api_client.py +0 -0
  127. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/git_proxy.py +0 -0
  128. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/ignore_utils.py +0 -0
  129. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/jwt_utils.py +0 -0
  130. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/path_utils.py +0 -0
  131. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/progress_bar.py +0 -0
  132. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/scan_batch.py +0 -0
  133. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/scan_utils.py +0 -0
  134. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/sentry.py +0 -0
  135. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/string_utils.py +0 -0
  136. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/task_timer.py +0 -0
  137. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/version_checker.py +0 -0
  138. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cli/utils/yaml_utils.py +0 -0
  139. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/config.py +0 -0
  140. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/__init__.py +0 -0
  141. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/auth_client.py +0 -0
  142. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/client_creator.py +0 -0
  143. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/config.py +0 -0
  144. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/config_dev.py +0 -0
  145. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/cycode_client.py +0 -0
  146. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/cycode_client_base.py +0 -0
  147. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/cycode_dev_based_client.py +0 -0
  148. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/cycode_token_based_client.py +0 -0
  149. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/headers.py +0 -0
  150. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/logger.py +0 -0
  151. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/models.py +0 -0
  152. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/report_client.py +0 -0
  153. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/scan_client.py +0 -0
  154. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/cyclient/scan_config_base.py +0 -0
  155. {cycode-3.0.0rc2 → cycode-3.0.1}/cycode/logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cycode
3
- Version: 3.0.0rc2
3
+ Version: 3.0.1
4
4
  Summary: Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning.
5
5
  Home-page: https://github.com/cycodehq/cycode-cli
6
6
  License: MIT
@@ -0,0 +1 @@
1
+ __version__ = '3.0.1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -4,6 +4,7 @@ from typing import Annotated, Optional
4
4
  import typer
5
5
  from typer import rich_utils
6
6
  from typer._completion_classes import completion_init
7
+ from typer._completion_shared import Shells
7
8
  from typer.completion import install_callback, show_callback
8
9
 
9
10
  from cycode import __version__
@@ -113,16 +114,17 @@ def app_callback(
113
114
  ),
114
115
  ] = False,
115
116
  __: Annotated[
116
- Optional[bool],
117
+ Shells, # the choice is required for Homebrew to be able to install the completion
117
118
  typer.Option(
118
119
  '--show-completion',
119
120
  callback=show_callback,
120
121
  is_eager=True,
121
122
  expose_value=False,
122
- help='Show completion for the current shell, to copy it or customize the installation.',
123
+ show_default=False,
124
+ help='Show completion for the specified shell, to copy it or customize the installation.',
123
125
  rich_help_panel=_COMPLETION_RICH_HELP_PANEL,
124
126
  ),
125
- ] = False,
127
+ ] = None,
126
128
  ) -> None:
127
129
  """[bold cyan]Cycode CLI - Command Line Interface for Cycode.[/]"""
128
130
  init_sentry()
@@ -683,8 +683,8 @@ def try_get_git_remote_url(path: str) -> Optional[str]:
683
683
  remote_url = git_proxy.get_repo(path).remotes[0].config_reader.get('url')
684
684
  logger.debug('Found Git remote URL, %s', {'remote_url': remote_url, 'path': path})
685
685
  return remote_url
686
- except Exception as e:
687
- logger.debug('Failed to get Git remote URL', exc_info=e)
686
+ except Exception:
687
+ logger.debug('Failed to get Git remote URL. Probably not a Git repository')
688
688
  return None
689
689
 
690
690
 
@@ -706,7 +706,9 @@ def _get_plastic_repository_name(path: str) -> Optional[str]:
706
706
  f'--fieldseparator={consts.PLASTIC_VCS_DATA_SEPARATOR}',
707
707
  ]
708
708
 
709
- status = shell(command=command, timeout=consts.PLASTIC_VSC_CLI_TIMEOUT, working_directory=path)
709
+ status = shell(
710
+ command=command, timeout=consts.PLASTIC_VSC_CLI_TIMEOUT, working_directory=path, silent_exc_info=True
711
+ )
710
712
  if not status:
711
713
  logger.debug('Failed to get Plastic repository name (command failed)')
712
714
  return None
@@ -717,8 +719,8 @@ def _get_plastic_repository_name(path: str) -> Optional[str]:
717
719
  return None
718
720
 
719
721
  return status_parts[2].strip()
720
- except Exception as e:
721
- logger.debug('Failed to get Plastic repository name', exc_info=e)
722
+ except Exception:
723
+ logger.debug('Failed to get Plastic repository name. Probably not a Plastic repository')
722
724
  return None
723
725
 
724
726
 
@@ -738,7 +740,9 @@ def _get_plastic_repository_list(working_dir: Optional[str] = None) -> dict[str,
738
740
  try:
739
741
  command = ['cm', 'repo', 'ls', f'--format={{repname}}{consts.PLASTIC_VCS_DATA_SEPARATOR}{{repguid}}']
740
742
 
741
- status = shell(command=command, timeout=consts.PLASTIC_VSC_CLI_TIMEOUT, working_directory=working_dir)
743
+ status = shell(
744
+ command=command, timeout=consts.PLASTIC_VSC_CLI_TIMEOUT, working_directory=working_dir, silent_exc_info=True
745
+ )
742
746
  if not status:
743
747
  logger.debug('Failed to get Plastic repository list (command failed)')
744
748
  return repo_name_to_guid
@@ -1,9 +1,9 @@
1
+ import os
1
2
  from abc import ABC, abstractmethod
2
3
  from typing import Optional
3
4
 
4
5
  import typer
5
6
 
6
- from cycode.cli.logger import logger
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
@@ -15,30 +15,27 @@ def build_dep_tree_path(path: str, generated_file_name: str) -> str:
15
15
 
16
16
  def execute_commands(
17
17
  commands: list[list[str]],
18
- file_name: str,
19
- command_timeout: int,
20
- dependencies_file_name: Optional[str] = None,
18
+ timeout: int,
19
+ output_file_path: Optional[str] = None,
21
20
  working_directory: Optional[str] = None,
22
21
  ) -> Optional[str]:
23
22
  try:
24
- all_dependencies = []
23
+ outputs = []
25
24
 
26
- # Run all commands and collect outputs
27
25
  for command in commands:
28
- dependencies = shell(command=command, timeout=command_timeout, working_directory=working_directory)
29
- all_dependencies.append(dependencies) # Collect each command's output
26
+ command_output = shell(command=command, timeout=timeout, working_directory=working_directory)
27
+ if command_output:
28
+ outputs.append(command_output)
30
29
 
31
- dependencies = '\n'.join(all_dependencies)
30
+ joined_output = '\n'.join(outputs)
32
31
 
33
- # Write all collected outputs to the file if dependencies_file_name is provided
34
- if dependencies_file_name:
35
- with open(dependencies_file_name, 'w') as output_file: # Open once in 'w' mode to start fresh
36
- output_file.writelines(dependencies)
37
- except Exception as e:
38
- logger.debug('Failed to restore dependencies via shell command, %s', {'filename': file_name}, exc_info=e)
32
+ if output_file_path:
33
+ with open(output_file_path, 'w', encoding='UTF-8') as output_file:
34
+ output_file.writelines(joined_output)
35
+ except Exception:
39
36
  return None
40
37
 
41
- return dependencies
38
+ return joined_output
42
39
 
43
40
 
44
41
  class BaseRestoreDependencies(ABC):
@@ -64,27 +61,25 @@ class BaseRestoreDependencies(ABC):
64
61
  relative_restore_file_path = build_dep_tree_path(document.path, self.get_lock_file_name())
65
62
  working_directory_path = self.get_working_directory(document)
66
63
 
67
- if self.verify_restore_file_already_exist(restore_file_path):
68
- restore_file_content = get_file_content(restore_file_path)
69
- else:
70
- output_file_path = restore_file_path if self.create_output_file_manually else None
71
- execute_commands(
64
+ if not self.verify_restore_file_already_exist(restore_file_path):
65
+ output = execute_commands(
72
66
  self.get_commands(manifest_file_path),
73
- manifest_file_path,
74
67
  self.command_timeout,
75
- output_file_path,
76
- working_directory_path,
68
+ output_file_path=restore_file_path if self.create_output_file_manually else None,
69
+ working_directory=working_directory_path,
77
70
  )
78
- restore_file_content = get_file_content(restore_file_path)
71
+ if output is None: # one of the commands failed
72
+ return None
79
73
 
74
+ restore_file_content = get_file_content(restore_file_path)
80
75
  return Document(relative_restore_file_path, restore_file_content, self.is_git_diff)
81
76
 
82
77
  def get_working_directory(self, document: Document) -> Optional[str]:
83
78
  return None
84
79
 
85
- @abstractmethod
86
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
87
- pass
80
+ @staticmethod
81
+ def verify_restore_file_already_exist(restore_file_path: str) -> bool:
82
+ return os.path.isfile(restore_file_path)
88
83
 
89
84
  @abstractmethod
90
85
  def is_project(self, document: Document) -> bool:
@@ -44,8 +44,5 @@ class RestoreGoDependencies(BaseRestoreDependencies):
44
44
  def get_lock_file_name(self) -> str:
45
45
  return GO_RESTORE_FILE_NAME
46
46
 
47
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
48
- return os.path.isfile(restore_file_path)
49
-
50
47
  def get_working_directory(self, document: Document) -> Optional[str]:
51
48
  return os.path.dirname(document.absolute_path)
@@ -42,22 +42,19 @@ class RestoreGradleDependencies(BaseRestoreDependencies):
42
42
  def get_lock_file_name(self) -> str:
43
43
  return BUILD_GRADLE_DEP_TREE_FILE_NAME
44
44
 
45
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
46
- return os.path.isfile(restore_file_path)
47
-
48
45
  def get_working_directory(self, document: Document) -> Optional[str]:
49
46
  return get_path_from_context(self.ctx) if self.is_gradle_sub_projects() else None
50
47
 
51
48
  def get_all_projects(self) -> set[str]:
52
- projects_output = shell(
49
+ output = shell(
53
50
  command=BUILD_GRADLE_ALL_PROJECTS_COMMAND,
54
51
  timeout=BUILD_GRADLE_ALL_PROJECTS_TIMEOUT,
55
52
  working_directory=get_path_from_context(self.ctx),
56
53
  )
54
+ if not output:
55
+ return set()
57
56
 
58
- projects = re.findall(ALL_PROJECTS_REGEX, projects_output)
59
-
60
- return set(projects)
57
+ return set(re.findall(ALL_PROJECTS_REGEX, output))
61
58
 
62
59
  def get_commands_for_sub_projects(self, manifest_file_path: str) -> list[list[str]]:
63
60
  project_name = os.path.basename(os.path.dirname(manifest_file_path))
@@ -1,4 +1,3 @@
1
- import os
2
1
  from os import path
3
2
  from typing import Optional
4
3
 
@@ -30,9 +29,6 @@ class RestoreMavenDependencies(BaseRestoreDependencies):
30
29
  def get_lock_file_name(self) -> str:
31
30
  return join_paths('target', MAVEN_CYCLONE_DEP_TREE_FILE_NAME)
32
31
 
33
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
34
- return os.path.isfile(restore_file_path)
35
-
36
32
  def try_restore_dependencies(self, document: Document) -> Optional[Document]:
37
33
  restore_dependencies_document = super().try_restore_dependencies(document)
38
34
  manifest_file_path = self.get_manifest_file_path(document)
@@ -51,8 +47,8 @@ class RestoreMavenDependencies(BaseRestoreDependencies):
51
47
  self, document: Document, manifest_file_path: str, restore_dependencies_document: Optional[Document]
52
48
  ) -> Optional[Document]:
53
49
  # TODO(MarshalX): does it even work? Ignored restore_dependencies_document arg
54
- secondary_restore_command = create_secondary_restore_command(manifest_file_path)
55
- backup_restore_content = execute_commands(secondary_restore_command, manifest_file_path, self.command_timeout)
50
+ secondary_restore_command = create_secondary_restore_commands(manifest_file_path)
51
+ backup_restore_content = execute_commands(secondary_restore_command, self.command_timeout)
56
52
  restore_dependencies_document = Document(
57
53
  build_dep_tree_path(document.path, MAVEN_DEP_TREE_FILE_NAME), backup_restore_content, self.is_git_diff
58
54
  )
@@ -64,13 +60,15 @@ class RestoreMavenDependencies(BaseRestoreDependencies):
64
60
  return restore_dependencies
65
61
 
66
62
 
67
- def create_secondary_restore_command(manifest_file_path: str) -> list[str]:
63
+ def create_secondary_restore_commands(manifest_file_path: str) -> list[list[str]]:
68
64
  return [
69
- 'mvn',
70
- 'dependency:tree',
71
- '-B',
72
- '-DoutputType=text',
73
- '-f',
74
- manifest_file_path,
75
- f'-DoutputFile={MAVEN_DEP_TREE_FILE_NAME}',
65
+ [
66
+ 'mvn',
67
+ 'dependency:tree',
68
+ '-B',
69
+ '-DoutputType=text',
70
+ '-f',
71
+ manifest_file_path,
72
+ f'-DoutputFile={MAVEN_DEP_TREE_FILE_NAME}',
73
+ ]
76
74
  ]
@@ -33,9 +33,6 @@ class RestoreNpmDependencies(BaseRestoreDependencies):
33
33
  def get_lock_file_name(self) -> str:
34
34
  return NPM_LOCK_FILE_NAME
35
35
 
36
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
37
- return os.path.isfile(restore_file_path)
38
-
39
36
  @staticmethod
40
37
  def prepare_manifest_file_path_for_command(manifest_file_path: str) -> str:
41
38
  return manifest_file_path.replace(os.sep + NPM_MANIFEST_FILE_NAME, '')
@@ -1,5 +1,3 @@
1
- import os
2
-
3
1
  import typer
4
2
 
5
3
  from cycode.cli.files_collector.sca.base_restore_dependencies import BaseRestoreDependencies
@@ -21,6 +19,3 @@ class RestoreNugetDependencies(BaseRestoreDependencies):
21
19
 
22
20
  def get_lock_file_name(self) -> str:
23
21
  return NUGET_LOCK_FILE_NAME
24
-
25
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
26
- return os.path.isfile(restore_file_path)
@@ -18,8 +18,5 @@ class RestoreRubyDependencies(BaseRestoreDependencies):
18
18
  def get_lock_file_name(self) -> str:
19
19
  return RUBY_LOCK_FILE_NAME
20
20
 
21
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
22
- return os.path.isfile(restore_file_path)
23
-
24
21
  def get_working_directory(self, document: Document) -> Optional[str]:
25
22
  return os.path.dirname(document.absolute_path)
@@ -18,8 +18,5 @@ class RestoreSbtDependencies(BaseRestoreDependencies):
18
18
  def get_lock_file_name(self) -> str:
19
19
  return SBT_LOCK_FILE_NAME
20
20
 
21
- def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
22
- return os.path.isfile(restore_file_path)
23
-
24
21
  def get_working_directory(self, document: Document) -> Optional[str]:
25
22
  return os.path.dirname(document.absolute_path)
@@ -16,6 +16,7 @@ def shell(
16
16
  command: Union[str, list[str]],
17
17
  timeout: int = _SUBPROCESS_DEFAULT_TIMEOUT_SEC,
18
18
  working_directory: Optional[str] = None,
19
+ silent_exc_info: bool = False,
19
20
  ) -> Optional[str]:
20
21
  logger.debug('Executing shell command: %s', command)
21
22
 
@@ -27,12 +28,15 @@ def shell(
27
28
 
28
29
  return result.stdout.decode('UTF-8').strip()
29
30
  except subprocess.CalledProcessError as e:
30
- logger.debug('Error occurred while running shell command', exc_info=e)
31
+ if not silent_exc_info:
32
+ logger.debug('Error occurred while running shell command', exc_info=e)
31
33
  except subprocess.TimeoutExpired as e:
32
34
  logger.debug('Command timed out', exc_info=e)
33
35
  raise typer.Abort(f'Command "{command}" timed out') from e
34
36
  except Exception as e:
35
- logger.debug('Unhandled exception occurred while running shell command', exc_info=e)
37
+ if not silent_exc_info:
38
+ logger.debug('Unhandled exception occurred while running shell command', exc_info=e)
39
+
36
40
  raise click.ClickException(f'Unhandled exception: {e}') from e
37
41
 
38
42
  return None
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cycode"
3
- version = "3.0.0.rc2" # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
3
+ version = "3.0.1" # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
4
4
  description = "Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning."
5
5
  keywords=["secret-scan", "cycode", "devops", "token", "secret", "security", "cycode", "code"]
6
6
  authors = ["Cycode <support@cycode.com>"]
@@ -1 +0,0 @@
1
- __version__ = '3.0.0.rc2' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes