Skip to content
Open
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ cd claude-code-security-review
pytest claudecode -v
```

## Windows setup

To run the Claude Code Security Review on Windows:

1. Install Node.js (v18 or later) and npm:
- Download from https://nodejs.org or use nvm-windows.
2. Install the Claude CLI:npm install -g @anthropic-ai/claude-code
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after colon. Should be '2. Install the Claude CLI: npm install -g @anthropic-ai/claude-code'.

Suggested change
2. Install the Claude CLI:npm install -g @anthropic-ai/claude-code
2. Install the Claude CLI: npm install -g @anthropic-ai/claude-code

Copilot uses AI. Check for mistakes.


3. Add npm global directory to PATH:$npmPath = npm config get prefix
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$npmPath", "User")

4. Set PowerShell execution policy:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after colon. Should be '4. Set PowerShell execution policy: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned'.

Suggested change
4. Set PowerShell execution policy:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
4. Set PowerShell execution policy: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

Copilot uses AI. Check for mistakes.

5. Verify installation:claude --version
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after colon. Should be '3. Add npm global directory to PATH: $npmPath = npm config get prefix'.

Suggested change
5. Verify installation:claude --version
2. Install the Claude CLI: npm install -g @anthropic-ai/claude-code
3. Add npm global directory to PATH: $npmPath = npm config get prefix
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$npmPath", "User")
4. Set PowerShell execution policy: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
5. Verify installation: claude --version

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after colon. Should be '5. Verify installation: claude --version'.

Suggested change
5. Verify installation:claude --version
5. Verify installation: claude --version

Copilot uses AI. Check for mistakes.


Expected output: 1.0.71 (Claude Code) or similar.

Troubleshooting
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'Troubleshooting' section should be formatted as a proper header with markdown syntax (## Troubleshooting).

Suggested change
Troubleshooting
## Troubleshooting

Copilot uses AI. Check for mistakes.


Claude CLI not found: Ensure claude.ps1 or claude.cmd is in PATH and execution policy is RemoteSigned.
Test failures: Verify npm is installed and check logs in github_action_audit.py for errors.

## Support

For issues or questions:
Expand Down
8 changes: 8 additions & 0 deletions claudecode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
main
)

# Auto-apply Windows compatibility patches if needed
try:
from claudecode.windows_patches import auto_patch_if_needed
auto_patch_if_needed()
except ImportError:
# Windows patches not available, continue normally
pass

__all__ = [
"GitHubActionClient",
"SimpleClaudeRunner",
Expand Down
44 changes: 15 additions & 29 deletions claudecode/github_action_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SUBPROCESS_TIMEOUT
)
from claudecode.logger import get_logger
from claudecode.platform_utils import run_claude_subprocess, get_platform_adapter

logger = get_logger(__name__)

Expand Down Expand Up @@ -230,7 +231,7 @@ def run_security_audit(self, repo_dir: Path, prompt: str) -> Tuple[bool, str, Di
# Run Claude Code with retry logic
NUM_RETRIES = 3
for attempt in range(NUM_RETRIES):
result = subprocess.run(
result = run_claude_subprocess(
cmd,
input=prompt, # Pass prompt via stdin
cwd=repo_dir,
Expand Down Expand Up @@ -313,34 +314,19 @@ def _extract_security_findings(self, claude_output: Any) -> Dict[str, Any]:

def validate_claude_available(self) -> Tuple[bool, str]:
"""Validate that Claude Code is available."""
try:
result = subprocess.run(
['claude', '--version'],
capture_output=True,
text=True,
timeout=10
)

if result.returncode == 0:
# Also check if API key is configured
api_key = os.environ.get('ANTHROPIC_API_KEY', '')
if not api_key:
return False, "ANTHROPIC_API_KEY environment variable is not set"
return True, ""
else:
error_msg = f"Claude Code returned exit code {result.returncode}"
if result.stderr:
error_msg += f". Stderr: {result.stderr}"
if result.stdout:
error_msg += f". Stdout: {result.stdout}"
return False, error_msg

except subprocess.TimeoutExpired:
return False, "Claude Code command timed out"
except FileNotFoundError:
return False, "Claude Code is not installed or not in PATH"
except Exception as e:
return False, f"Failed to check Claude Code: {str(e)}"
# Use platform adapter for robust cross-platform validation
platform_adapter = get_platform_adapter()
is_available, error_msg = platform_adapter.validate_claude_availability()

if not is_available:
return False, error_msg

# Also check if API key is configured
api_key = os.environ.get('ANTHROPIC_API_KEY', '')
if not api_key:
return False, "ANTHROPIC_API_KEY environment variable is not set"

return True, ""



Expand Down
Loading