cycode 3.5.2.dev1__tar.gz → 3.5.3.dev2__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.
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/PKG-INFO +1 -1
- cycode-3.5.3.dev2/cycode/__init__.py +1 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/path/path_command.py +6 -1
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/code_scanner.py +12 -2
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/commit_range_scanner.py +43 -5
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/repository/repository_command.py +5 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_command.py +8 -1
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/consts.py +2 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/commit_range_documents.py +1 -16
- cycode-3.5.3.dev2/cycode/cli/files_collector/documents_walk_ignore.py +124 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/path_documents.py +24 -7
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/walk_ignore.py +14 -5
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/scan_utils.py +7 -1
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/models.py +2 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/scan_client.py +10 -3
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/pyproject.toml +1 -1
- cycode-3.5.2.dev1/cycode/__init__.py +0 -1
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/LICENCE +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/README.md +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/__main__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/app.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ai_remediation/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ai_remediation/ai_remediation_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ai_remediation/apply_fix.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ai_remediation/print_remediation.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/auth/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/auth/auth_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/auth/auth_common.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/auth/auth_manager.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/auth/models.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/configure/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/configure/configure_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/configure/consts.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/configure/messages.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/configure/prompts.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ignore/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ignore/ignore_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/mcp/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/mcp/mcp_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/report_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/common.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/path/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/repository_url/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/repository_url/repository_url_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/sbom_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/report/sbom/sbom_report_file.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/aggregation_report.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/commit_history/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/commit_history/commit_history_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/detection_excluder.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/path/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/path/path_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_commit/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_commit/pre_commit_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_push/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_push/pre_push_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_receive/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/pre_receive/pre_receive_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/remote_url_resolver.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/repository/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_ci/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_ci/ci_integrations.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_ci/scan_ci_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_parameters.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/scan_result.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/status/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/status/get_cli_status.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/status/models.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/status/status_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/status/version_command.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/cli_types.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/config.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/console.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/custom_exceptions.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/handle_ai_remediation_errors.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/handle_auth_errors.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/handle_errors.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/handle_report_sbom_errors.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/exceptions/handle_scan_errors.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/file_excluder.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/iac/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/iac/tf_content_generator.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/models/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/models/in_memory_zip.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/repository_documents.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/base_restore_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/go/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/go/restore_go_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/maven/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/npm/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/nuget/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/nuget/restore_nuget_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/ruby/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/ruby/restore_ruby_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/sbt/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/sca/sca_file_collector.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/zip_documents.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/logger.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/main.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/models.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/console_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/json_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/printer_base.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/rich_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/sca_table_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/table.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/table_models.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/table_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/tables/table_printer_base.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/text_printer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/code_snippet_syntax.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/detection_data.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/detection_ordering/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/detection_ordering/common_ordering.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/detection_ordering/sca_ordering.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/printers/utils/rich_helpers.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/base_file_manager.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/config_file_manager.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/configuration_manager.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/credentials_manager.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/user_settings/jwt_creator.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/enum_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/get_api_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/git_proxy.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/ignore_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/jwt_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/path_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/progress_bar.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/scan_batch.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/sentry.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/shell_executor.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/string_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/task_timer.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/version_checker.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/utils/yaml_utils.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/config.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/__init__.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/auth_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/client_creator.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/config.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/config_dev.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/cycode_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/cycode_client_base.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/cycode_dev_based_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/cycode_token_based_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/headers.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/logger.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/report_client.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cyclient/scan_config_base.py +0 -0
- {cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/logger.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '3.5.3.dev2' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
|
|
@@ -12,6 +12,7 @@ from cycode.cli.files_collector.sca.sca_file_collector import add_sca_dependenci
|
|
|
12
12
|
from cycode.cli.files_collector.zip_documents import zip_documents
|
|
13
13
|
from cycode.cli.utils.get_api_client import get_report_cycode_client
|
|
14
14
|
from cycode.cli.utils.progress_bar import SbomReportProgressBarSection
|
|
15
|
+
from cycode.cli.utils.scan_utils import is_cycodeignore_allowed_by_scan_config
|
|
15
16
|
from cycode.cli.utils.sentry import add_breadcrumb
|
|
16
17
|
|
|
17
18
|
|
|
@@ -37,7 +38,11 @@ def path_command(
|
|
|
37
38
|
|
|
38
39
|
try:
|
|
39
40
|
documents = get_relevant_documents(
|
|
40
|
-
progress_bar,
|
|
41
|
+
progress_bar,
|
|
42
|
+
SbomReportProgressBarSection.PREPARE_LOCAL_FILES,
|
|
43
|
+
consts.SCA_SCAN_TYPE,
|
|
44
|
+
(str(path),),
|
|
45
|
+
is_cycodeignore_allowed=is_cycodeignore_allowed_by_scan_config(ctx),
|
|
41
46
|
)
|
|
42
47
|
# TODO(MarshalX): combine perform_pre_scan_documents_actions with get_relevant_document.
|
|
43
48
|
# unhardcode usage of context in perform_pre_scan_documents_actions
|
|
@@ -23,7 +23,11 @@ from cycode.cli.files_collector.zip_documents import zip_documents
|
|
|
23
23
|
from cycode.cli.models import CliError, Document, LocalScanResult
|
|
24
24
|
from cycode.cli.utils.progress_bar import ScanProgressBarSection
|
|
25
25
|
from cycode.cli.utils.scan_batch import run_parallel_batched_scan
|
|
26
|
-
from cycode.cli.utils.scan_utils import
|
|
26
|
+
from cycode.cli.utils.scan_utils import (
|
|
27
|
+
generate_unique_scan_id,
|
|
28
|
+
is_cycodeignore_allowed_by_scan_config,
|
|
29
|
+
set_issue_detected_by_scan_results,
|
|
30
|
+
)
|
|
27
31
|
from cycode.cyclient.models import ZippedFileScanResult
|
|
28
32
|
from cycode.logger import get_logger
|
|
29
33
|
|
|
@@ -42,7 +46,13 @@ def scan_disk_files(ctx: typer.Context, paths: tuple[str, ...]) -> None:
|
|
|
42
46
|
progress_bar = ctx.obj['progress_bar']
|
|
43
47
|
|
|
44
48
|
try:
|
|
45
|
-
documents = get_relevant_documents(
|
|
49
|
+
documents = get_relevant_documents(
|
|
50
|
+
progress_bar,
|
|
51
|
+
ScanProgressBarSection.PREPARE_LOCAL_FILES,
|
|
52
|
+
scan_type,
|
|
53
|
+
paths,
|
|
54
|
+
is_cycodeignore_allowed=is_cycodeignore_allowed_by_scan_config(ctx),
|
|
55
|
+
)
|
|
46
56
|
add_sca_dependencies_tree_documents_if_needed(ctx, scan_type, documents)
|
|
47
57
|
scan_documents(ctx, documents, get_scan_parameters(ctx, paths))
|
|
48
58
|
except Exception as e:
|
|
@@ -26,9 +26,9 @@ from cycode.cli.files_collector.commit_range_documents import (
|
|
|
26
26
|
get_diff_file_path,
|
|
27
27
|
get_pre_commit_modified_documents,
|
|
28
28
|
get_safe_head_reference_for_diff,
|
|
29
|
-
|
|
30
|
-
parse_commit_range_sca,
|
|
29
|
+
parse_commit_range,
|
|
31
30
|
)
|
|
31
|
+
from cycode.cli.files_collector.documents_walk_ignore import filter_documents_with_cycodeignore
|
|
32
32
|
from cycode.cli.files_collector.file_excluder import excluder
|
|
33
33
|
from cycode.cli.files_collector.models.in_memory_zip import InMemoryZip
|
|
34
34
|
from cycode.cli.files_collector.sca.sca_file_collector import (
|
|
@@ -40,7 +40,11 @@ from cycode.cli.models import Document
|
|
|
40
40
|
from cycode.cli.utils.git_proxy import git_proxy
|
|
41
41
|
from cycode.cli.utils.path_utils import get_path_by_os
|
|
42
42
|
from cycode.cli.utils.progress_bar import ScanProgressBarSection
|
|
43
|
-
from cycode.cli.utils.scan_utils import
|
|
43
|
+
from cycode.cli.utils.scan_utils import (
|
|
44
|
+
generate_unique_scan_id,
|
|
45
|
+
is_cycodeignore_allowed_by_scan_config,
|
|
46
|
+
set_issue_detected_by_scan_results,
|
|
47
|
+
)
|
|
44
48
|
from cycode.cyclient.models import ZippedFileScanResult
|
|
45
49
|
from cycode.logger import get_logger
|
|
46
50
|
|
|
@@ -182,13 +186,19 @@ def _scan_commit_range_documents(
|
|
|
182
186
|
def _scan_sca_commit_range(ctx: typer.Context, repo_path: str, commit_range: str, **_) -> None:
|
|
183
187
|
scan_parameters = get_scan_parameters(ctx, (repo_path,))
|
|
184
188
|
|
|
185
|
-
from_commit_rev, to_commit_rev =
|
|
189
|
+
from_commit_rev, to_commit_rev = parse_commit_range(commit_range, repo_path)
|
|
186
190
|
from_commit_documents, to_commit_documents, _ = get_commit_range_modified_documents(
|
|
187
191
|
ctx.obj['progress_bar'], ScanProgressBarSection.PREPARE_LOCAL_FILES, repo_path, from_commit_rev, to_commit_rev
|
|
188
192
|
)
|
|
189
193
|
from_commit_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SCA_SCAN_TYPE, from_commit_documents)
|
|
190
194
|
to_commit_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SCA_SCAN_TYPE, to_commit_documents)
|
|
191
195
|
|
|
196
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
197
|
+
from_commit_documents = filter_documents_with_cycodeignore(
|
|
198
|
+
from_commit_documents, repo_path, is_cycodeignore_allowed
|
|
199
|
+
)
|
|
200
|
+
to_commit_documents = filter_documents_with_cycodeignore(to_commit_documents, repo_path, is_cycodeignore_allowed)
|
|
201
|
+
|
|
192
202
|
perform_sca_pre_commit_range_scan_actions(
|
|
193
203
|
repo_path, from_commit_documents, from_commit_rev, to_commit_documents, to_commit_rev
|
|
194
204
|
)
|
|
@@ -204,6 +214,11 @@ def _scan_secret_commit_range(
|
|
|
204
214
|
consts.SECRET_SCAN_TYPE, commit_diff_documents_to_scan
|
|
205
215
|
)
|
|
206
216
|
|
|
217
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
218
|
+
diff_documents_to_scan = filter_documents_with_cycodeignore(
|
|
219
|
+
diff_documents_to_scan, repo_path, is_cycodeignore_allowed
|
|
220
|
+
)
|
|
221
|
+
|
|
207
222
|
scan_documents(
|
|
208
223
|
ctx, diff_documents_to_scan, get_scan_parameters(ctx, (repo_path,)), is_git_diff=True, is_commit_range=True
|
|
209
224
|
)
|
|
@@ -212,7 +227,7 @@ def _scan_secret_commit_range(
|
|
|
212
227
|
def _scan_sast_commit_range(ctx: typer.Context, repo_path: str, commit_range: str, **_) -> None:
|
|
213
228
|
scan_parameters = get_scan_parameters(ctx, (repo_path,))
|
|
214
229
|
|
|
215
|
-
from_commit_rev, to_commit_rev =
|
|
230
|
+
from_commit_rev, to_commit_rev = parse_commit_range(commit_range, repo_path)
|
|
216
231
|
_, commit_documents, diff_documents = get_commit_range_modified_documents(
|
|
217
232
|
ctx.obj['progress_bar'],
|
|
218
233
|
ScanProgressBarSection.PREPARE_LOCAL_FILES,
|
|
@@ -221,9 +236,14 @@ def _scan_sast_commit_range(ctx: typer.Context, repo_path: str, commit_range: st
|
|
|
221
236
|
to_commit_rev,
|
|
222
237
|
reverse_diff=False,
|
|
223
238
|
)
|
|
239
|
+
|
|
224
240
|
commit_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SAST_SCAN_TYPE, commit_documents)
|
|
225
241
|
diff_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SAST_SCAN_TYPE, diff_documents)
|
|
226
242
|
|
|
243
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
244
|
+
commit_documents = filter_documents_with_cycodeignore(commit_documents, repo_path, is_cycodeignore_allowed)
|
|
245
|
+
diff_documents = filter_documents_with_cycodeignore(diff_documents, repo_path, is_cycodeignore_allowed)
|
|
246
|
+
|
|
227
247
|
_scan_commit_range_documents(ctx, commit_documents, diff_documents, scan_parameters=scan_parameters)
|
|
228
248
|
|
|
229
249
|
|
|
@@ -254,11 +274,18 @@ def _scan_sca_pre_commit(ctx: typer.Context, repo_path: str) -> None:
|
|
|
254
274
|
progress_bar_section=ScanProgressBarSection.PREPARE_LOCAL_FILES,
|
|
255
275
|
repo_path=repo_path,
|
|
256
276
|
)
|
|
277
|
+
|
|
257
278
|
git_head_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SCA_SCAN_TYPE, git_head_documents)
|
|
258
279
|
pre_committed_documents = excluder.exclude_irrelevant_documents_to_scan(
|
|
259
280
|
consts.SCA_SCAN_TYPE, pre_committed_documents
|
|
260
281
|
)
|
|
261
282
|
|
|
283
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
284
|
+
git_head_documents = filter_documents_with_cycodeignore(git_head_documents, repo_path, is_cycodeignore_allowed)
|
|
285
|
+
pre_committed_documents = filter_documents_with_cycodeignore(
|
|
286
|
+
pre_committed_documents, repo_path, is_cycodeignore_allowed
|
|
287
|
+
)
|
|
288
|
+
|
|
262
289
|
perform_sca_pre_hook_range_scan_actions(repo_path, git_head_documents, pre_committed_documents)
|
|
263
290
|
|
|
264
291
|
_scan_commit_range_documents(
|
|
@@ -288,8 +315,12 @@ def _scan_secret_pre_commit(ctx: typer.Context, repo_path: str) -> None:
|
|
|
288
315
|
is_git_diff_format=True,
|
|
289
316
|
)
|
|
290
317
|
)
|
|
318
|
+
|
|
291
319
|
documents_to_scan = excluder.exclude_irrelevant_documents_to_scan(consts.SECRET_SCAN_TYPE, documents_to_scan)
|
|
292
320
|
|
|
321
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
322
|
+
documents_to_scan = filter_documents_with_cycodeignore(documents_to_scan, repo_path, is_cycodeignore_allowed)
|
|
323
|
+
|
|
293
324
|
scan_documents(ctx, documents_to_scan, get_scan_parameters(ctx), is_git_diff=True)
|
|
294
325
|
|
|
295
326
|
|
|
@@ -301,11 +332,18 @@ def _scan_sast_pre_commit(ctx: typer.Context, repo_path: str, **_) -> None:
|
|
|
301
332
|
progress_bar_section=ScanProgressBarSection.PREPARE_LOCAL_FILES,
|
|
302
333
|
repo_path=repo_path,
|
|
303
334
|
)
|
|
335
|
+
|
|
304
336
|
pre_committed_documents = excluder.exclude_irrelevant_documents_to_scan(
|
|
305
337
|
consts.SAST_SCAN_TYPE, pre_committed_documents
|
|
306
338
|
)
|
|
307
339
|
diff_documents = excluder.exclude_irrelevant_documents_to_scan(consts.SAST_SCAN_TYPE, diff_documents)
|
|
308
340
|
|
|
341
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
342
|
+
pre_committed_documents = filter_documents_with_cycodeignore(
|
|
343
|
+
pre_committed_documents, repo_path, is_cycodeignore_allowed
|
|
344
|
+
)
|
|
345
|
+
diff_documents = filter_documents_with_cycodeignore(diff_documents, repo_path, is_cycodeignore_allowed)
|
|
346
|
+
|
|
309
347
|
_scan_commit_range_documents(ctx, pre_committed_documents, diff_documents, scan_parameters=scan_parameters)
|
|
310
348
|
|
|
311
349
|
|
{cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/scan/repository/repository_command.py
RENAMED
|
@@ -8,6 +8,7 @@ from cycode.cli import consts
|
|
|
8
8
|
from cycode.cli.apps.scan.code_scanner import scan_documents
|
|
9
9
|
from cycode.cli.apps.scan.scan_parameters import get_scan_parameters
|
|
10
10
|
from cycode.cli.exceptions.handle_scan_errors import handle_scan_exception
|
|
11
|
+
from cycode.cli.files_collector.documents_walk_ignore import filter_documents_with_cycodeignore
|
|
11
12
|
from cycode.cli.files_collector.file_excluder import excluder
|
|
12
13
|
from cycode.cli.files_collector.repository_documents import get_git_repository_tree_file_entries
|
|
13
14
|
from cycode.cli.files_collector.sca.sca_file_collector import add_sca_dependencies_tree_documents_if_needed
|
|
@@ -15,6 +16,7 @@ from cycode.cli.logger import logger
|
|
|
15
16
|
from cycode.cli.models import Document
|
|
16
17
|
from cycode.cli.utils.path_utils import get_path_by_os
|
|
17
18
|
from cycode.cli.utils.progress_bar import ScanProgressBarSection
|
|
19
|
+
from cycode.cli.utils.scan_utils import is_cycodeignore_allowed_by_scan_config
|
|
18
20
|
from cycode.cli.utils.sentry import add_breadcrumb
|
|
19
21
|
|
|
20
22
|
|
|
@@ -60,6 +62,9 @@ def repository_command(
|
|
|
60
62
|
|
|
61
63
|
documents_to_scan = excluder.exclude_irrelevant_documents_to_scan(scan_type, documents_to_scan)
|
|
62
64
|
|
|
65
|
+
is_cycodeignore_allowed = is_cycodeignore_allowed_by_scan_config(ctx)
|
|
66
|
+
documents_to_scan = filter_documents_with_cycodeignore(documents_to_scan, str(path), is_cycodeignore_allowed)
|
|
67
|
+
|
|
63
68
|
add_sca_dependencies_tree_documents_if_needed(ctx, scan_type, documents_to_scan)
|
|
64
69
|
|
|
65
70
|
logger.debug('Found all relevant files for scanning %s', {'path': path, 'branch': branch})
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from typing import Annotated, Optional
|
|
3
4
|
|
|
4
5
|
import click
|
|
5
6
|
import typer
|
|
6
7
|
|
|
8
|
+
from cycode.cli.apps.scan.remote_url_resolver import _try_get_git_remote_url
|
|
7
9
|
from cycode.cli.cli_types import ExportTypeOption, ScanTypeOption, ScaScanTypeOption, SeverityOption
|
|
8
10
|
from cycode.cli.consts import (
|
|
9
11
|
ISSUE_DETECTED_STATUS_CODE,
|
|
@@ -161,10 +163,15 @@ def scan_command(
|
|
|
161
163
|
scan_client = get_scan_cycode_client(ctx)
|
|
162
164
|
ctx.obj['client'] = scan_client
|
|
163
165
|
|
|
164
|
-
|
|
166
|
+
# Get remote URL from current working directory
|
|
167
|
+
remote_url = _try_get_git_remote_url(os.getcwd())
|
|
168
|
+
|
|
169
|
+
remote_scan_config = scan_client.get_scan_configuration_safe(scan_type, remote_url)
|
|
165
170
|
if remote_scan_config:
|
|
166
171
|
excluder.apply_scan_config(str(scan_type), remote_scan_config)
|
|
167
172
|
|
|
173
|
+
ctx.obj['scan_config'] = remote_scan_config
|
|
174
|
+
|
|
168
175
|
if export_type and export_file:
|
|
169
176
|
console_printer = ctx.obj['console_printer']
|
|
170
177
|
console_printer.enable_recording(export_type, export_file)
|
|
@@ -17,6 +17,8 @@ SAST_SCAN_TYPE = 'sast'
|
|
|
17
17
|
IAC_SCAN_SUPPORTED_FILE_EXTENSIONS = ('.tf', '.tf.json', '.json', '.yaml', '.yml', '.dockerfile', '.containerfile')
|
|
18
18
|
IAC_SCAN_SUPPORTED_FILE_PREFIXES = ('dockerfile', 'containerfile')
|
|
19
19
|
|
|
20
|
+
CYCODEIGNORE_FILENAME = '.cycodeignore'
|
|
21
|
+
|
|
20
22
|
SECRET_SCAN_FILE_EXTENSIONS_TO_IGNORE = (
|
|
21
23
|
'.DS_Store',
|
|
22
24
|
'.bmp',
|
{cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/files_collector/commit_range_documents.py
RENAMED
|
@@ -408,22 +408,7 @@ def get_pre_commit_modified_documents(
|
|
|
408
408
|
return git_head_documents, pre_committed_documents, diff_documents
|
|
409
409
|
|
|
410
410
|
|
|
411
|
-
def
|
|
412
|
-
# FIXME(MarshalX): i truly believe that this function does NOT work as expected
|
|
413
|
-
# it does not handle cases like 'A..B' correctly
|
|
414
|
-
# i leave it as it for SCA to not break anything
|
|
415
|
-
# the more correct approach is implemented for SAST
|
|
416
|
-
from_commit_rev = to_commit_rev = None
|
|
417
|
-
|
|
418
|
-
for commit in git_proxy.get_repo(path).iter_commits(rev=commit_range):
|
|
419
|
-
if not to_commit_rev:
|
|
420
|
-
to_commit_rev = commit.hexsha
|
|
421
|
-
from_commit_rev = commit.hexsha
|
|
422
|
-
|
|
423
|
-
return from_commit_rev, to_commit_rev
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
def parse_commit_range_sast(commit_range: str, path: str) -> tuple[Optional[str], Optional[str]]:
|
|
411
|
+
def parse_commit_range(commit_range: str, path: str) -> tuple[Optional[str], Optional[str]]:
|
|
427
412
|
"""Parses a git commit range string and returns the full SHAs for the 'from' and 'to' commits.
|
|
428
413
|
|
|
429
414
|
Supports:
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from cycode.cli import consts
|
|
5
|
+
from cycode.cli.logger import get_logger
|
|
6
|
+
from cycode.cli.utils.ignore_utils import IgnoreFilterManager
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from cycode.cli.models import Document
|
|
10
|
+
|
|
11
|
+
logger = get_logger('Documents Ignores')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_cycodeignore_path(repo_path: str) -> str:
|
|
15
|
+
"""Get the path to .cycodeignore file in the repository root."""
|
|
16
|
+
return os.path.join(repo_path, consts.CYCODEIGNORE_FILENAME)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _create_ignore_filter_manager(repo_path: str, cycodeignore_path: str) -> IgnoreFilterManager:
|
|
20
|
+
"""Create IgnoreFilterManager with .cycodeignore file."""
|
|
21
|
+
return IgnoreFilterManager.build(
|
|
22
|
+
path=repo_path,
|
|
23
|
+
global_ignore_file_paths=[cycodeignore_path],
|
|
24
|
+
global_patterns=[],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _log_ignored_files(repo_path: str, dirpath: str, ignored_dirnames: list[str], ignored_filenames: list[str]) -> None:
|
|
29
|
+
"""Log ignored files for debugging (similar to walk_ignore function)."""
|
|
30
|
+
rel_dirpath = '' if dirpath == repo_path else os.path.relpath(dirpath, repo_path)
|
|
31
|
+
display_dir = rel_dirpath or '.'
|
|
32
|
+
|
|
33
|
+
for is_dir, names in (
|
|
34
|
+
(True, ignored_dirnames),
|
|
35
|
+
(False, ignored_filenames),
|
|
36
|
+
):
|
|
37
|
+
for name in names:
|
|
38
|
+
full_path = os.path.join(repo_path, display_dir, name)
|
|
39
|
+
if is_dir:
|
|
40
|
+
full_path = os.path.join(full_path, '*')
|
|
41
|
+
logger.debug('Ignoring match %s', full_path)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _build_allowed_paths_set(ignore_filter_manager: IgnoreFilterManager, repo_path: str) -> set[str]:
|
|
45
|
+
"""Build set of allowed file paths using walk_with_ignored."""
|
|
46
|
+
allowed_paths = set()
|
|
47
|
+
|
|
48
|
+
for dirpath, _dirnames, filenames, ignored_dirnames, ignored_filenames in ignore_filter_manager.walk_with_ignored():
|
|
49
|
+
_log_ignored_files(repo_path, dirpath, ignored_dirnames, ignored_filenames)
|
|
50
|
+
|
|
51
|
+
for filename in filenames:
|
|
52
|
+
file_path = os.path.join(dirpath, filename)
|
|
53
|
+
allowed_paths.add(file_path)
|
|
54
|
+
|
|
55
|
+
return allowed_paths
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _get_document_check_path(document: 'Document', repo_path: str) -> str:
|
|
59
|
+
"""Get the normalized absolute path for a document to check against allowed paths."""
|
|
60
|
+
check_path = document.absolute_path
|
|
61
|
+
if not check_path:
|
|
62
|
+
check_path = document.path if os.path.isabs(document.path) else os.path.join(repo_path, document.path)
|
|
63
|
+
|
|
64
|
+
return os.path.normpath(check_path)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _filter_documents_by_allowed_paths(
|
|
68
|
+
documents: list['Document'], allowed_paths: set[str], repo_path: str
|
|
69
|
+
) -> list['Document']:
|
|
70
|
+
"""Filter documents by checking if their paths are in the allowed set."""
|
|
71
|
+
filtered_documents = []
|
|
72
|
+
|
|
73
|
+
for document in documents:
|
|
74
|
+
try:
|
|
75
|
+
check_path = _get_document_check_path(document, repo_path)
|
|
76
|
+
|
|
77
|
+
if check_path in allowed_paths:
|
|
78
|
+
filtered_documents.append(document)
|
|
79
|
+
else:
|
|
80
|
+
relative_path = os.path.relpath(check_path, repo_path)
|
|
81
|
+
logger.debug('Filtered out document due to .cycodeignore: %s', relative_path)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
logger.debug('Error processing document %s: %s', document.path, e)
|
|
84
|
+
filtered_documents.append(document)
|
|
85
|
+
|
|
86
|
+
return filtered_documents
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def filter_documents_with_cycodeignore(
|
|
90
|
+
documents: list['Document'], repo_path: str, is_cycodeignore_allowed: bool = True
|
|
91
|
+
) -> list['Document']:
|
|
92
|
+
"""Filter documents based on .cycodeignore patterns.
|
|
93
|
+
|
|
94
|
+
This function uses .cycodeignore file in the repository root to filter out
|
|
95
|
+
documents whose paths match any of those patterns.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
documents: List of Document objects to filter
|
|
99
|
+
repo_path: Path to the repository root
|
|
100
|
+
is_cycodeignore_allowed: Whether .cycodeignore filtering is allowed by scan configuration
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
List of Document objects that don't match any .cycodeignore patterns
|
|
104
|
+
"""
|
|
105
|
+
if not is_cycodeignore_allowed:
|
|
106
|
+
logger.debug('.cycodeignore filtering is not allowed by scan configuration')
|
|
107
|
+
return documents
|
|
108
|
+
|
|
109
|
+
cycodeignore_path = _get_cycodeignore_path(repo_path)
|
|
110
|
+
|
|
111
|
+
if not os.path.exists(cycodeignore_path):
|
|
112
|
+
logger.debug('.cycodeignore file does not exist in the repository root')
|
|
113
|
+
return documents
|
|
114
|
+
|
|
115
|
+
logger.info('Using %s for filtering documents', cycodeignore_path)
|
|
116
|
+
|
|
117
|
+
ignore_filter_manager = _create_ignore_filter_manager(repo_path, cycodeignore_path)
|
|
118
|
+
|
|
119
|
+
allowed_paths = _build_allowed_paths_set(ignore_filter_manager, repo_path)
|
|
120
|
+
|
|
121
|
+
filtered_documents = _filter_documents_by_allowed_paths(documents, allowed_paths, repo_path)
|
|
122
|
+
|
|
123
|
+
logger.debug('Filtered %d documents using .cycodeignore patterns', len(documents) - len(filtered_documents))
|
|
124
|
+
return filtered_documents
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from collections.abc import Generator
|
|
2
3
|
from typing import TYPE_CHECKING
|
|
3
4
|
|
|
4
5
|
from cycode.cli.files_collector.file_excluder import excluder
|
|
@@ -17,10 +18,18 @@ if TYPE_CHECKING:
|
|
|
17
18
|
from cycode.cli.utils.progress_bar import BaseProgressBar, ProgressBarSection
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
def _get_all_existing_files_in_directory(
|
|
21
|
+
def _get_all_existing_files_in_directory(
|
|
22
|
+
path: str, *, walk_with_ignore_patterns: bool = True, is_cycodeignore_allowed: bool = True
|
|
23
|
+
) -> list[str]:
|
|
21
24
|
files: list[str] = []
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
if walk_with_ignore_patterns:
|
|
27
|
+
|
|
28
|
+
def walk_func(path: str) -> Generator[tuple[str, list[str], list[str]], None, None]:
|
|
29
|
+
return walk_ignore(path, is_cycodeignore_allowed=is_cycodeignore_allowed)
|
|
30
|
+
else:
|
|
31
|
+
walk_func = os.walk
|
|
32
|
+
|
|
24
33
|
for root, _, filenames in walk_func(path):
|
|
25
34
|
for filename in filenames:
|
|
26
35
|
files.append(os.path.join(root, filename))
|
|
@@ -28,7 +37,7 @@ def _get_all_existing_files_in_directory(path: str, *, walk_with_ignore_patterns
|
|
|
28
37
|
return files
|
|
29
38
|
|
|
30
39
|
|
|
31
|
-
def _get_relevant_files_in_path(path: str) -> list[str]:
|
|
40
|
+
def _get_relevant_files_in_path(path: str, *, is_cycodeignore_allowed: bool = True) -> list[str]:
|
|
32
41
|
absolute_path = get_absolute_path(path)
|
|
33
42
|
|
|
34
43
|
if not os.path.isfile(absolute_path) and not os.path.isdir(absolute_path):
|
|
@@ -37,16 +46,21 @@ def _get_relevant_files_in_path(path: str) -> list[str]:
|
|
|
37
46
|
if os.path.isfile(absolute_path):
|
|
38
47
|
return [absolute_path]
|
|
39
48
|
|
|
40
|
-
file_paths = _get_all_existing_files_in_directory(absolute_path)
|
|
49
|
+
file_paths = _get_all_existing_files_in_directory(absolute_path, is_cycodeignore_allowed=is_cycodeignore_allowed)
|
|
41
50
|
return [file_path for file_path in file_paths if os.path.isfile(file_path)]
|
|
42
51
|
|
|
43
52
|
|
|
44
53
|
def _get_relevant_files(
|
|
45
|
-
progress_bar: 'BaseProgressBar',
|
|
54
|
+
progress_bar: 'BaseProgressBar',
|
|
55
|
+
progress_bar_section: 'ProgressBarSection',
|
|
56
|
+
scan_type: str,
|
|
57
|
+
paths: tuple[str, ...],
|
|
58
|
+
*,
|
|
59
|
+
is_cycodeignore_allowed: bool = True,
|
|
46
60
|
) -> list[str]:
|
|
47
61
|
all_files_to_scan = []
|
|
48
62
|
for path in paths:
|
|
49
|
-
all_files_to_scan.extend(_get_relevant_files_in_path(path))
|
|
63
|
+
all_files_to_scan.extend(_get_relevant_files_in_path(path, is_cycodeignore_allowed=is_cycodeignore_allowed))
|
|
50
64
|
|
|
51
65
|
# we are double the progress bar section length because we are going to process the files twice
|
|
52
66
|
# first time to get the file list with respect of excluded patterns (excluding takes seconds to execute)
|
|
@@ -94,8 +108,11 @@ def get_relevant_documents(
|
|
|
94
108
|
paths: tuple[str, ...],
|
|
95
109
|
*,
|
|
96
110
|
is_git_diff: bool = False,
|
|
111
|
+
is_cycodeignore_allowed: bool = True,
|
|
97
112
|
) -> list[Document]:
|
|
98
|
-
relevant_files = _get_relevant_files(
|
|
113
|
+
relevant_files = _get_relevant_files(
|
|
114
|
+
progress_bar, progress_bar_section, scan_type, paths, is_cycodeignore_allowed=is_cycodeignore_allowed
|
|
115
|
+
)
|
|
99
116
|
|
|
100
117
|
documents: list[Document] = []
|
|
101
118
|
for file in relevant_files:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from collections.abc import Generator, Iterable
|
|
3
3
|
|
|
4
|
+
from cycode.cli import consts
|
|
4
5
|
from cycode.cli.logger import get_logger
|
|
5
6
|
from cycode.cli.utils.ignore_utils import IgnoreFilterManager
|
|
6
7
|
|
|
@@ -8,7 +9,6 @@ logger = get_logger('Ignores')
|
|
|
8
9
|
|
|
9
10
|
_SUPPORTED_IGNORE_PATTERN_FILES = {
|
|
10
11
|
'.gitignore',
|
|
11
|
-
'.cycodeignore',
|
|
12
12
|
}
|
|
13
13
|
_DEFAULT_GLOBAL_IGNORE_PATTERNS = [
|
|
14
14
|
'.git',
|
|
@@ -25,11 +25,17 @@ def _walk_to_top(path: str) -> Iterable[str]:
|
|
|
25
25
|
yield path # Include the top-level directory
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def _collect_top_level_ignore_files(path: str) -> list[str]:
|
|
28
|
+
def _collect_top_level_ignore_files(path: str, *, is_cycodeignore_allowed: bool = True) -> list[str]:
|
|
29
29
|
ignore_files = []
|
|
30
30
|
top_paths = reversed(list(_walk_to_top(path))) # we must reverse it to make top levels more prioritized
|
|
31
|
+
|
|
32
|
+
supported_files = set(_SUPPORTED_IGNORE_PATTERN_FILES)
|
|
33
|
+
if is_cycodeignore_allowed:
|
|
34
|
+
supported_files.add(consts.CYCODEIGNORE_FILENAME)
|
|
35
|
+
logger.debug('.cycodeignore files included due to scan configuration')
|
|
36
|
+
|
|
31
37
|
for dir_path in top_paths:
|
|
32
|
-
for ignore_file in
|
|
38
|
+
for ignore_file in supported_files:
|
|
33
39
|
ignore_file_path = os.path.join(dir_path, ignore_file)
|
|
34
40
|
if os.path.exists(ignore_file_path):
|
|
35
41
|
logger.debug('Reading top level ignore file: %s', ignore_file_path)
|
|
@@ -37,10 +43,13 @@ def _collect_top_level_ignore_files(path: str) -> list[str]:
|
|
|
37
43
|
return ignore_files
|
|
38
44
|
|
|
39
45
|
|
|
40
|
-
def walk_ignore(
|
|
46
|
+
def walk_ignore(
|
|
47
|
+
path: str, *, is_cycodeignore_allowed: bool = True
|
|
48
|
+
) -> Generator[tuple[str, list[str], list[str]], None, None]:
|
|
49
|
+
ignore_file_paths = _collect_top_level_ignore_files(path, is_cycodeignore_allowed=is_cycodeignore_allowed)
|
|
41
50
|
ignore_filter_manager = IgnoreFilterManager.build(
|
|
42
51
|
path=path,
|
|
43
|
-
global_ignore_file_paths=
|
|
52
|
+
global_ignore_file_paths=ignore_file_paths,
|
|
44
53
|
global_patterns=_DEFAULT_GLOBAL_IGNORE_PATTERNS,
|
|
45
54
|
)
|
|
46
55
|
for dirpath, dirnames, filenames, ignored_dirnames, ignored_filenames in ignore_filter_manager.walk_with_ignored():
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import TYPE_CHECKING
|
|
2
|
+
from typing import TYPE_CHECKING, Optional
|
|
3
3
|
from uuid import UUID, uuid4
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
6
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from cycode.cli.models import LocalScanResult
|
|
9
|
+
from cycode.cyclient.models import ScanConfiguration
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def set_issue_detected(ctx: typer.Context, issue_detected: bool) -> None:
|
|
@@ -22,6 +23,11 @@ def is_scan_failed(ctx: typer.Context) -> bool:
|
|
|
22
23
|
return did_fail or issue_detected
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
def is_cycodeignore_allowed_by_scan_config(ctx: typer.Context) -> bool:
|
|
27
|
+
scan_config: Optional[ScanConfiguration] = ctx.obj.get('scan_config')
|
|
28
|
+
return scan_config.is_cycode_ignore_allowed if scan_config else True
|
|
29
|
+
|
|
30
|
+
|
|
25
31
|
def generate_unique_scan_id() -> UUID:
|
|
26
32
|
if 'PYTEST_TEST_UNIQUE_ID' in os.environ:
|
|
27
33
|
return UUID(os.environ['PYTEST_TEST_UNIQUE_ID'])
|
|
@@ -505,6 +505,7 @@ class SupportedModulesPreferencesSchema(Schema):
|
|
|
505
505
|
@dataclass
|
|
506
506
|
class ScanConfiguration:
|
|
507
507
|
scannable_extensions: list[str]
|
|
508
|
+
is_cycode_ignore_allowed: bool
|
|
508
509
|
|
|
509
510
|
|
|
510
511
|
class ScanConfigurationSchema(Schema):
|
|
@@ -512,6 +513,7 @@ class ScanConfigurationSchema(Schema):
|
|
|
512
513
|
unknown = EXCLUDE
|
|
513
514
|
|
|
514
515
|
scannable_extensions = fields.List(fields.String(), allow_none=True)
|
|
516
|
+
is_cycode_ignore_allowed = fields.Boolean(load_default=True)
|
|
515
517
|
|
|
516
518
|
@post_load
|
|
517
519
|
def build_dto(self, data: dict[str, Any], **_) -> 'ScanConfiguration':
|
|
@@ -280,16 +280,23 @@ class ScanClient:
|
|
|
280
280
|
correct_scan_type = self.scan_config.get_async_scan_type(scan_type)
|
|
281
281
|
return f'{self.get_scan_service_url_path(scan_type)}/{correct_scan_type}/configuration'
|
|
282
282
|
|
|
283
|
-
def get_scan_configuration(self, scan_type: str) -> models.ScanConfiguration:
|
|
283
|
+
def get_scan_configuration(self, scan_type: str, remote_url: Optional[str] = None) -> models.ScanConfiguration:
|
|
284
|
+
params = {}
|
|
285
|
+
if remote_url:
|
|
286
|
+
params['remote_url'] = remote_url
|
|
287
|
+
|
|
284
288
|
response = self.scan_cycode_client.get(
|
|
285
289
|
url_path=self.get_scan_configuration_path(scan_type),
|
|
290
|
+
params=params,
|
|
286
291
|
hide_response_content_log=self._hide_response_log,
|
|
287
292
|
)
|
|
288
293
|
return models.ScanConfigurationSchema().load(response.json())
|
|
289
294
|
|
|
290
|
-
def get_scan_configuration_safe(
|
|
295
|
+
def get_scan_configuration_safe(
|
|
296
|
+
self, scan_type: str, remote_url: Optional[str] = None
|
|
297
|
+
) -> Optional['models.ScanConfiguration']:
|
|
291
298
|
try:
|
|
292
|
-
return self.get_scan_configuration(scan_type)
|
|
299
|
+
return self.get_scan_configuration(scan_type, remote_url)
|
|
293
300
|
except RequestHttpError as e:
|
|
294
301
|
if e.status_code == 404:
|
|
295
302
|
logger.debug(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cycode"
|
|
3
|
-
version = "3.5.
|
|
3
|
+
version = "3.5.3.dev2" # 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.5.2.dev1' # 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
|
{cycode-3.5.2.dev1 → cycode-3.5.3.dev2}/cycode/cli/apps/ai_remediation/ai_remediation_command.py
RENAMED
|
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
|