cycode 3.12.3.dev4__py3-none-any.whl → 3.12.3.dev5__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__ = '3.12.3.dev4' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
1
+ __version__ = '3.12.3.dev5' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
@@ -0,0 +1,44 @@
1
+ """Reader for ~/.claude.json configuration file.
2
+
3
+ Extracts user email from the Claude Code global config file
4
+ for use in AI guardrails scan enrichment.
5
+ """
6
+
7
+ import json
8
+ from pathlib import Path
9
+ from typing import Optional
10
+
11
+ from cycode.logger import get_logger
12
+
13
+ logger = get_logger('AI Guardrails Claude Config')
14
+
15
+ _CLAUDE_CONFIG_PATH = Path.home() / '.claude.json'
16
+
17
+
18
+ def load_claude_config(config_path: Optional[Path] = None) -> Optional[dict]:
19
+ """Load and parse ~/.claude.json.
20
+
21
+ Args:
22
+ config_path: Override path for testing. Defaults to ~/.claude.json.
23
+
24
+ Returns:
25
+ Parsed dict or None if file is missing or invalid.
26
+ """
27
+ path = config_path or _CLAUDE_CONFIG_PATH
28
+ if not path.exists():
29
+ logger.debug('Claude config file not found', extra={'path': str(path)})
30
+ return None
31
+ try:
32
+ content = path.read_text(encoding='utf-8')
33
+ return json.loads(content)
34
+ except Exception as e:
35
+ logger.debug('Failed to load Claude config file', exc_info=e)
36
+ return None
37
+
38
+
39
+ def get_user_email(config: dict) -> Optional[str]:
40
+ """Extract user email from Claude config.
41
+
42
+ Reads oauthAccount.emailAddress from the config dict.
43
+ """
44
+ return config.get('oauthAccount', {}).get('emailAddress')
@@ -7,6 +7,7 @@ from pathlib import Path
7
7
  from typing import Optional
8
8
 
9
9
  from cycode.cli.apps.ai_guardrails.consts import AIIDEType
