Skip to content

CodeGuard: A robust code security assessment tool empowering developers with support for 10+ programming languages and detection of 70+ vulnerability types. Ensure secure coding and elevate your tech with cutting-edge protection!

Notifications You must be signed in to change notification settings

ZeroHack01/CodeGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

67 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation



Version Python License Stars


๐Ÿ” Advanced static code analysis tool for comprehensive security vulnerability detection

๐Ÿš€ Installation โ€ข ๐Ÿ“ฑ Web Interface โ€ข ๐Ÿ“– Usage Guide โ€ข ๐Ÿ”ง API Reference โ€ข ๐ŸŒ Languages


๐Ÿ›ก๏ธ What CodeGuard Does

CodeGuard is a cutting-edge static code analyzer that identifies security vulnerabilities using advanced pattern matching and comprehensive code analysis across multiple programming languages.

๐Ÿ” Security Detection

  • Code Injection - eval(), exec(), dynamic execution
  • Authentication Flaws - Hardcoded secrets & credentials
  • Command Injection - System command vulnerabilities
  • Memory Safety - Buffer overflows (C/C++)
  • Web Security - XSS, CSRF, DOM manipulation
  • Database Security - SQL injection patterns
  • Cryptography - Weak algorithms & implementations

๐Ÿ“Š Professional Features

  • Real-time Analysis - Instant vulnerability detection
  • Severity Classification - Critical, High, Medium, Low
  • Smart Recommendations - Auto-generated fix suggestions
  • Multiple Formats - JSON, CSV, HTML reports
  • Web Dashboard - Interactive browser interface
  • REST API - Programmatic access & integration
  • CI/CD Ready - Pipeline integration support

๐Ÿš€ Installation

๐ŸŒ Cross-Platform Installation

๐ŸชŸ Windows

# PowerShell
git clone https://github.com/ZeroHack01/CodeGuard.git
cd CodeGuard

# Virtual Environment
python -m venv venv
venv\Scripts\activate

# Dependencies
pip install -r requirements.txt

# Launch Scanner
python app.py

๐Ÿ’ก Access: http://localhost:5000

๐ŸŽ macOS

# Terminal
git clone https://github.com/ZeroHack01/CodeGuard.git
cd CodeGuard

# Virtual Environment  
python3 -m venv venv
source venv/bin/activate

# Dependencies
pip3 install -r requirements.txt

# Launch Scanner
python3 app.py

๐Ÿ’ก Access: http://localhost:5000

๐Ÿง Linux

# Ubuntu/Debian
sudo apt update && sudo apt install -y \
  python3 python3-pip python3-venv git

# CentOS/RHEL/Fedora
sudo dnf install python3 python3-pip git

# Setup
git clone https://github.com/ZeroHack01/CodeGuard.git
cd CodeGuard
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

# Launch
python3 app.py

๐Ÿ’ก Access: http://localhost:5000

๐Ÿณ Docker Deployment

# Option 1: Docker Hub
docker pull zerohack01/codeguard:latest
docker run -d -p 5000:5000 --name codeguard-scanner zerohack01/codeguard:latest

# Option 2: Build from Source
git clone https://github.com/ZeroHack01/CodeGuard.git && cd CodeGuard
docker build -t codeguard-scanner .
docker run -d -p 5000:5000 --name codeguard-scanner codeguard-scanner

# Container Management
docker stop codeguard-scanner      # Stop container
docker start codeguard-scanner     # Start container  
docker rm codeguard-scanner        # Remove container

๐ŸŒ Web Interface: http://localhost:5000


๐Ÿ“ฑ Web Interface Preview

๐ŸŽฎ Interactive Dashboard

CodeGuard Dashboard

๐ŸŽฏ Main Dashboard - Clean interface for uploading and managing code analysis

๐Ÿ“ค Smart File Upload System

File Upload Interface

๐Ÿ”„ Drag & Drop Upload - Support for multiple files with automatic language detection

๐Ÿ“Š Comprehensive Results Dashboard

Security Analysis Results

๐Ÿ” Detailed Analysis - Line-by-line vulnerability reporting with severity levels and fix recommendations


๐Ÿ“– Usage Guide

๐Ÿง Linux

  1. Access via browser: localhost:5000
  2. Select files for scanning
  3. Process vulnerability analysis
  4. Examine color-coded results
  5. Generate exportable reports

๐Ÿ’ป Command Line Interface

# Python Integration
from scanner import scan_file

# Single file analysis
results = scan_file('vulnerable_app.py')
for vulnerability in results:
    print(f"๐Ÿšจ Line {vulnerability['line']}: {vulnerability['issue']}")
    print(f"   Severity: {vulnerability['severity']}")
# REST API Usage
curl -X POST -F "file=@security_test.py" \
     -H "Content-Type: multipart/form-data" \
     http://localhost:5000/api/scan

๐ŸŒ Supported Languages and Frameworks

</>

Visual distribution of CodeGuard's language detection capabilities


