cycode 3.18.1.dev8__py3-none-any.whl → 3.18.1.dev10__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
@@ -5,4 +5,4 @@ import time as _time
5
5
  # end-to-end scan duration from the moment the user actually triggered it.
6
6
  _BOOT_WALL: float = _time.time()
7
7
 
8
- __version__ = '3.18.1.dev8' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
8
+ __version__ = '3.18.1.dev10' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -27,7 +27,7 @@ from cycode.cli.files_collector.commit_range_documents import (
27
27
  get_diff_file_content,
28
28
  get_diff_file_path,
29
29
  get_pre_commit_modified_documents,
30
- get_safe_head_reference_for_diff,
30
+ get_staged_diff_index,
31
31
  parse_commit_range,
32
32
  )
33
33
  from cycode.cli.files_collector.documents_walk_ignore import filter_documents_with_cycodeignore
@@ -360,8 +360,7 @@ def _scan_sca_pre_commit(ctx: typer.Context, repo_path: str) -> None:
360
360
  def _scan_secret_pre_commit(ctx: typer.Context, repo_path: str) -> None:
361
361
  progress_bar = ctx.obj['progress_bar']
362
362
  repo = git_proxy.get_repo(repo_path)
363
- head_reference = get_safe_head_reference_for_diff(repo)
364
- diff_index = repo.index.diff(head_reference, create_patch=True, R=True)
363
+ _, diff_index = get_staged_diff_index(repo)
365
364
 
366
365
  progress_bar.set_section_length(ScanProgressBarSection.PREPARE_LOCAL_FILES, len(diff_index))
367
366
 
@@ -15,7 +15,7 @@ from cycode.cli.utils.progress_bar import ScanProgressBarSection
15
15
  from cycode.logger import get_logger
16
16
 
17
17
  if TYPE_CHECKING:
18
- from git import Diff, Repo
18
+ from git import Diff, DiffIndex, Repo
19
19
 
20
20
  from cycode.cli.utils.progress_bar import BaseProgressBar, ProgressBarSection
21
21
 
@@ -47,6 +47,23 @@ def get_safe_head_reference_for_diff(repo: 'Repo') -> str:
47
47
  return consts.GIT_EMPTY_TREE_OBJECT
48
48
 
49
49
 
50
+ def get_staged_diff_index(repo: 'Repo') -> tuple[str, 'DiffIndex']:
51
+ """Diff the index against HEAD, or against the empty tree in repositories with no commits.
52
+
53
+ GitPython only inverts the `R` flag for HEAD, so `R` must be off for the empty tree to keep
54
+ staged content showing up as added lines in both cases.
55
+
56
+ Args:
57
+ repo: Git repository object
58
+
59
+ Returns:
60
+ The reference that was diffed against, and the resulting diff index
61
+ """
62
+ head_reference = get_safe_head_reference_for_diff(repo)
63
+ reverse = head_reference == consts.GIT_HEAD_COMMIT_REV
64
+ return head_reference, repo.index.diff(head_reference, create_patch=True, R=reverse)
65
+
66
+
50
67
  def _does_reach_to_max_commits_to_scan_limit(commit_ids: list[str], max_commits_count: Optional[int]) -> bool:
51
68
  if max_commits_count is None:
52
69
  return False