10
+ from cycode.cli.apps.ai_guardrails.scan.claude_config import get_user_email, load_claude_config
10
11
  from cycode.cli.apps.ai_guardrails.scan.types import (
11
12
  CLAUDE_CODE_EVENT_MAPPING,
12
13
  CLAUDE_CODE_EVENT_NAMES,
@@ -207,11 +208,15 @@ class AIHookPayload:
207
208
  # Extract IDE version, model, and generation ID from transcript file
208
209
  ide_version, model, generation_id = _extract_from_claude_transcript(payload.get('transcript_path'))
209
210
 
211
+ # Extract user email from ~/.claude.json
212
+ claude_config = load_claude_config()
213
+ ide_user_email = get_user_email(claude_config) if claude_config else None
214
+
210
215
  return cls(
211
216
  event_name=canonical_event,
212
217
  conversation_id=payload.get('session_id'),
213
218
  generation_id=generation_id,
214
- ide_user_email=None, # Claude Code doesn't provide this in hook payload
219
+ ide_user_email=ide_user_email,
215
220
  model=model,
216
221
  ide_provider=AIIDEType.CLAUDE_CODE.value,
217
222
  ide_version=ide_version,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycode
3
- Version: 3.12.3.dev4
3
+ Version: 3.12.3.dev5
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=lig0eJ_EAA82PNYTdZ4IwBXVHgUIY39vry0nkPTxcQ4,115
1
+ cycode/__init__.py,sha256=FYtGGWFeHBebJ4ZXbcB6omMDRUbH3lV8_EjHiWXUNbQ,115
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=bsfXV85RRb1iz19JRC9gkc5Iv30fnEE1cwA8dg552NQ,6482
@@ -11,9 +11,10 @@ cycode/cli/apps/ai_guardrails/ensure_auth_command.py,sha256=SwgafehweFCPt7Qtbprs
11
11
  cycode/cli/apps/ai_guardrails/hooks_manager.py,sha256=37IcEMCK60pQ8lnuy8GThlq9oeNOfETVp_xYGeJ9EpM,9428
12
12
  cycode/cli/apps/ai_guardrails/install_command.py,sha256=qlklts1Uj6j3urK6jwAWJY-L_DgVaZWuk7vZcpoKPAQ,4571
13
13
  cycode/cli/apps/ai_guardrails/scan/__init__.py,sha256=qJc82XiQGiAuc1sYY8Ij_A-qXpxgLPuayQq8xWlouMA,48
14
+ cycode/cli/apps/ai_guardrails/scan/claude_config.py,sha256=JCPpSHUroH6tF2URoXCsf_AszqrSsSDcpM8ST4uJqHQ,1262
14
15
  cycode/cli/apps/ai_guardrails/scan/consts.py,sha256=drAslw6vW3kxmbCs2qPCUbUPR7PJouT2lsXtu5sD-lQ,1094
15
16
  cycode/cli/apps/ai_guardrails/scan/handlers.py,sha256=e3UlQ6TbFFFAFEAgMUhL5i7bV1mSrmFJuLb9O0FLX2Y,15702
16
- cycode/cli/apps/ai_guardrails/scan/payload.py,sha256=-r8BsvP-VPD3XibyIPKreCjJNVXGpe_9ENPF78NlnkQ,10178
17
+ cycode/cli/apps/ai_guardrails/scan/payload.py,sha256=wUk9PEtVrym0SaChiML8_7KGa0NmpRNIrcojKA3msjU,10409
17
18
  cycode/cli/apps/ai_guardrails/scan/policy.py,sha256=39s8hnxgjny1l6XAO59wsRcAlpW-LG00GUnO0PfqvuY,2566
18
19
  cycode/cli/apps/ai_guardrails/scan/response_builders.py,sha256=tVFJCnGdqSmyileg-idypOihygct7F6T4KHXYlX8y_c,4653
19
20
  cycode/cli/apps/ai_guardrails/scan/scan_command.py,sha256=_2fa6vz8ZmJlvCYrYNoWfX9fWrrpzcNCwL1UD-JxqLM,5618
@@ -198,8 +199,8 @@ cycode/cyclient/report_client.py,sha256=Scq30NeJPzgXv0hPLO1U05AdE9i_2iu6cIrSKpEJ
198
199
  cycode/cyclient/scan_client.py,sha256=6TK5FQkfrvV7PHqRnUzEn1PBNd2oPYVamvIixcUfe3c,16755
199
200
  cycode/cyclient/scan_config_base.py,sha256=mXsPZGYCtp85rv5GIige40yQZXuRcEKUW-VQJ0vgFzk,1201
200
201
  cycode/logger.py,sha256=EfZGRK6VC5rE_LAjIcRrHFiQCueylCDXoG6bvGkrIME,2111
201
- cycode-3.12.3.dev4.dist-info/METADATA,sha256=-FVJcdUsjkhOaDwzI_MuYfe1W1Fzz_lnGJRLVHZlNoI,84350
202
- cycode-3.12.3.dev4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
203
- cycode-3.12.3.dev4.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
204
- cycode-3.12.3.dev4.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
205
- cycode-3.12.3.dev4.dist-info/RECORD,,
202
+ cycode-3.12.3.dev5.dist-info/METADATA,sha256=LTrKb0Le7JLpLCLUjsO3MRgV3qhsA1w5nh33z1Grles,84350
203
+ cycode-3.12.3.dev5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
204
+ cycode-3.12.3.dev5.dist-info/entry_points.txt,sha256=iDcVJM8ByLElVgvBgtYxDjw1kT7O8Mo0LcWZIT5L3Ig,45
205
+ cycode-3.12.3.dev5.dist-info/licenses/LICENCE,sha256=2Wx4N6mD_4xB7-E3hPkZ3MPhpJy__k_I8MaCSO-PDRo,1068
206
+ cycode-3.12.3.dev5.dist-info/RECORD,,