elsiddik commited on
Commit
4439e1a
Β·
verified Β·
1 Parent(s): 8f771b0

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +109 -1
README.md CHANGED
@@ -1,3 +1,111 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-7B-Instruct
4
+ library_name: unsloth
5
+ tags:
6
+ - cybersecurity
7
+ - vulnerability-detection
8
+ - cve
9
+ - code-audit
10
+ - code-repair
11
+ - qwen2.5-coder
12
+ - fine-sec
13
+ datasets:
14
+ - custom-sec-cve
15
+ language:
16
+ - en
17
+ - code
18
+ pipeline_tag: text-generation
19
  ---
20
+
21
+ # πŸ›‘οΈ FineSec-Detector: Specialized Security LLM (Qwen2.5-Coder-7B-Instruct)
22
+
23
+ **FineSec-Detector** is a 7B parameter specialized cybersecurity Large Language Model fine-tuned on high-precision CVE vulnerability reports, real-world exploit benchmarks, and secure code repair patterns using **Unsloth 4-bit QLoRA**.
24
+
25
+ The model acts as an automated Senior Application Security (AppSec) Auditor & Penetration Tester. It audits source code, identifies vulnerabilities, classifies severity & CWE IDs, and produces ready-to-merge secure code patches in structured JSON.
26
+
27
+ ---
28
+
29
+ ## ✨ Key Features
30
+
31
+ - πŸ” **Automated Vulnerability Detection**: Audits Python, C/C++, JavaScript, Go, PHP, Java, and Bash source code.
32
+ - 🎯 **Structured JSON Output**: Produces standardized security reports suitable for CI/CD pipeline integration.
33
+ - 🏷️ **CWE & Severity Classification**: Classifies bugs into standard CWE categories (e.g., CWE-89 SQLi, CWE-79 XSS, CWE-78 RCE, CWE-120 Buffer Overflow) with CVSS-aligned severity levels (`CRITICAL`, `HIGH`, `MEDIUM`, `LOW`).
34
+ - πŸ› οΈ **Remediation & Patching**: Generates diffs and secure code refactors directly replacing vulnerable logic.
35
+
36
+ ---
37
+
38
+ ## πŸš€ Quickstart: Inference
39
+
40
+ ### 1. Using Unsloth (Fastest & Memory Efficient)
41
+
42
+ ```python
43
+ from unsloth import FastLanguageModel
44
+
45
+ # Load model and tokenizer
46
+ model, tokenizer = FastLanguageModel.from_pretrained(
47
+ model_name = "elsiddik/finsec_detector",
48
+ max_seq_length = 1024,
49
+ load_in_4bit = True,
50
+ )
51
+ FastLanguageModel.for_inference(model)
52
+
53
+ # Security audit prompt
54
+ prompt = """### System Prompt:
55
+ You are FineSec-AI, an expert Application Security Engineer. Analyze code snippet for vulnerabilities and output JSON report with fields: 'vulnerabilities' (list of objects with severity, cwe, description, vulnerable_line, fix_code).
56
+
57
+ ### Input Code:
58
+ ```python
59
+ import sqlite3
60
+
61
+ def login(username, password):
62
+ conn = sqlite3.connect('users.db')
63
+ cursor = conn.cursor()
64
+ query = f"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'"
65
+ cursor.execute(query)
66
+ return cursor.fetchone()
67
+ ```
68
+
69
+ ### Security Analysis (JSON):"""
70
+
71
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
72
+ outputs = model.generate(**inputs, max_new_tokens=512, use_cache=True)
73
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
74
+ ```
75
+
76
+ ---
77
+
78
+ ## πŸ“Š Sample Output (Structured JSON)
79
+
80
+ ```json
81
+ {
82
+ "is_vulnerable": true,
83
+ "severity": "CRITICAL",
84
+ "cwe": "CWE-89",
85
+ "vulnerability_type": "SQL Injection",
86
+ "description": "User input is directly concatenated into the SQL query string without parameterization, allowing unauthenticated SQL injection.",
87
+ "vulnerable_code": "query = f\"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'\"",
88
+ "remediation": "Use parameterized SQL queries with placeholder parameters.",
89
+ "fixed_code": "query = 'SELECT * FROM users WHERE username = ? AND password = ?'\ncursor.execute(query, (username, password))"
90
+ }
91
+ ```
92
+
93
+ ---
94
+
95
+ ## βš™οΈ Model Details
96
+
97
+ | Attribute | Details |
98
+ |---|---|
99
+ | **Base Architecture** | Qwen2.5-Coder-7B-Instruct |
100
+ | **Fine-Tuning Method** | QLoRA 4-bit (Unsloth) |
101
+ | **LoRA Target Modules** | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` |
102
+ | **LoRA Rank (r)** | 16 |
103
+ | **LoRA Alpha** | 32 |
104
+ | **Context Window** | 1024 tokens |
105
+ | **License** | Apache-2.0 |
106
+
107
+ ---
108
+
109
+ ## πŸ”’ Intended Use & Disclaimer
110
+
111
+ **FineSec-Detector** is designed for defensive security purposes, code auditing, secure code development, and AppSec integration. Users are responsible for exercising due diligence when integrating model output into production systems.