# 🔒 Security Code Scanner
A powerful Python tool that scans your codebase for security vulnerabilities using Claude AI. This tool analyzes your code files and provides detailed security findings with suggested fixes.
## ✨ Features
- **Multi-language Support**: Scans Python, JavaScript, TypeScript, Java, C/C++, PHP, Ruby, Go, Rust, and many more
- **AI-Powered Analysis**: Uses Claude AI to identify security vulnerabilities with high accuracy
- **Parallel Processing**: Fast scanning with configurable parallel workers
- **Detailed Reports**: Provides vulnerability type, severity, location, and suggested fixes
- **Smart File Filtering**: Automatically skips irrelevant files and directories
- **JSON Output**: Option to save results in JSON format for further processing
- **Inline Comments**: Add vulnerability comments directly to source files for easy review
- **Enhanced Comments**: Include suggested fix code as comments, making it easy to implement fixes
## 🚀 Installation
1. **Clone or download the tool:**
```bash
git clone <repository-url>
cd AI-code-sec-reviewer
```
2. **Install dependencies:**
```bash
pip install -r requirements.txt
```
3. **Set up your Anthropic API key:**
```bash
export ANTHROPIC_API_KEY='your-api-key-here'
```
Or add it to your `.bashrc` or `.zshrc`:
```bash
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc
```
## 📋 Usage
### Basic Usage
Scan a project directory:
```bash
python security_scanner.py /path/to/your/project
```
Scan current directory:
```bash
python security_scanner.py .
```
### Advanced Options
**Increase parallel workers for faster scanning:**
```bash
python security_scanner.py /path/to/project --max-workers 8
```
**Save results to JSON file:**
```bash
python security_scanner.py /path/to/project --output scan_results.json
```
**Combine options:**
```bash
python security_scanner.py /path/to/project --max-workers 6 --output results.json
```
## 📊 Output Format
The tool provides detailed output including:
- **Summary Statistics**: Files analyzed, vulnerability rate, files modified with comments
- **Per-file Analysis**: Each file with vulnerabilities is listed separately
- **Vulnerability Details**:
- Type and severity (High/Medium/Low)
- Line number or code section
- Description of the issue
- Vulnerable code snippet
- Suggested fix with commented code
### Example Output
```
🔒 SECURITY SCAN RESULTS
================================================================================
📊 Summary:
Files analyzed: 15
Files with vulnerabilities: 3
Files modified with comments: 3
Vulnerability rate: 20.0%
🔍 /path/to/project/app.py
------------------------------------------------------------
🔴 HIGH - SQL Injection
Line/Section: 45
Description: User input directly concatenated into SQL query
Vulnerable Code:
query = f"SELECT * FROM users WHERE id = {user_id}"
Suggested Fix:
# Use parameterized queries to prevent SQL injection
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))
💬 Added vulnerability comments to 3 files
Review the comments in your source files for detailed information
📈 VULNERABILITY SUMMARY
================================================================================
Total vulnerabilities found: 5
High severity: 2
Medium severity: 2
Low severity: 1
```
## 🔍 Supported File Types
The scanner automatically detects and analyzes files with these extensions:
- **Web Development**: `.py`, `.js`, `.ts`, `.jsx`, `.tsx`, `.php`, `.rb`
- **Backend**: `.java`, `.cs`, `.go`, `.rs`, `.swift`, `.kt`
- **Systems**: `.c`, `.cpp`, `.cxx`, `.h`, `.hpp`
- **Scripts**: `.sh`, `.bash`, `.ps1`, `.vbs`, `.pl`
- **Data**: `.sql`, `.r`, `.m`
- **Functional**: `.scala`, `.clj`, `.hs`, `.ml`, `.fs`
- **Others**: `.scm`, `.lisp`, `.el`
## 🚫 Skipped Directories and Files
The tool automatically skips:
- **Version Control**: `.git`, `.svn`, `.hg`
- **Dependencies**: `node_modules`, `venv`, `.venv`, `env`
- **Build Artifacts**: `build`, `dist`, `target`, `bin`, `obj`
- **IDE Files**: `.idea`, `.vscode`, `.vs`
- **Cache**: `__pycache__`, `.pytest_cache`, `coverage`
- **Lock Files**: `package-lock.json`, `yarn.lock`, `poetry.lock`
- **Documentation**: `README.md`, `LICENSE`
## ⚙️ Configuration
### Environment Variables
- `ANTHROPIC_API_KEY`: Your Anthropic API key (required)
### Command Line Options
- `project_path`: Path to the project directory to scan (required)
- `--max-workers`: Maximum number of parallel workers (default: 4)
- `--output`: Output file to save results as JSON
- `--add-comments`: Add vulnerability comments directly to source files
## 🔧 Troubleshooting
### Common Issues
**1. API Key Error:**
```
❌ Error: ANTHROPIC_API_KEY environment variable not set
```
**Solution:** Set your API key as shown in the installation section.
**2. No Files Found:**
```
⚠️ No files found to scan
```
**Solution:** Check if the project path is correct and contains code files.
**3. Permission Errors:**
```
❌ Error: [Errno 13] Permission denied
```
**Solution:** Ensure you have read permissions for the project directory.
**4. API Rate Limits:**
```
❌ Error: Rate limit exceeded
```
**Solution:** Reduce the number of parallel workers or wait before retrying.
**5. Comment Addition Failed:**
```
⚠️ Failed to add comments to filename.py
```
**Solution:** Check if the file is writable and not locked by another process.
## 🛡️ Security Considerations
- **API Key Security**: Never commit your API key to version control
- **Code Privacy**: Your code is sent to Claude API for analysis
- **Rate Limits**: Be mindful of API rate limits for large projects
- **False Positives**: Review all findings manually before implementing fixes
- **File Modifications**: The `--add-comments` flag modifies your source files. Consider backing up your code before running
## 🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/AI-CodeScanner",
"name": "ai-code-scanner",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "security, code, scanner, vulnerability, claude, ai, static-analysis",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/a4/f3/0f574c78d6c022f4274307f38e5cf0385c5305c542db5dc0b861f6798eb5/ai-code-scanner-1.0.0.tar.gz",
"platform": null,
"description": "# \ud83d\udd12 Security Code Scanner\n\nA powerful Python tool that scans your codebase for security vulnerabilities using Claude AI. This tool analyzes your code files and provides detailed security findings with suggested fixes.\n\n## \u2728 Features\n\n- **Multi-language Support**: Scans Python, JavaScript, TypeScript, Java, C/C++, PHP, Ruby, Go, Rust, and many more\n- **AI-Powered Analysis**: Uses Claude AI to identify security vulnerabilities with high accuracy\n- **Parallel Processing**: Fast scanning with configurable parallel workers\n- **Detailed Reports**: Provides vulnerability type, severity, location, and suggested fixes\n- **Smart File Filtering**: Automatically skips irrelevant files and directories\n- **JSON Output**: Option to save results in JSON format for further processing\n- **Inline Comments**: Add vulnerability comments directly to source files for easy review\n- **Enhanced Comments**: Include suggested fix code as comments, making it easy to implement fixes\n\n## \ud83d\ude80 Installation\n\n1. **Clone or download the tool:**\n ```bash\n git clone <repository-url>\n cd AI-code-sec-reviewer\n ```\n\n2. **Install dependencies:**\n ```bash\n pip install -r requirements.txt\n ```\n\n3. **Set up your Anthropic API key:**\n ```bash\n export ANTHROPIC_API_KEY='your-api-key-here'\n ```\n \n Or add it to your `.bashrc` or `.zshrc`:\n ```bash\n echo 'export ANTHROPIC_API_KEY=\"your-api-key-here\"' >> ~/.bashrc\n source ~/.bashrc\n ```\n\n## \ud83d\udccb Usage\n\n### Basic Usage\n\nScan a project directory:\n```bash\npython security_scanner.py /path/to/your/project\n```\n\nScan current directory:\n```bash\npython security_scanner.py .\n```\n\n### Advanced Options\n\n**Increase parallel workers for faster scanning:**\n```bash\npython security_scanner.py /path/to/project --max-workers 8\n```\n\n**Save results to JSON file:**\n```bash\npython security_scanner.py /path/to/project --output scan_results.json\n```\n\n**Combine options:**\n```bash\npython security_scanner.py /path/to/project --max-workers 6 --output results.json\n```\n\n## \ud83d\udcca Output Format\n\nThe tool provides detailed output including:\n\n- **Summary Statistics**: Files analyzed, vulnerability rate, files modified with comments\n- **Per-file Analysis**: Each file with vulnerabilities is listed separately\n- **Vulnerability Details**: \n - Type and severity (High/Medium/Low)\n - Line number or code section\n - Description of the issue\n - Vulnerable code snippet\n - Suggested fix with commented code\n\n### Example Output\n\n```\n\ud83d\udd12 SECURITY SCAN RESULTS\n================================================================================\n\n\ud83d\udcca Summary:\n Files analyzed: 15\n Files with vulnerabilities: 3\n Files modified with comments: 3\n Vulnerability rate: 20.0%\n\n\ud83d\udd0d /path/to/project/app.py\n------------------------------------------------------------\n\n\ud83d\udd34 HIGH - SQL Injection\n Line/Section: 45\n Description: User input directly concatenated into SQL query\n Vulnerable Code:\n query = f\"SELECT * FROM users WHERE id = {user_id}\"\n \n Suggested Fix:\n # Use parameterized queries to prevent SQL injection\n query = \"SELECT * FROM users WHERE id = %s\"\n cursor.execute(query, (user_id,))\n\n\ud83d\udcac Added vulnerability comments to 3 files\n Review the comments in your source files for detailed information\n\n\ud83d\udcc8 VULNERABILITY SUMMARY\n================================================================================\n Total vulnerabilities found: 5\n High severity: 2\n Medium severity: 2\n Low severity: 1\n```\n\n## \ud83d\udd0d Supported File Types\n\nThe scanner automatically detects and analyzes files with these extensions:\n\n- **Web Development**: `.py`, `.js`, `.ts`, `.jsx`, `.tsx`, `.php`, `.rb`\n- **Backend**: `.java`, `.cs`, `.go`, `.rs`, `.swift`, `.kt`\n- **Systems**: `.c`, `.cpp`, `.cxx`, `.h`, `.hpp`\n- **Scripts**: `.sh`, `.bash`, `.ps1`, `.vbs`, `.pl`\n- **Data**: `.sql`, `.r`, `.m`\n- **Functional**: `.scala`, `.clj`, `.hs`, `.ml`, `.fs`\n- **Others**: `.scm`, `.lisp`, `.el`\n\n## \ud83d\udeab Skipped Directories and Files\n\nThe tool automatically skips:\n- **Version Control**: `.git`, `.svn`, `.hg`\n- **Dependencies**: `node_modules`, `venv`, `.venv`, `env`\n- **Build Artifacts**: `build`, `dist`, `target`, `bin`, `obj`\n- **IDE Files**: `.idea`, `.vscode`, `.vs`\n- **Cache**: `__pycache__`, `.pytest_cache`, `coverage`\n- **Lock Files**: `package-lock.json`, `yarn.lock`, `poetry.lock`\n- **Documentation**: `README.md`, `LICENSE`\n\n## \u2699\ufe0f Configuration\n\n### Environment Variables\n\n- `ANTHROPIC_API_KEY`: Your Anthropic API key (required)\n\n### Command Line Options\n\n- `project_path`: Path to the project directory to scan (required)\n- `--max-workers`: Maximum number of parallel workers (default: 4)\n- `--output`: Output file to save results as JSON\n- `--add-comments`: Add vulnerability comments directly to source files\n\n## \ud83d\udd27 Troubleshooting\n\n### Common Issues\n\n**1. API Key Error:**\n```\n\u274c Error: ANTHROPIC_API_KEY environment variable not set\n```\n**Solution:** Set your API key as shown in the installation section.\n\n**2. No Files Found:**\n```\n\u26a0\ufe0f No files found to scan\n```\n**Solution:** Check if the project path is correct and contains code files.\n\n**3. Permission Errors:**\n```\n\u274c Error: [Errno 13] Permission denied\n```\n**Solution:** Ensure you have read permissions for the project directory.\n\n**4. API Rate Limits:**\n```\n\u274c Error: Rate limit exceeded\n```\n**Solution:** Reduce the number of parallel workers or wait before retrying.\n\n**5. Comment Addition Failed:**\n```\n\u26a0\ufe0f Failed to add comments to filename.py\n```\n**Solution:** Check if the file is writable and not locked by another process.\n\n## \ud83d\udee1\ufe0f Security Considerations\n\n- **API Key Security**: Never commit your API key to version control\n- **Code Privacy**: Your code is sent to Claude API for analysis\n- **Rate Limits**: Be mindful of API rate limits for large projects\n- **False Positives**: Review all findings manually before implementing fixes\n- **File Modifications**: The `--add-comments` flag modifies your source files. Consider backing up your code before running\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit issues and pull requests.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A powerful Python tool that scans your codebase for security vulnerabilities using Claude AI",
"version": "1.0.0",
"project_urls": {
"Bug Reports": "https://github.com/yourusername/AI-CodeScanner/issues",
"Documentation": "https://github.com/yourusername/AI-CodeScanner#readme",
"Homepage": "https://github.com/yourusername/AI-CodeScanner",
"Source": "https://github.com/yourusername/AI-CodeScanner"
},
"split_keywords": [
"security",
" code",
" scanner",
" vulnerability",
" claude",
" ai",
" static-analysis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5b63436ba6e40b2959f6500c1dcb9ed2775f923fa1db82583a2a288f0c9f1d30",
"md5": "e78441d4cf4376f8a0027c90c686e71b",
"sha256": "6657421b414c1d4dc6e8c653e6594e99620dc0991aa6ef1f2106388262d88cb4"
},
"downloads": -1,
"filename": "ai_code_scanner-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e78441d4cf4376f8a0027c90c686e71b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 9350,
"upload_time": "2025-07-30T05:22:58",
"upload_time_iso_8601": "2025-07-30T05:22:58.118684Z",
"url": "https://files.pythonhosted.org/packages/5b/63/436ba6e40b2959f6500c1dcb9ed2775f923fa1db82583a2a288f0c9f1d30/ai_code_scanner-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a4f30f574c78d6c022f4274307f38e5cf0385c5305c542db5dc0b861f6798eb5",
"md5": "efaf0b3ac6f07c9854e5978eb34cb3cd",
"sha256": "897e6dd6e2854a0ff110cdfad03f983710b075126ef3b09bb20ddb639d6b7aee"
},
"downloads": -1,
"filename": "ai-code-scanner-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "efaf0b3ac6f07c9854e5978eb34cb3cd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 12847,
"upload_time": "2025-07-30T05:22:59",
"upload_time_iso_8601": "2025-07-30T05:22:59.645640Z",
"url": "https://files.pythonhosted.org/packages/a4/f3/0f574c78d6c022f4274307f38e5cf0385c5305c542db5dc0b861f6798eb5/ai-code-scanner-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 05:22:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "AI-CodeScanner",
"github_not_found": true,
"lcname": "ai-code-scanner"
}