cycode 2.3.1.dev2__tar.gz → 2.3.1.dev3__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-2.3.1.dev2 → cycode-2.3.1.dev3}/PKG-INFO +1 -1
- cycode-2.3.1.dev3/cycode/__init__.py +1 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/code_scanner.py +1 -1
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/consts.py +4 -0
- cycode-2.3.1.dev3/cycode/cli/utils/scan_batch.py +138 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/pyproject.toml +1 -1
- cycode-2.3.1.dev2/cycode/__init__.py +0 -1
- cycode-2.3.1.dev2/cycode/cli/utils/scan_batch.py +0 -75
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/LICENCE +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/README.md +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/ai_remediation/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/ai_remediation/ai_remediation_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/auth/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/auth/auth_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/auth/auth_manager.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/auth_common.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/configure/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/configure/configure_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/ignore/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/ignore/ignore_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/main_cli.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/report_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/common.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/path/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/path/path_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/repository_url/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/repository_url/repository_url_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/sbom_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/sbom_report_file.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/commit_history/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/commit_history/commit_history_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/path/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/path/path_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_commit/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_commit/pre_commit_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_receive/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_receive/pre_receive_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/repository/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/repository/repository_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/scan_ci/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/scan_ci/ci_integrations.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/scan_ci/scan_ci_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/scan_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/status/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/status/status_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/version/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/version/version_checker.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/version/version_command.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/config.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/config.yaml +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/common.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/custom_exceptions.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/handle_ai_remediation_errors.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/handle_report_sbom_errors.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/handle_scan_errors.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/excluder.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/iac/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/iac/tf_content_generator.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/models/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/models/in_memory_zip.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/path_documents.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/repository_documents.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/base_restore_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/go/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/go/restore_go_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/maven/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/npm/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/nuget/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/nuget/restore_nuget_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/ruby/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/ruby/restore_ruby_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/sbt/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/sca_code_scanner.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/walk_ignore.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/zip_documents.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/main.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/models.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/console_printer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/json_printer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/printer_base.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/sca_table_printer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/table.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/table_models.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/table_printer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/tables/table_printer_base.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/printers/text_printer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/sentry.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/base_file_manager.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/config_file_manager.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/configuration_manager.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/credentials_manager.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/user_settings/jwt_creator.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/enum_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/get_api_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/git_proxy.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/ignore_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/jwt_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/path_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/progress_bar.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/scan_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/shell_executor.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/string_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/task_timer.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/utils/yaml_utils.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/__init__.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/auth_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/client_creator.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/config.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/config.yaml +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/config_dev.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/cycode_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/cycode_client_base.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/cycode_dev_based_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/cycode_token_based_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/headers.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/models.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/report_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/scan_client.py +0 -0
- {cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cyclient/scan_config_base.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.3.1.dev3' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
|
|
@@ -171,7 +171,7 @@ def _get_scan_documents_thread_func(
|
|
|
171
171
|
should_use_sync_flow = _should_use_sync_flow(command_scan_type, scan_type, sync_option, scan_parameters)
|
|
172
172
|
|
|
173
173
|
try:
|
|
174
|
-
logger.debug('Preparing local files, %s', {'
|
|
174
|
+
logger.debug('Preparing local files, %s', {'batch_files_count': len(batch)})
|
|
175
175
|
zipped_documents = zip_documents(scan_type, batch)
|
|
176
176
|
zip_file_size = zipped_documents.size
|
|
177
177
|
scan_result = perform_scan(
|
|
@@ -145,7 +145,11 @@ ZIP_MAX_SIZE_LIMIT_IN_BYTES = {
|
|
|
145
145
|
# scan in batches
|
|
146
146
|
DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES = 9 * 1024 * 1024
|
|
147
147
|
SCAN_BATCH_MAX_SIZE_IN_BYTES = {SAST_SCAN_TYPE: 50 * 1024 * 1024}
|
|
148
|
+
SCAN_BATCH_MAX_SIZE_IN_BYTES_ENV_VAR_NAME = 'SCAN_BATCH_MAX_SIZE_IN_BYTES'
|
|
149
|
+
|
|
148
150
|
DEFAULT_SCAN_BATCH_MAX_FILES_COUNT = 1000
|
|
151
|
+
SCAN_BATCH_MAX_FILES_COUNT_ENV_VAR_NAME = 'SCAN_BATCH_MAX_FILES_COUNT'
|
|
152
|
+
|
|
149
153
|
# if we increase this values, the server doesn't allow connecting (ConnectionError)
|
|
150
154
|
SCAN_BATCH_MAX_PARALLEL_SCANS = 5
|
|
151
155
|
SCAN_BATCH_SCANS_PER_CPU = 1
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from multiprocessing.pool import ThreadPool
|
|
3
|
+
from typing import TYPE_CHECKING, Callable, Dict, List, Tuple
|
|
4
|
+
|
|
5
|
+
from cycode.cli import consts
|
|
6
|
+
from cycode.cli.models import Document
|
|
7
|
+
from cycode.cli.utils.progress_bar import ScanProgressBarSection
|
|
8
|
+
from cycode.cyclient import logger
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from cycode.cli.models import CliError, LocalScanResult
|
|
12
|
+
from cycode.cli.utils.progress_bar import BaseProgressBar
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_max_batch_size(scan_type: str) -> int:
|
|
16
|
+
logger.debug(
|
|
17
|
+
'You can customize the batch size by setting the environment variable "%s"',
|
|
18
|
+
consts.SCAN_BATCH_MAX_SIZE_IN_BYTES_ENV_VAR_NAME,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
custom_size = os.environ.get(consts.SCAN_BATCH_MAX_SIZE_IN_BYTES_ENV_VAR_NAME)
|
|
22
|
+
if custom_size:
|
|
23
|
+
logger.debug('Custom batch size is set, %s', {'custom_size': custom_size})
|
|
24
|
+
return int(custom_size)
|
|
25
|
+
|
|
26
|
+
return consts.SCAN_BATCH_MAX_SIZE_IN_BYTES.get(scan_type, consts.DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _get_max_batch_files_count(_: str) -> int:
|
|
30
|
+
logger.debug(
|
|
31
|
+
'You can customize the batch files count by setting the environment variable "%s"',
|
|
32
|
+
consts.SCAN_BATCH_MAX_FILES_COUNT_ENV_VAR_NAME,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
custom_files_count = os.environ.get(consts.SCAN_BATCH_MAX_FILES_COUNT_ENV_VAR_NAME)
|
|
36
|
+
if custom_files_count:
|
|
37
|
+
logger.debug('Custom batch files count is set, %s', {'custom_files_count': custom_files_count})
|
|
38
|
+
return int(custom_files_count)
|
|
39
|
+
|
|
40
|
+
return consts.DEFAULT_SCAN_BATCH_MAX_FILES_COUNT
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def split_documents_into_batches(
|
|
44
|
+
scan_type: str,
|
|
45
|
+
documents: List[Document],
|
|
46
|
+
) -> List[List[Document]]:
|
|
47
|
+
max_size = _get_max_batch_size(scan_type)
|
|
48
|
+
max_files_count = _get_max_batch_files_count(scan_type)
|
|
49
|
+
|
|
50
|
+
logger.debug(
|
|
51
|
+
'Splitting documents into batches, %s',
|
|
52
|
+
{'document_count': len(documents), 'max_batch_size': max_size, 'max_files_count': max_files_count},
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
batches = []
|
|
56
|
+
|
|
57
|
+
current_size = 0
|
|
58
|
+
current_batch = []
|
|
59
|
+
for document in documents:
|
|
60
|
+
document_size = len(document.content.encode('UTF-8'))
|
|
61
|
+
|
|
62
|
+
exceeds_max_size = current_size + document_size > max_size
|
|
63
|
+
if exceeds_max_size:
|
|
64
|
+
logger.debug(
|
|
65
|
+
'Going to create new batch because current batch size exceeds the limit, %s',
|
|
66
|
+
{
|
|
67
|
+
'batch_index': len(batches),
|
|
68
|
+
'current_batch_size': current_size + document_size,
|
|
69
|
+
'max_batch_size': max_size,
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
exceeds_max_files_count = len(current_batch) >= max_files_count
|
|
74
|
+
if exceeds_max_files_count:
|
|
75
|
+
logger.debug(
|
|
76
|
+
'Going to create new batch because current batch files count exceeds the limit, %s',
|
|
77
|
+
{
|
|
78
|
+
'batch_index': len(batches),
|
|
79
|
+
'current_batch_files_count': len(current_batch),
|
|
80
|
+
'max_batch_files_count': max_files_count,
|
|
81
|
+
},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
if exceeds_max_size or exceeds_max_files_count:
|
|
85
|
+
batches.append(current_batch)
|
|
86
|
+
|
|
87
|
+
current_batch = [document]
|
|
88
|
+
current_size = document_size
|
|
89
|
+
else:
|
|
90
|
+
current_batch.append(document)
|
|
91
|
+
current_size += document_size
|
|
92
|
+
|
|
93
|
+
if current_batch:
|
|
94
|
+
batches.append(current_batch)
|
|
95
|
+
|
|
96
|
+
logger.debug('Documents were split into batches %s', {'batches_count': len(batches)})
|
|
97
|
+
|
|
98
|
+
return batches
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _get_threads_count() -> int:
|
|
102
|
+
cpu_count = os.cpu_count() or 1
|
|
103
|
+
return min(cpu_count * consts.SCAN_BATCH_SCANS_PER_CPU, consts.SCAN_BATCH_MAX_PARALLEL_SCANS)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def run_parallel_batched_scan(
|
|
107
|
+
scan_function: Callable[[List[Document]], Tuple[str, 'CliError', 'LocalScanResult']],
|
|
108
|
+
scan_type: str,
|
|
109
|
+
documents: List[Document],
|
|
110
|
+
progress_bar: 'BaseProgressBar',
|
|
111
|
+
) -> Tuple[Dict[str, 'CliError'], List['LocalScanResult']]:
|
|
112
|
+
# batching is disabled for SCA; requested by Mor
|
|
113
|
+
batches = [documents] if scan_type == consts.SCA_SCAN_TYPE else split_documents_into_batches(scan_type, documents)
|
|
114
|
+
|
|
115
|
+
progress_bar.set_section_length(ScanProgressBarSection.SCAN, len(batches)) # * 3
|
|
116
|
+
# TODO(MarshalX): we should multiply the count of batches in SCAN section because each batch has 3 steps:
|
|
117
|
+
# 1. scan creation
|
|
118
|
+
# 2. scan completion
|
|
119
|
+
# 3. detection creation
|
|
120
|
+
# it's not possible yet because not all scan types moved to polling mechanism
|
|
121
|
+
# the progress bar could be significant improved (be more dynamic) in the future
|
|
122
|
+
|
|
123
|
+
threads_count = _get_threads_count()
|
|
124
|
+
local_scan_results: List['LocalScanResult'] = []
|
|
125
|
+
cli_errors: Dict[str, 'CliError'] = {}
|
|
126
|
+
|
|
127
|
+
logger.debug('Running parallel batched scan, %s', {'threads_count': threads_count, 'batches_count': len(batches)})
|
|
128
|
+
|
|
129
|
+
with ThreadPool(processes=threads_count) as pool:
|
|
130
|
+
for scan_id, err, result in pool.imap(scan_function, batches):
|
|
131
|
+
if result:
|
|
132
|
+
local_scan_results.append(result)
|
|
133
|
+
if err:
|
|
134
|
+
cli_errors[scan_id] = err
|
|
135
|
+
|
|
136
|
+
progress_bar.update(ScanProgressBarSection.SCAN)
|
|
137
|
+
|
|
138
|
+
return cli_errors, local_scan_results
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cycode"
|
|
3
|
-
version = "2.3.1.
|
|
3
|
+
version = "2.3.1.dev3" # 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__ = '2.3.1.dev2' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from multiprocessing.pool import ThreadPool
|
|
3
|
-
from typing import TYPE_CHECKING, Callable, Dict, List, Tuple
|
|
4
|
-
|
|
5
|
-
from cycode.cli import consts
|
|
6
|
-
from cycode.cli.models import Document
|
|
7
|
-
from cycode.cli.utils.progress_bar import ScanProgressBarSection
|
|
8
|
-
|
|
9
|
-
if TYPE_CHECKING:
|
|
10
|
-
from cycode.cli.models import CliError, LocalScanResult
|
|
11
|
-
from cycode.cli.utils.progress_bar import BaseProgressBar
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def split_documents_into_batches(
|
|
15
|
-
documents: List[Document],
|
|
16
|
-
max_size: int = consts.DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES,
|
|
17
|
-
max_files_count: int = consts.DEFAULT_SCAN_BATCH_MAX_FILES_COUNT,
|
|
18
|
-
) -> List[List[Document]]:
|
|
19
|
-
batches = []
|
|
20
|
-
|
|
21
|
-
current_size = 0
|
|
22
|
-
current_batch = []
|
|
23
|
-
for document in documents:
|
|
24
|
-
document_size = len(document.content.encode('UTF-8'))
|
|
25
|
-
|
|
26
|
-
if (current_size + document_size > max_size) or (len(current_batch) >= max_files_count):
|
|
27
|
-
batches.append(current_batch)
|
|
28
|
-
|
|
29
|
-
current_batch = [document]
|
|
30
|
-
current_size = document_size
|
|
31
|
-
else:
|
|
32
|
-
current_batch.append(document)
|
|
33
|
-
current_size += document_size
|
|
34
|
-
|
|
35
|
-
if current_batch:
|
|
36
|
-
batches.append(current_batch)
|
|
37
|
-
|
|
38
|
-
return batches
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _get_threads_count() -> int:
|
|
42
|
-
cpu_count = os.cpu_count() or 1
|
|
43
|
-
return min(cpu_count * consts.SCAN_BATCH_SCANS_PER_CPU, consts.SCAN_BATCH_MAX_PARALLEL_SCANS)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def run_parallel_batched_scan(
|
|
47
|
-
scan_function: Callable[[List[Document]], Tuple[str, 'CliError', 'LocalScanResult']],
|
|
48
|
-
scan_type: str,
|
|
49
|
-
documents: List[Document],
|
|
50
|
-
progress_bar: 'BaseProgressBar',
|
|
51
|
-
) -> Tuple[Dict[str, 'CliError'], List['LocalScanResult']]:
|
|
52
|
-
max_size = consts.SCAN_BATCH_MAX_SIZE_IN_BYTES.get(scan_type, consts.DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES)
|
|
53
|
-
|
|
54
|
-
batches = [documents] if scan_type == consts.SCA_SCAN_TYPE else split_documents_into_batches(documents, max_size)
|
|
55
|
-
|
|
56
|
-
progress_bar.set_section_length(ScanProgressBarSection.SCAN, len(batches)) # * 3
|
|
57
|
-
# TODO(MarshalX): we should multiply the count of batches in SCAN section because each batch has 3 steps:
|
|
58
|
-
# 1. scan creation
|
|
59
|
-
# 2. scan completion
|
|
60
|
-
# 3. detection creation
|
|
61
|
-
# it's not possible yet because not all scan types moved to polling mechanism
|
|
62
|
-
# the progress bar could be significant improved (be more dynamic) in the future
|
|
63
|
-
|
|
64
|
-
local_scan_results: List['LocalScanResult'] = []
|
|
65
|
-
cli_errors: Dict[str, 'CliError'] = {}
|
|
66
|
-
with ThreadPool(processes=_get_threads_count()) as pool:
|
|
67
|
-
for scan_id, err, result in pool.imap(scan_function, batches):
|
|
68
|
-
if result:
|
|
69
|
-
local_scan_results.append(result)
|
|
70
|
-
if err:
|
|
71
|
-
cli_errors[scan_id] = err
|
|
72
|
-
|
|
73
|
-
progress_bar.update(ScanProgressBarSection.SCAN)
|
|
74
|
-
|
|
75
|
-
return cli_errors, local_scan_results
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/path/path_command.py
RENAMED
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/report/sbom/repository_url/__init__.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
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_commit/pre_commit_command.py
RENAMED
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/pre_receive/pre_receive_command.py
RENAMED
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/commands/scan/repository/repository_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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/exceptions/handle_ai_remediation_errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/iac/tf_content_generator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/base_restore_dependencies.py
RENAMED
|
File without changes
|
|
File without changes
|
{cycode-2.3.1.dev2 → cycode-2.3.1.dev3}/cycode/cli/files_collector/sca/go/restore_go_dependencies.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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|