cycode 3.28.1.dev4__py3-none-any.whl → 3.28.2.dev1__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.28.1.dev4' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
8
+ __version__ = '3.28.2.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -27,7 +27,7 @@ from cycode.cli.apps.ai_guardrails.ides.base import HookDecision
27
27
  from cycode.cli.apps.ai_guardrails.scan.mcp_server_status import is_enforced, load_mcp_server_statuses
28
28
  from cycode.cli.apps.ai_guardrails.scan.payload import AIHookPayload
29
29
  from cycode.cli.apps.ai_guardrails.scan.policy import get_policy_value
30
- from cycode.cli.apps.ai_guardrails.scan.prompt_images import PromptImage
30
+ from cycode.cli.apps.ai_guardrails.scan.prompt_images import PromptImage, read_prompt_image
31
31
  from cycode.cli.apps.ai_guardrails.scan.types import (
32
32
  SECRETS_BLOCK_REASON_BY_EVENT_TYPE,
33
33
  AiHookEventType,
@@ -586,6 +586,22 @@ def _scan_text_for_secrets(
586
586
  return _scan_documents_for_secrets(ctx, documents, timeout_ms, payload, event_type)
587
587
 
588
588
 
589
+ def _file_document(file_path: str, max_bytes: int) -> Document:
590
+ """The file to scan as a document: an image as its bytes, anything else as its text, up to ``max_bytes``.
591
+
592
+ An image is what a prompt's attachment is scanned as (read_prompt_image). Its name keeps its format's extension
593
+ (PromptImage.file_name), as the server picks the files to scan by extension as well as signature.
594
+ """
595
+ image_content = read_prompt_image(file_path)
596
+ if image_content is not None:
597
+ image = PromptImage(path=file_path, content=image_content)
598
+ return Document(path=image.file_name, content=image.content, is_git_diff_format=False, absolute_path=file_path)
599
+
600
+ with open(file_path, encoding='utf-8', errors='replace') as f:
601
+ content = f.read(max_bytes)
602
+ return Document(path=os.path.basename(file_path), content=content, is_git_diff_format=False)
603
+
604
+
589
605
  def _scan_path_for_secrets(
590
606
  ctx: typer.Context,
591
607
  file_path: str,
@@ -601,13 +617,10 @@ def _scan_path_for_secrets(
601
617
  return NO_SCAN
602
618
 
603
619
  max_bytes = get_policy_value(policy, 'secrets', 'max_bytes', default=200000)
604
-
605
- with open(file_path, encoding='utf-8', errors='replace') as f:
606
- content = f.read(max_bytes)
620
+ document = _file_document(file_path, max_bytes)
607
621
 
608
622
  timeout_ms = get_policy_value(policy, 'secrets', 'timeout_ms', default=30000)
609
623
 
610
- document = Document(path=os.path.basename(file_path), content=content, is_git_diff_format=False)
611
624
  return _scan_documents_for_secrets(
612
625
  ctx, [document], timeout_ms, payload, AiHookEventType.FILE_READ, paths=(file_path,)
613
626
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.28.1.dev4
3
+ Version: 3.28.2.dev1
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
@@ -1,4 +1,4 @@
1
- cycode/__init__.py,sha256=0s__sg2RCz090s5qEmM8ExMgXC5_vXIVP46HdcDVKVA,396
1
+ cycode/__init__.py,sha256=qXdLzXdWg_EOHpl4O9fzq2glF0aDvMXx3_sgj3XMwbA,396
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=sI6wBHmfo7RchO9rnOXaQyUHRG9fm4r9aIduV4ZOD5c,10167
@@ -23,7 +23,7 @@ cycode/cli/apps/ai_guardrails/scan/__init__.py,sha256=qJc82XiQGiAuc1sYY8Ij_A-qXp
23
23
  cycode/cli/apps/ai_guardrails/scan/consts.py,sha256=8H8JXlgm65sYkgTXqsBInHhHe80UPjqY4vumZXB4GGM,1060
24
24
  cycode/cli/apps/ai_guardrails/scan/detach.py,sha256=8BRgBq9Qi8nXEx6NKlE8scSRPkO30XCfsiI5PLvq6Gk,2700
25
25
  cycode/cli/apps/ai_guardrails/scan/guardrail_config.py,sha256=cU5DqsPvt_dejkiDhbN7ve--1LlT-VuQvLv70kWUtJs,7911
26
- cycode/cli/apps/ai_guardrails/scan/handlers.py,sha256=P_stqp2abf-nyhgM7Mn3Xfh2nxjBQfbzcOFPzIWNyTc,24140
26
+ cycode/cli/apps/ai_guardrails/scan/handlers.py,sha256=B9VvOBT0-y8j9X0dlW_8IXu0lJkm_DPNHudKwKL008A,24880
27
27
  cycode/cli/apps/ai_guardrails/scan/mcp_server_status.py,sha256=44wij2VtjsB7cffxEnEBqQ5RInmzLROwOC0VwtDRl4s,4355
28
28
  cycode/cli/apps/ai_guardrails/scan/payload.py,sha256=Ntwn6f71VsZxgztPoa4UN9pJvp9KnP4ctN1qobY7QaY,1881
29
29
  cycode/cli/apps/ai_guardrails/scan/policy.py,sha256=nqLjWqNty-p4pk4mSCyy7EfqavUNCdP3nUSkKC7QRMY,4984
@@ -227,8 +227,8 @@ cycode/cyclient/report_client.py,sha256=PaKEo6Q0GFVdpNC18vvR4uBoUX1MnllVmKkS72eA
227
227
  cycode/cyclient/scan_client.py,sha256=ft80sGTsW-BW4bECuGdfLv0CrSdIkp_RLlGfwHVf_Fs,17325
228
228
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
229
229
  cycode/logger.py,sha256=OHmfkf4dnyZgfixGqkWf3js3uysrOXU_4cS8TChtAzc,2079
230
- cycode-3.28.1.dev4.dist-info/METADATA,sha256=5Ui6nHF2yrW5Fn-ThYxKq_CSrTN2sIwB27es98Dn3U8,97154
231
- cycode-3.28.1.dev4.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
232
- cycode-3.28.1.dev4.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
233
- cycode-3.28.1.dev4.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
234
- cycode-3.28.1.dev4.dist-info/RECORD,,
230
+ cycode-3.28.2.dev1.dist-info/METADATA,sha256=Kfzh1IzPilELM_6u5bMgzrs-zvdMEq-k5kzxxtj8_Ck,97154
231
+ cycode-3.28.2.dev1.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
232
+ cycode-3.28.2.dev1.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
233
+ cycode-3.28.2.dev1.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
234
+ cycode-3.28.2.dev1.dist-info/RECORD,,