cycode 2.2.1.dev2__py3-none-any.whl → 2.2.1.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cycode/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '2.2.1.dev2' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
1
+ __version__ = '2.2.1.dev3' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -301,6 +301,7 @@ def scan_documents(
301
301
  if not scan_parameters:
302
302
  scan_parameters = get_default_scan_parameters(context)
303
303
 
304
+ scan_type = context.obj['scan_type']
304
305
  progress_bar = context.obj['progress_bar']
305
306
 
306
307
  if not documents_to_scan:
@@ -318,13 +319,13 @@ def scan_documents(
318
319
  context, is_git_diff, is_commit_range, scan_parameters
319
320
  )
320
321
  errors, local_scan_results = run_parallel_batched_scan(
321
- scan_batch_thread_func, documents_to_scan, progress_bar=progress_bar
322
+ scan_batch_thread_func, scan_type, documents_to_scan, progress_bar=progress_bar
322
323
  )
323
324
 
324
325
  if len(local_scan_results) > 1:
325
326
  # if we used more than one batch, we need to fetch aggregate report url
326
327
  aggregation_report_url = _try_get_aggregation_report_url_if_needed(
327
- scan_parameters, context.obj['client'], context.obj['scan_type']
328
+ scan_parameters, context.obj['client'], scan_type
328
329
  )
329
330
  set_aggregation_report_url(context, aggregation_report_url)
330
331
 
@@ -3,6 +3,7 @@ from typing import List
3
3
 
4
4
  import click
5
5
 
6
+ from cycode.cli import consts
6
7
  from cycode.cli.commands.scan.commit_history.commit_history_command import commit_history_command
7
8
  from cycode.cli.commands.scan.path.path_command import path_command
8
9
  from cycode.cli.commands.scan.pre_commit.pre_commit_command import pre_commit_command
@@ -34,7 +35,7 @@ from cycode.cli.utils.get_api_client import get_scan_cycode_client
34
35
  @click.option(
35
36
  '--scan-type',
36
37
  '-t',
37
- default='secret',
38
+ default=consts.SECRET_SCAN_TYPE,
38
39
  help='Specify the type of scan you wish to execute (the default is Secrets).',
39
40
  type=click.Choice(config['scans']['supported_scans']),
40
41
  )
cycode/cli/consts.py CHANGED
@@ -136,14 +136,16 @@ EXCLUSIONS_BY_CVE_SECTION_NAME = 'cves'
136
136
  # 5MB in bytes (in decimal)
137
137
  FILE_MAX_SIZE_LIMIT_IN_BYTES = 5000000
138
138
 
139
- # 20MB in bytes (in binary)
140
- ZIP_MAX_SIZE_LIMIT_IN_BYTES = 20971520
141
- # 200MB in bytes (in binary)
142
- SCA_ZIP_MAX_SIZE_LIMIT_IN_BYTES = 209715200
139
+ DEFAULT_ZIP_MAX_SIZE_LIMIT_IN_BYTES = 20 * 1024 * 1024
140
+ ZIP_MAX_SIZE_LIMIT_IN_BYTES = {
141
+ SCA_SCAN_TYPE: 200 * 1024 * 1024,
142
+ SAST_SCAN_TYPE: 50 * 1024 * 1024,
143
+ }
143
144
 
144
145
  # scan in batches
145
- SCAN_BATCH_MAX_SIZE_IN_BYTES = 9 * 1024 * 1024
146
- SCAN_BATCH_MAX_FILES_COUNT = 1000
146
+ DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES = 9 * 1024 * 1024
147
+ SCAN_BATCH_MAX_SIZE_IN_BYTES = {SAST_SCAN_TYPE: 50 * 1024 * 1024}
148
+ DEFAULT_SCAN_BATCH_MAX_FILES_COUNT = 1000
147
149
  # if we increase this values, the server doesn't allow connecting (ConnectionError)
148
150
  SCAN_BATCH_MAX_PARALLEL_SCANS = 5
149
151
  SCAN_BATCH_SCANS_PER_CPU = 1
@@ -10,12 +10,9 @@ from cycode.cyclient import logger
10
10
 
11
11
 
12
12
  def _validate_zip_file_size(scan_type: str, zip_file_size: int) -> None:
13
- if scan_type == consts.SCA_SCAN_TYPE:
14
- if zip_file_size > consts.SCA_ZIP_MAX_SIZE_LIMIT_IN_BYTES:
15
- raise custom_exceptions.ZipTooLargeError(consts.SCA_ZIP_MAX_SIZE_LIMIT_IN_BYTES)
16
- else:
17
- if zip_file_size > consts.ZIP_MAX_SIZE_LIMIT_IN_BYTES:
18
- raise custom_exceptions.ZipTooLargeError(consts.ZIP_MAX_SIZE_LIMIT_IN_BYTES)
13
+ max_size_limit = consts.ZIP_MAX_SIZE_LIMIT_IN_BYTES.get(scan_type, consts.DEFAULT_ZIP_MAX_SIZE_LIMIT_IN_BYTES)
14
+ if zip_file_size > max_size_limit:
15
+ raise custom_exceptions.ZipTooLargeError(max_size_limit)
19
16
 
20
17
 
21
18
  def zip_documents(scan_type: str, documents: List[Document], zip_file: Optional[InMemoryZip] = None) -> InMemoryZip:
@@ -2,12 +2,7 @@ import os
2
2
  from multiprocessing.pool import ThreadPool
3
3
  from typing import TYPE_CHECKING, Callable, Dict, List, Tuple
4
4
 
5
- from cycode.cli.consts import (
6
- SCAN_BATCH_MAX_FILES_COUNT,
7
- SCAN_BATCH_MAX_PARALLEL_SCANS,
8
- SCAN_BATCH_MAX_SIZE_IN_BYTES,
9
- SCAN_BATCH_SCANS_PER_CPU,
10
- )
5
+ from cycode.cli import consts
11
6
  from cycode.cli.models import Document
12
7
  from cycode.cli.utils.progress_bar import ScanProgressBarSection
13
8
 
@@ -18,8 +13,8 @@ if TYPE_CHECKING:
18
13
 
19
14
  def split_documents_into_batches(
20
15
  documents: List[Document],
21
- max_size_mb: int = SCAN_BATCH_MAX_SIZE_IN_BYTES,
22
- max_files_count: int = SCAN_BATCH_MAX_FILES_COUNT,
16
+ max_size: int = consts.DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES,
17
+ max_files_count: int = consts.DEFAULT_SCAN_BATCH_MAX_FILES_COUNT,
23
18
  ) -> List[List[Document]]:
24
19
  batches = []
25
20
 
@@ -28,7 +23,7 @@ def split_documents_into_batches(
28
23
  for document in documents:
29
24
  document_size = len(document.content.encode('UTF-8'))
30
25
 
31
- if (current_size + document_size > max_size_mb) or (len(current_batch) >= max_files_count):
26
+ if (current_size + document_size > max_size) or (len(current_batch) >= max_files_count):
32
27
  batches.append(current_batch)
33
28
 
34
29
  current_batch = [document]
@@ -45,17 +40,18 @@ def split_documents_into_batches(
45
40
 
46
41
  def _get_threads_count() -> int:
47
42
  cpu_count = os.cpu_count() or 1
48
- return min(cpu_count * SCAN_BATCH_SCANS_PER_CPU, SCAN_BATCH_MAX_PARALLEL_SCANS)
43
+ return min(cpu_count * consts.SCAN_BATCH_SCANS_PER_CPU, consts.SCAN_BATCH_MAX_PARALLEL_SCANS)
49
44
 
50
45
 
51
46
  def run_parallel_batched_scan(
52
47
  scan_function: Callable[[List[Document]], Tuple[str, 'CliError', 'LocalScanResult']],
48
+ scan_type: str,
53
49
  documents: List[Document],
54
50
  progress_bar: 'BaseProgressBar',
55
- max_size_mb: int = SCAN_BATCH_MAX_SIZE_IN_BYTES,
56
- max_files_count: int = SCAN_BATCH_MAX_FILES_COUNT,
57
51
  ) -> Tuple[Dict[str, 'CliError'], List['LocalScanResult']]:
58
- batches = split_documents_into_batches(documents, max_size_mb, max_files_count)
52
+ max_size = consts.SCAN_BATCH_MAX_SIZE_IN_BYTES.get(scan_type, consts.DEFAULT_SCAN_BATCH_MAX_SIZE_IN_BYTES)
53
+ batches = split_documents_into_batches(documents, max_size)
54
+
59
55
  progress_bar.set_section_length(ScanProgressBarSection.SCAN, len(batches)) # * 3
60
56
  # TODO(MarshalX): we should multiply the count of batches in SCAN section because each batch has 3 steps:
61
57
  # 1. scan creation
@@ -328,11 +328,11 @@ class ScanClient:
328
328
  @staticmethod
329
329
  def get_service_name(scan_type: str) -> Optional[str]:
330
330
  # TODO(MarshalX): get_service_name should be removed from ScanClient? Because it exists in ScanConfig
331
- if scan_type == 'secret':
331
+ if scan_type == consts.SECRET_SCAN_TYPE:
332
332
  return 'secret'
333
- if scan_type == 'iac':
333
+ if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
334
334
  return 'iac'
335
- if scan_type == 'sca' or scan_type == 'sast':
335
+ if scan_type == consts.SCA_SCAN_TYPE or scan_type == consts.SAST_SCAN_TYPE:
336
336
  return 'scans'
337
337
 
338
338
  return None
@@ -9,9 +9,9 @@ class ScanConfigBase(ABC):
9
9
 
10
10
  @staticmethod
11
11
  def get_async_scan_type(scan_type: str) -> str:
12
- if scan_type == 'secret':
12
+ if scan_type == consts.SECRET_SCAN_TYPE:
13
13
  return 'Secrets'
14
- if scan_type == 'iac':
14
+ if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
15
15
  return 'InfraConfiguration'
16
16
 
17
17
  return scan_type.upper()
@@ -31,9 +31,9 @@ class DevScanConfig(ScanConfigBase):
31
31
  def get_service_name(self, scan_type: str, should_use_scan_service: bool = False) -> str:
32
32
  if should_use_scan_service:
33
33
  return '5004'
34
- if scan_type == 'secret':
34
+ if scan_type == consts.SECRET_SCAN_TYPE:
35
35
  return '5025'
36
- if scan_type == 'iac':
36
+ if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
37
37
  return '5026'
38
38
 
39
39
  # sca and sast
@@ -47,9 +47,9 @@ class DefaultScanConfig(ScanConfigBase):
47
47
  def get_service_name(self, scan_type: str, should_use_scan_service: bool = False) -> str:
48
48
  if should_use_scan_service:
49
49
  return 'scans'
50
- if scan_type == 'secret':
50
+ if scan_type == consts.SECRET_SCAN_TYPE:
51
51
  return 'secret'
52
- if scan_type == 'iac':
52
+ if scan_type == consts.INFRA_CONFIGURATION_SCAN_TYPE:
53
53
  return 'iac'
54
54
 
55
55
  # sca and sast
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cycode
3
- Version: 2.2.1.dev2
3
+ Version: 2.2.1.dev3
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
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=bSr8UX24Qhqyb8DkxP-yP2BBgUKJ6SDz2M8-bLdnePw,114
1
+ cycode/__init__.py,sha256=vpHVIjFbUE0HZ1vNee8RWTjIDx4aPXE7TjY-L3UxHpw,114
2
2
  cycode/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  cycode/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cycode/cli/commands/ai_remediation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -23,7 +23,7 @@ cycode/cli/commands/report/sbom/repository_url/repository_url_command.py,sha256=
23
23
  cycode/cli/commands/report/sbom/sbom_command.py,sha256=akjbxFcArXW6tnGBXJWTpPjMr28pNmJZGLD7UxKeW6Y,2431
24
24
  cycode/cli/commands/report/sbom/sbom_report_file.py,sha256=fr3HMSr6lppeI3OgYADDWlWD8ij2edN1gmpUOPmeTN0,1533
25
25
  cycode/cli/commands/scan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- cycode/cli/commands/scan/code_scanner.py,sha256=lqK9s8D9uQgmuZwMY-tZf_gvkAbYz7-zNjL69bnChl8,40546
26
+ cycode/cli/commands/scan/code_scanner.py,sha256=3y9Wna6cB97_iLFW6jc7FIfY7d58paKi-BFPgMkm7Ww,40583
27
27
  cycode/cli/commands/scan/commit_history/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  cycode/cli/commands/scan/commit_history/commit_history_command.py,sha256=Yr1MAcrTYvYxdjAFBuvovWs3B5wBFv-N4lZRox_gXDE,1062
29
29
  cycode/cli/commands/scan/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -37,7 +37,7 @@ cycode/cli/commands/scan/repository/repository_command.py,sha256=xH6PPXweenHOll7
37
37
  cycode/cli/commands/scan/scan_ci/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  cycode/cli/commands/scan/scan_ci/ci_integrations.py,sha256=bbttv1pI8C2jQWtvt_mzypFEVi2iTI9TV0xfeIgrs5M,1588
39
39
  cycode/cli/commands/scan/scan_ci/scan_ci_command.py,sha256=wTjNt06gWgNoehg1ueHf9eAXseGE8pUb6wL1_vrIU5w,622
40
- cycode/cli/commands/scan/scan_command.py,sha256=R4MbHrW6Evpikeg3W0r9kUtZUTUGffFkE0B2WeiutJA,5170
40
+ cycode/cli/commands/scan/scan_command.py,sha256=mLyksWNm40nJiP6iV8yNwFfpstx3uN5r3Tr53tfkDjs,5215
41
41
  cycode/cli/commands/status/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  cycode/cli/commands/status/status_command.py,sha256=DlIHHLv7CgmlXd6Kn9p26VF0TfRUmhGKLFc3FUEPQOo,4295
43
43
  cycode/cli/commands/version/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,7 +45,7 @@ cycode/cli/commands/version/version_checker.py,sha256=fuT_REPWh_eQW7OTBETgdeXMa5
45
45
  cycode/cli/commands/version/version_command.py,sha256=CdLccqFoK3_yE13H7QUpxjsEZltke1emN-_qHHpnghU,555
46
46
  cycode/cli/config.py,sha256=JR_-uZdWVV-AaffRqTbDH0V7O4KLGNKn50v3huuPlts,466
47
47
  cycode/cli/config.yaml,sha256=SBs5VNdaY9BVbRlwgnTF_j53GBbjJVwwBj9qx_qvrds,463
48
- cycode/cli/consts.py,sha256=XyqiqjjDsHCDQpmSCgXcAlT8MEj2LcJZygxVqLaRLh0,6878
48
+ cycode/cli/consts.py,sha256=Tqzme0tesEEWOd30fJgSwmpIo-ITb9tHXhc_xrpIoDA,6985
49
49
  cycode/cli/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  cycode/cli/exceptions/common.py,sha256=Si_e8bn_VfsnCww_eN1czF9iBPbQZxS8L8Oy4YoA0cA,954
51
51
  cycode/cli/exceptions/custom_exceptions.py,sha256=7HiXUoh0lnIP7yUwO-lv1p9AXiMU2bIJdlUvu9H6CKY,3466
@@ -77,7 +77,7 @@ cycode/cli/files_collector/sca/sbt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
77
77
  cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py,sha256=hlRoQWEFbap2UYiVdK6HOeWi0Zn3l2Az2A4yWdnnyI0,923
78
78
  cycode/cli/files_collector/sca/sca_code_scanner.py,sha256=E5cIBdjwrL2Exy7U6r9HiZX-ex86QeX7LCkDK2km2Sc,7145
79
79
  cycode/cli/files_collector/walk_ignore.py,sha256=y9gI91F2AIborQb03QcwedBIhzi6r4sKuYLBACqaw3k,1459
80
- cycode/cli/files_collector/zip_documents.py,sha256=64ovgvzG7399bPWIg_g0T3KebSuFpRXZaxBTeNdJ17k,1873
80
+ cycode/cli/files_collector/zip_documents.py,sha256=Trmref-dBdxNUd6deNobkNj2VI_9Gcu5lGkw1DGWwg8,1728
81
81
  cycode/cli/main.py,sha256=TWZxfs7nu-zSm1YU4H801T_u16xeV3S-gZcb4gSSD24,387
82
82
  cycode/cli/models.py,sha256=yxJJsHO-VBVeomVupD8ho_KyUEX-T0n61b23YF6_AMw,2363
83
83
  cycode/cli/printers/__init__.py,sha256=ALwAXSZy2lNXWC3NfCIxf8K0F6eFrbZa9PLZwPINi5E,93
@@ -106,7 +106,7 @@ cycode/cli/utils/ignore_utils.py,sha256=zQqRS_SmuFZfTwmRGnYJHd9lIolYoGDgSAiAIZmr
106
106
  cycode/cli/utils/jwt_utils.py,sha256=M7UxRHQQ1xsWxg0b1Lo85eQxhnhfgBJB4xpe1Y_JZZs,544
107
107
  cycode/cli/utils/path_utils.py,sha256=TqyH-kZxEQHa6rVygr8yBy0fbXSwNu34-ifIKM4n-os,3114
108
108
  cycode/cli/utils/progress_bar.py,sha256=OMG_JF5xIScDvqeOuHcEr6kPcYR1D8n9hzD64uq_-EI,9884
109
- cycode/cli/utils/scan_batch.py,sha256=4zLbnuZ7c-jM-KZCgCKVVXQEhWYWYaTNWOUqL9VLJDY,2794
109
+ cycode/cli/utils/scan_batch.py,sha256=TXEkujV6wqaLyC_FNNtc5LYp-ogFIAxc2kqt1yAB4Tw,2701
110
110
  cycode/cli/utils/scan_utils.py,sha256=d3Cysjagh0RRbIXNmt0rQfgDTtZBJKO9TLntC6CuPbQ,334
111
111
  cycode/cli/utils/shell_executor.py,sha256=jmD8El3wzkLaGwf3iHjbfFhd6Z9MOs9F7sLuIP9MiKg,935
112
112
  cycode/cli/utils/string_utils.py,sha256=W4TMXOQP_PpAfOYemWkUK1TeW_TkQDBCHeTeL0Olcsk,2034
@@ -125,10 +125,10 @@ cycode/cyclient/cycode_token_based_client.py,sha256=tD_HWgkz0VDcU4AQsPxHxGTwfQ8K
125
125
  cycode/cyclient/headers.py,sha256=5KnigR9_1ifxW63z1iYgETfjD3D1v85jkth3oc2fERM,1434
126
126
  cycode/cyclient/models.py,sha256=iUrTtQrIvls1kgtOadCa8QPzsvh8_kj2eZIX73FIIpk,14354
127
127
  cycode/cyclient/report_client.py,sha256=sNLOm64oaONz-TUBs6fpFfbb7RfxALPS6YBqadMo2-8,3971
128
- cycode/cyclient/scan_client.py,sha256=BvoMiwgPImvdyp3n6qKwqGtWxjPkeb1JvBd3QphGkz0,14696
129
- cycode/cyclient/scan_config_base.py,sha256=sM69JOIt6Y0zFT-kp0KXSBjG8ViKl2Y2y6Fh95-57io,1642
130
- cycode-2.2.1.dev2.dist-info/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
131
- cycode-2.2.1.dev2.dist-info/METADATA,sha256=gUjfwkOG3GsNBovL0RYliolaPOFF0QVnSr0N1C3eOT4,45725
132
- cycode-2.2.1.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
133
- cycode-2.2.1.dev2.dist-info/entry_points.txt,sha256=GKZlS6LtUdABDPd7-o9bwNSI5gYQnyA3qGrFFQKt3Vc,51
134
- cycode-2.2.1.dev2.dist-info/RECORD,,
128
+ cycode/cyclient/scan_client.py,sha256=kgtGsxW-7Y_7hlS1ZY0O5xcRm8i3PvRp84PgEWlhD_0,14772
129
+ cycode/cyclient/scan_config_base.py,sha256=JqoC8C8164IuFrhJe540bPWf6_iQOZ2SJXGud72COwo,1780
130
+ cycode-2.2.1.dev3.dist-info/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
131
+ cycode-2.2.1.dev3.dist-info/METADATA,sha256=JF5gXu-j65pl0IjE45PWg-qKh688TB0Ud4VMxiqjCFo,45725
132
+ cycode-2.2.1.dev3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
133
+ cycode-2.2.1.dev3.dist-info/entry_points.txt,sha256=GKZlS6LtUdABDPd7-o9bwNSI5gYQnyA3qGrFFQKt3Vc,51
134
+ cycode-2.2.1.dev3.dist-info/RECORD,,