Skip to content

Commit 48d9d2f

Browse files
committed
CM-58022-added mcp server name
removed cycode marker add ai-guardrails scan type
1 parent d794938 commit 48d9d2f

File tree

7 files changed

+18
-21
lines changed

7 files changed

+18
-21
lines changed

cycode/cli/apps/ai_guardrails/consts.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ def _get_cursor_hooks_dir() -> Path:
5656
# Default IDE
5757
DEFAULT_IDE = AIIDEType.CURSOR
5858

59-
# Marker to identify Cycode hooks
60-
CYCODE_MARKER = 'cycode_guardrails'
61-
6259
# Command used in hooks
63-
CYCODE_SCAN_PROMPT_COMMAND = 'cycode scan prompt'
60+
CYCODE_SCAN_PROMPT_COMMAND = 'cycode ai-guardrails scan'
6461

6562

6663
def get_hooks_config(ide: AIIDEType) -> dict:
@@ -78,5 +75,4 @@ def get_hooks_config(ide: AIIDEType) -> dict:
7875
return {
7976
'version': 1,
8077
'hooks': hooks,
81-
CYCODE_MARKER: True,
8278
}

cycode/cli/apps/ai_guardrails/hooks_manager.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import Optional
1111

1212
from cycode.cli.apps.ai_guardrails.consts import (
13-
CYCODE_MARKER,
1413
CYCODE_SCAN_PROMPT_COMMAND,
1514
DEFAULT_IDE,
1615
IDE_CONFIGS,
@@ -100,9 +99,6 @@ def install_hooks(
10099
for entry in entries:
101100
existing['hooks'][event].append(entry)
102101

103-
# Add marker
104-
existing[CYCODE_MARKER] = True
105-
106102
# Save
107103
if save_hooks_file(hooks_path, existing):
108104
return True, f'AI guardrails hooks installed: {hooks_path}'
@@ -140,11 +136,6 @@ def uninstall_hooks(
140136
if not existing['hooks'][event]:
141137
del existing['hooks'][event]
142138

143-
# Remove marker
144-
if CYCODE_MARKER in existing:
145-
del existing[CYCODE_MARKER]
146-
modified = True
147-
148139
if not modified:
149140
return True, 'No Cycode hooks found to remove'
150141

@@ -190,17 +181,20 @@ def get_hooks_status(scope: str = 'user', repo_path: Optional[Path] = None, ide:
190181
if existing is None:
191182
return status
192183

193-
status['cycode_installed'] = existing.get(CYCODE_MARKER, False)
194-
195184
# Check each hook event for this IDE
196185
ide_config = IDE_CONFIGS[ide]
186+
has_cycode_hooks = False
197187
for event in ide_config.hook_events:
198188
entries = existing.get('hooks', {}).get(event, [])
199189
cycode_entries = [e for e in entries if is_cycode_hook_entry(e)]
190+
if cycode_entries:
191+
has_cycode_hooks = True
200192
status['hooks'][event] = {
201193
'total_entries': len(entries),
202194
'cycode_entries': len(cycode_entries),
203195
'enabled': len(cycode_entries) > 0,
204196
}
205197

198+
status['cycode_installed'] = has_cycode_hooks
199+
206200
return status

cycode/cli/apps/ai_guardrails/scan/handlers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ def _setup_scan_context(ctx: typer.Context) -> typer.Context:
248248
# Set up minimal required context
249249
ctx.obj['progress_bar'] = DummyProgressBar([ScanProgressBarSection])
250250
ctx.obj['sync'] = True # Synchronous scan
251+
ctx.obj['scan_type'] = ScanTypeOption.SECRET # AI guardrails always scans for secrets
252+
ctx.obj['severity_threshold'] = SeverityOption.INFO # Report all severities
251253

252254
# Set command name for scan logic
253255
ctx.info_name = 'ai-guardrails'

cycode/cli/apps/ai_guardrails/scan/payload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class AIHookPayload:
2424
# Event-specific data
2525
prompt: Optional[str] = None # For prompt events
2626
file_path: Optional[str] = None # For file_read events
27+
mcp_server_name: Optional[str] = None # For mcp_execution events
2728
mcp_tool_name: Optional[str] = None # For mcp_execution events
2829
mcp_arguments: Optional[dict] = None # For mcp_execution events
2930

@@ -47,6 +48,7 @@ def from_cursor_payload(cls, payload: dict) -> 'AIHookPayload':
4748
ide_version=payload.get('cursor_version'),
4849
prompt=payload.get('prompt', ''),
4950
file_path=payload.get('file_path') or payload.get('path'),
51+
mcp_server_name=payload.get('command'), # MCP server name
5052
mcp_tool_name=payload.get('tool_name') or payload.get('tool'),
5153
mcp_arguments=payload.get('arguments') or payload.get('tool_input') or payload.get('input'),
5254
)

cycode/cli/apps/scan/code_scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _should_use_sync_flow(command_scan_type: str, scan_type: str, sync_option: b
9191
if not sync_option and scan_type != consts.IAC_SCAN_TYPE:
9292
return False
9393

94-
if command_scan_type not in {'path', 'repository', 'prompt'}:
94+
if command_scan_type not in {'path', 'repository', 'ai-guardrails'}:
9595
return False
9696

9797
if scan_type == consts.IAC_SCAN_TYPE:

cycode/cyclient/ai_security_manager_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def create_event(
7575
'generation_id': payload.generation_id,
7676
'block_reason': block_reason,
7777
'cli_scan_id': scan_id,
78+
'mcp_server_name': payload.mcp_server_name,
7879
'mcp_tool_name': payload.mcp_tool_name,
7980
}
8081

tests/cli/commands/ai_guardrails/scan/test_payload.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ def test_from_cursor_payload_mcp_execution_event() -> None:
5050
cursor_payload = {
5151
'hook_event_name': 'beforeMCPExecution',
5252
'conversation_id': 'conv-123',
53-
'tool_name': 'execute_command',
54-
'arguments': {'command': 'ls -la', 'secret': 'password123'},
53+
'command': 'GitLab',
54+
'tool_name': 'discussion_list',
55+
'arguments': {'resource_type': 'merge_request', 'parent_id': 'organization/repo', 'resource_id': '4'},
5556
}
5657

5758
unified = AIHookPayload.from_cursor_payload(cursor_payload)
5859

5960
assert unified.event_name == AiHookEventType.MCP_EXECUTION
60-
assert unified.mcp_tool_name == 'execute_command'
61-
assert unified.mcp_arguments == {'command': 'ls -la', 'secret': 'password123'}
61+
assert unified.mcp_server_name == 'GitLab'
62+
assert unified.mcp_tool_name == 'discussion_list'
63+
assert unified.mcp_arguments == {'resource_type': 'merge_request', 'parent_id': 'organization/repo', 'resource_id': '4'}
6264

6365

6466
def test_from_cursor_payload_with_alternative_field_names() -> None:

0 commit comments

Comments
 (0)