๐Ÿ“‹ Language Details

Language Extensions Security Patterns Framework Support
๐Ÿ Python .py .pyw .pyc eval(), exec(), os.system(), pickle.loads() Django, Flask, FastAPI
๐ŸŸจ JavaScript .js .jsx .mjs innerHTML, eval(), document.write() React, Vue, Angular
โšก TypeScript .ts .tsx .d.ts Type safety issues, XSS vulnerabilities Angular, React TS
๐Ÿ”ต C/C++ .c .cpp .h .hpp gets(), strcpy(), malloc(), system() Native, Qt, Boost
โ˜• Java .java .jar .class Runtime.exec(), reflection, deserialization Spring, Struts, JSF
๐Ÿ˜ PHP .php .phtml .php3 eval(), shell_exec(), include(), mysqli Laravel, Symfony, CodeIgniter
๐Ÿ’Ž Ruby .rb .rbw .rake eval(), system(), send(), constantize() Rails, Sinatra, Hanami
๐Ÿน Go .go .mod .sum exec.Command(), unsafe.Pointer, sql.Query Gin, Echo, Fiber
๐ŸŒ HTML/CSS .html .htm .css Script injection, unsafe protocols Bootstrap, Tailwind

๐Ÿ“Š Total: 9 Languages | 75+ Security Patterns | 83% Average Coverage


๐Ÿ”ง API Reference

๐Ÿ“ก Available Endpoints

Method Endpoint Description Parameters
POST /api/scan Upload and analyze file file (multipart/form-data)
GET / Access web interface None

๐Ÿ“ API Usage Examples

# Upload and scan a file
curl -X POST \
  -F "file=@source_code.py" \
  -H "Accept: application/json" \
  http://localhost:5000/api/scan

# Test with vulnerable Python code
echo 'eval(user_input)' > test.py
curl -X POST -F "file=@test.py" http://localhost:5000/api/scan

# Test with hardcoded credentials
echo 'password = "admin123"' > config.py  
curl -X POST -F "file=@config.py" http://localhost:5000/api/scan

๐Ÿ“‹ Response Format

{
  "success": true,
  "filename": "source_code.py",
  "language": "python",
  "issues": [
    {
      "line": 15,
      "code": "eval(data)",
      "issue": "Code Injection",
      "severity": "Critical"
    }
  ],
  "total_issues": 1
}

๐Ÿ“Š Sample Output

๐Ÿ” Example scan results
{
  "filename": "app.py",
  "language": "python",
  "scan_time": 0.8,
  "issues": [
    {
      "line": 23,
      "code": "eval(user_input)",
      "issue": "Code Injection",
      "severity": "Critical",
      "description": "Dynamic code execution detected"
    },
    {
      "line": 15,
      "code": "password = 'admin123'",
      "issue": "Hardcoded Password",
      "severity": "High",
      "description": "Credentials found in source code"
    },
    {
      "line": 31,
      "code": "os.system(command)",
      "issue": "Command Injection",
      "severity": "High",
      "description": "System command execution risk"
    }
  ],
  "summary": {
    "total_issues": 3,
    "critical": 1,
    "high": 2,
    "medium": 0
  }
}

๐Ÿงช Testing CodeGuard

Create a test file with known vulnerabilities:

# test_vulnerable.py
api_key = "sk-1234567890abcdef"    # Hardcoded credential
user_code = input("Enter code: ")
eval(user_code)                    # Code injection
os.system("ls " + user_path)       # Command injection

Expected result: 3 security issues detected


โš™๏ธ Configuration

๐Ÿ”ง Environment Settings
# Server Configuration
FLASK_HOST=0.0.0.0              # Bind address
FLASK_PORT=5000                 # Port number
FLASK_DEBUG=false               # Debug mode

# File Processing
MAX_FILE_SIZE=10485760          # 10MB limit
UPLOAD_TIMEOUT=30               # 30 seconds

# Scanner Options
SEVERITY_THRESHOLD=medium       # Minimum severity to report
EXPORT_FORMATS=json,csv         # Available export formats

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-detection
  3. Implement your security improvements
  4. Add comprehensive tests
  5. Commit changes: git commit -m "Add new feature"
  6. Push to branch: git push origin feature/amazing-detection
  7. Submit Pull Request

๐Ÿ› Bug Reports & Feature Requests


๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE file for complete terms.

๐Ÿ“ฆ Dependencies

  • Flask - Web framework for the interface
  • Werkzeug - WSGI web application library
  • Other dependencies - See requirements.txt for complete list


๐Ÿ› Report Issues โ€ข ๐Ÿ’ผ LinkedIn โ€ข ๐Ÿ“ง Email

GitHub

โญ Star this repository if CodeGuard helped secure your code!

About

CodeGuard: A robust code security assessment tool empowering developers with support for 10+ programming languages and detection of 70+ vulnerability types. Ensure secure coding and elevate your tech with cutting-edge protection!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published