Spaces:
Running
Running
readme update
Browse files
README.md
CHANGED
|
@@ -10,82 +10,93 @@ pinned: false
|
|
| 10 |
app_port: 8501
|
| 11 |
short_description: AI Python security scanner using CodeBERT and rules.
|
| 12 |
---
|
| 13 |
-
|
| 14 |
-
# -AI-Code-Security-Scanner-Real-time-Vulnerability-Detection-Remediation
|
| 15 |
-
An advanced AI-powered security tool that detects code vulnerabilities (SQLi, XSS, etc.) using hybrid Rule-Based analysis and CodeBERT Deep Learning models. Features interactive dashboards and real-time fix suggestions.
|
| 16 |
-
=======
|
| 17 |
-
# π AI Code Security Scanner
|
| 18 |
|
| 19 |
-
|
| 20 |
-
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="Python 3.9+">
|
| 21 |
-
<img src="https://img.shields.io/badge/π€-Spaces-yellow.svg" alt="Hugging Face Spaces">
|
| 22 |
-
<img src="https://img.shields.io/badge/Streamlit-1.28+-red.svg" alt="Streamlit">
|
| 23 |
-
<img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT">
|
| 24 |
-
</p>
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
---
|
| 29 |
-
|
| 30 |
-
## π Live Demo
|
| 31 |
-
Try it now: [Hugging Face Spaces Demo](https://huggingface.co/spaces/your-username/code-security-scanner)
|
| 32 |
-
|
| 33 |
-
## β¨ Features
|
| 34 |
-
* **π€ AI-Powered Detection**: Combines rule-based analysis with fine-tuned CodeBERT model.
|
| 35 |
-
* **π Multiple Vulnerability Types**: SQL Injection, XSS, Hardcoded Secrets, Command Injection, etc.
|
| 36 |
-
* **π‘ Fix Suggestions**: AI-generated fix recommendations with explanations.
|
| 37 |
-
* **π REST API**: Fully documented FastAPI backend for integration.
|
| 38 |
-
* **π Batch Processing**: Analyze multiple files simultaneously.
|
| 39 |
-
* **π Interactive Dashboard**: Real-time visualization of security scores.
|
| 40 |
-
* **π³ Docker Support**: Easy deployment with Docker & Docker Compose.
|
| 41 |
-
* **π§ CI/CD Pipeline**: Automated testing and deployment.
|
| 42 |
|
| 43 |
---
|
| 44 |
|
| 45 |
-
##
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
| 52 |
-
β β β
|
| 53 |
-
βΌ βΌ βΌ
|
| 54 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
| 55 |
-
β User Input β β Request Cache β β Fix Generator β
|
| 56 |
-
β & Results β β & Logging β β (AI + Rules) β
|
| 57 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
## π¦ Installation
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
```bash
|
| 65 |
-
# 1. Clone repository
|
| 66 |
-
git clone https://github.com/your-username/ai-code-security-scanner.git
|
| 67 |
-
cd ai-code-security-scanner
|
| 68 |
-
|
| 69 |
-
# 2. Create virtual environment
|
| 70 |
-
python -m venv venv
|
| 71 |
-
# On Windows:
|
| 72 |
-
.\venv\Scripts\activate
|
| 73 |
-
# On Mac/Linux:
|
| 74 |
-
source venv/bin/activate
|
| 75 |
-
|
| 76 |
-
# 3. Install dependencies
|
| 77 |
-
pip install -r requirements.txt
|
| 78 |
-
|
| 79 |
-
# 4. Run the application
|
| 80 |
-
streamlit run app.py`
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
## π³ Docker Deployment
|
| 84 |
|
| 85 |
-
#
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
# Access at:
|
| 89 |
-
# - Web UI: http://localhost:8501
|
| 90 |
-
# - API Docs: http://localhost:8000/docs
|
| 91 |
-
>>>>>>> da9f327 (Initial commit: Uploading AI Code Scanner project files and models)
|
|
|
|
| 10 |
app_port: 8501
|
| 11 |
short_description: AI Python security scanner using CodeBERT and rules.
|
| 12 |
---
|
| 13 |
+
# AI Code Security Scanner: Real-time Vulnerability Detection
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
An advanced security orchestration tool that detects critical vulnerabilities (SQLi, XSS, Command Injection) using a **Hybrid Analysis Engine**: combining static rule-based heuristics with deep learning **CodeBERT** models.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
[](https://huggingface.co/spaces/mubi-613/AI-Code-Security-Scanner)
|
| 18 |
|
| 19 |
+
> **Live Demo:** [AI Security Scanner on Hugging Face](https://huggingface.co/spaces/mubi-613/AI-Code-Security-Scanner)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
---
|
| 22 |
|
| 23 |
+
## Core Engineering Features
|
| 24 |
+
* **Hybrid Detection Engine:** Utilizes **AST (Abstract Syntax Tree)** parsing for rule-based detection and fine-tuned **CodeBERT** (Deep Learning) for semantic vulnerability pattern matching.
|
| 25 |
+
* **Automated Remediation:** Generates context-aware "Fix Suggestions" using AI to provide secure code alternatives for identified risks.
|
| 26 |
+
* **Security Dashboard:** Real-time visualization of security scores and vulnerability distribution across large codebases.
|
| 27 |
+
* **Batch Processing:** Optimized for high-throughput scanning of multiple Python files simultaneously using Python's `multiprocessing` capabilities.
|
| 28 |
+
* **REST API Architecture:** Built with a **FastAPI** backend, allowing for easy integration into existing CI/CD pipelines as a security gate.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
## Technical Stack
|
| 33 |
+
* **Deep Learning:** CodeBERT (Transformers), PyTorch
|
| 34 |
+
* **Analysis Engine:** Python AST, Custom Rule-based Heuristics
|
| 35 |
+
* **Backend/Frontend:** FastAPI, Streamlit
|
| 36 |
+
* **Deployment:** Docker, Hugging Face Spaces (Debian Linux)
|
| 37 |
+
|
| 38 |
+
## Installation
|
| 39 |
+
|
| 40 |
+
1. **Clone the repository:**
|
| 41 |
+
```bash
|
| 42 |
+
git clone [https://github.com/mubi0613/AI-Code-Security-Scanner.git](https://github.com/mubi0613/AI-Code-Security-Scanner.git)
|
| 43 |
+
cd AI-Code-Security-Scanner
|
| 44 |
+
|
| 45 |
+
2. **Setup environment:**
|
| 46 |
+
```bash
|
| 47 |
+
python -m venv venv
|
| 48 |
+
# On Windows:
|
| 49 |
+
.\venv\Scripts\activate
|
| 50 |
+
# On Mac/Linux:
|
| 51 |
+
source venv/bin/activate
|
| 52 |
+
|
| 53 |
+
3. **Install dependencies:**
|
| 54 |
+
```bash
|
| 55 |
+
pip install -r requirements.txt
|
| 56 |
+
|
| 57 |
+
4. **Run the application:**
|
| 58 |
+
```bash
|
| 59 |
+
streamlit run app.py`
|
| 60 |
+
|
| 61 |
+
## Docker Deployment
|
| 62 |
+
* Build and run with Docker Compose
|
| 63 |
+
* docker-compose up --build
|
| 64 |
+
|
| 65 |
+
## Access at:
|
| 66 |
+
* - Web UI: http://localhost:8501
|
| 67 |
+
* - API Docs: http://localhost:8000/docs
|
| 68 |
+
|
| 69 |
+
## Project Structure
|
| 70 |
+
|
| 71 |
+
AI-Code-Security-Scanner/
|
| 72 |
+
βββ app.py # Main Streamlit Dashboard & UI Logic
|
| 73 |
+
βββ api_backend.py # FastAPI Server for REST API Access
|
| 74 |
+
βββ combined_detector.py # Hybrid Logic (Rules + CodeBERT Model)
|
| 75 |
+
βββ rule_detector.py # Static Analysis & AST-based Heuristics
|
| 76 |
+
βββ fix_generator.py # AI-powered Remediation Engine
|
| 77 |
+
βββ saved_model/ # Fine-tuned CodeBERT Weights & Config
|
| 78 |
+
βββ docker-compose.yml # Container Orchestration for UI & API
|
| 79 |
+
βββ requirements.txt # Project Dependencies
|
| 80 |
+
βββ README.md # Technical Documentation
|
| 81 |
+
|
| 82 |
+
## Architecture Diagram
|
| 83 |
+
|
| 84 |
+
```mermaid
|
| 85 |
+
graph LR
|
| 86 |
+
subgraph "Frontend Layer"
|
| 87 |
+
A[Streamlit UI] --> B[User Code Input]
|
| 88 |
+
end
|
| 89 |
+
|
| 90 |
+
subgraph "Analysis Engine"
|
| 91 |
+
B --> C{Hybrid Scanner}
|
| 92 |
+
C --> D[Static Rule Engine]
|
| 93 |
+
C --> E[CodeBERT DL Model]
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
subgraph "Remediation & Reporting"
|
| 97 |
+
D & E --> F[Vulnerability Report]
|
| 98 |
+
F --> G[AI Fix Generator]
|
| 99 |
+
G --> H[Final Security Report]
|
| 100 |
+
end
|
| 101 |
+
```
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|