mubi-613 commited on
Commit
98b502b
Β·
1 Parent(s): 432e2da

readme update

Browse files
Files changed (1) hide show
  1. README.md +81 -70
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
- <<<<<<< HEAD
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
- <p align="center">
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
- **AI-powered code security scanner that detects vulnerabilities in Python code using rule-based analysis and machine learning.**
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
- ## πŸ—οΈ Architecture
46
-
47
-
48
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
49
- β”‚ Streamlit UI │────▢│ FastAPI Backend │────▢│ AI Engine β”‚
50
- β”‚ (Frontend) β”‚ β”‚ (REST API) β”‚ β”‚ (Rule+ML) β”‚
51
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
52
- β”‚ β”‚ β”‚
53
- β–Ό β–Ό β–Ό
54
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
55
- β”‚ User Input β”‚ β”‚ Request Cache β”‚ β”‚ Fix Generator β”‚
56
- β”‚ & Results β”‚ β”‚ & Logging β”‚ β”‚ (AI + Rules) β”‚
57
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
58
-
59
-
60
- ## πŸ“¦ Installation
61
 
62
- ### Local Development
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
- # Build and run with Docker Compose
86
- docker-compose up --build
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ [![Hugging Face Space](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Space-yellow)](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