@@ -411,8 +428,7 @@ def get_pre_commit_modified_documents(
411
428
  diff_documents = []
412
429
 
413
430
  repo = git_proxy.get_repo(repo_path)
414
- head_reference = get_safe_head_reference_for_diff(repo)
415
- diff_index = repo.index.diff(head_reference, create_patch=True, R=True)
431
+ head_reference, diff_index = get_staged_diff_index(repo)
416
432
  progress_bar.set_section_length(progress_bar_section, len(diff_index))
417
433
  for diff in diff_index:
418
434
  progress_bar.update(progress_bar_section)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.18.1.dev8
3
+ Version: 3.18.1.dev10
4
4
  Summary: Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning.
5
5
  License-Expression: MIT
6
6
  License-File: LICENCE
@@ -24,8 +24,8 @@ Requires-Dist: anyio (>=4.0.0,<4.13.0)
24
24
  Requires-Dist: arrow (>=1.0.0,<1.5.0)
25
25
  Requires-Dist: click (>=8.1.0,<8.2.0)
26
26
  Requires-Dist: colorama (>=0.4.3,<0.5.0)
27
- Requires-Dist: gitpython (>=3.1.50,<3.2.0)
28
- Requires-Dist: marshmallow (>=3.15.0,<4.0.0)
27
+ Requires-Dist: gitpython (>=3.1.51,<3.2.0)
28
+ Requires-Dist: marshmallow (>=4.0.1,<4.1.0)
29
29
  Requires-Dist: mcp (>=1.28.1,<2.0.0) ; python_version >= "3.10"
30
30
  Requires-Dist: patch-ng (==1.19.1)
31
31
  Requires-Dist: pathvalidate (>=3.3.1,<4.0.0)
@@ -33,8 +33,8 @@ Requires-Dist: pydantic (>=2.11.5,<3.0.0)
33
33
  Requires-Dist: pyjwt (>=2.8.0,<3.0)
34
34
  Requires-Dist: pyyaml (>=6.0,<7.0)
35
35
  Requires-Dist: requests (>=2.32.4,<3.0)
36
- Requires-Dist: rich (>=13.9.4,<14)
37
- Requires-Dist: tenacity (>=9.0.0,<9.1.0)
36
+ Requires-Dist: rich (>=15.0.0,<16.0.0)
37
+ Requires-Dist: tenacity (>=9.1.2,<9.2.0)
38
38
  Requires-Dist: tomli (>=2.0.0,<3.0.0) ; python_version < "3.11"
39
39
  Requires-Dist: tomli-w (>=1.0.0,<2.0.0)
40
40
  Requires-Dist: typer (>=0.15.3,<0.16.0)
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=_ADS-WcCE9QsO7SVokqG_8FHL-MbpEuqrdB41lf2--g,396
1
+ cycode/__init__.py,sha256=mcaQImNc9D-oAEbP_bIVqMAaT1EOk2hc9yPpgmj0B3o,397
2
2
  cycode/__main__.py,sha256=Z3bD5yrA7yPvAChcADQrqCaZd0ChGI1gdiwALwbWJ6U,104
3
3
  cycode/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cycode/cli/app.py,sha256=AlR2durAEbsa47PDfIj7JtMvJDWA_Dq6wPtVuMJYSCs,10250
@@ -68,7 +68,7 @@ cycode/cli/apps/scan/aggregation_report.py,sha256=8f9kPfO7biNf5OsDZG6UhMPqG6ymoF
68
68
  cycode/cli/apps/scan/code_scanner.py,sha256=e5jAsDp99VyeSoiLLIkm7P3HOYOInaTq8qZ-OytsO3w,17513
69
69
  cycode/cli/apps/scan/commit_history/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  cycode/cli/apps/scan/commit_history/commit_history_command.py,sha256=zTVmN8yeLXGAiCbyDL-EyEzSPNLzcRpP2q6Qq7p4uZA,1011
71
- cycode/cli/apps/scan/commit_range_scanner.py,sha256=beEEwi6f9W_jULGuTsYzpDGmnzCXfcrFxUUmfEmrVhU,17382
71
+ cycode/cli/apps/scan/commit_range_scanner.py,sha256=OB7mmgRrEptvXxwyTeyfTWzq2iFry3-uTVZPIbbs13w,17283
72
72
  cycode/cli/apps/scan/detection_excluder.py,sha256=0zaNa1PxVshATHv8axp4e-xWvmuNQdg_r5DYsdQ9EVo,6432
73
73
  cycode/cli/apps/scan/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  cycode/cli/apps/scan/path/path_command.py,sha256=x4HXqq1Wy6onziKMc6ELQxqeI5k-m3t_T3RG9kQxrq0,591
@@ -104,7 +104,7 @@ cycode/cli/exceptions/handle_errors.py,sha256=za3vQcM_eFTvbT-53tTc6ky-J0wav6lupD
104
104
  cycode/cli/exceptions/handle_report_sbom_errors.py,sha256=bi0EizHtQLL-ovhHRH98CZ7qXdDPLTYnI59Jn1Y5c0E,926
105
105
  cycode/cli/exceptions/handle_scan_errors.py,sha256=1KkBFb7LniflYRr0vMl1FPIZDALPZu1LiXhORGl0jhs,2195
106
106
  cycode/cli/files_collector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- cycode/cli/files_collector/commit_range_documents.py,sha256=ZAU9er6m8_IF9y9KxZoiEaDOiZC35SEfv5VtqKp4AZc,20484
107
+ cycode/cli/files_collector/commit_range_documents.py,sha256=Bvv9MJBoiraXI396A46412x9zgusjPS3g3nWdSFprPE,21095
108
108
  cycode/cli/files_collector/documents_walk_ignore.py,sha256=G4e-3vfP4WZ7wa9-VbZ66xCKCioTXnPBfbrs4_hh8xY,4705
109
109
  cycode/cli/files_collector/file_excluder.py,sha256=atua_L2qDbmhFXj4nB6rDqSn5--MubLGtUPSOXwXUqE,8231
110
110
  cycode/cli/files_collector/iac/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -211,8 +211,8 @@ cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ
211
211
  cycode/cyclient/scan_client.py,sha256=6TK5FQkfrvV7PHqRnUzEn1PBNd2oPYVamvIixcUfe3c,16755
212
212
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
213
213
  cycode/logger.py,sha256=EfZGRK6VC5rE_LAjIcRrHFiQCueylCDXoG6bvGkrIME,2111
214
- cycode-3.18.1.dev8.dist-info/METADATA,sha256=uxydyFv88PdmwQEAoJHlEc1h1rAuPQhz628fwhrHjyc,91049
215
- cycode-3.18.1.dev8.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
216
- cycode-3.18.1.dev8.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
217
- cycode-3.18.1.dev8.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
218
- cycode-3.18.1.dev8.dist-info/RECORD,,
214
+ cycode-3.18.1.dev10.dist-info/METADATA,sha256=I_frs2zuzTXDX9uszUgQxMLrRg15iYCaJYXwDCmwCZc,91053
215
+ cycode-3.18.1.dev10.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
216
+ cycode-3.18.1.dev10.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
217
+ cycode-3.18.1.dev10.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
218
+ cycode-3.18.1.dev10.dist-info/RECORD,,