AI-powered security code reviewer using a fine-tuned Qwen2.5-Coder LLM
Project description
llm-security-reviewer
AI-powered security code reviewer using a fine-tuned Qwen2.5-Coder-7B LLM. Scans code for vulnerabilities, reports CWE identifiers, and integrates directly with GitHub Pull Requests.
Requirements
- Python 3.10+
- NVIDIA GPU with CUDA (required — the model runs in 4-bit quantization)
- 8GB+ VRAM recommended
Installation
pip install llm-security-reviewer
Setup
Download the fine-tuned adapter weights and place them in a folder called adapters/:
your-project/
└── adapters/
├── adapter_config.json
└── adapter_model.safetensors
For GitHub PR reviews, set your token as an environment variable:
# Windows
set GITHUB_TOKEN=your_token_here
# Linux / macOS
export GITHUB_TOKEN=your_token_here
Usage
Review a local file:
llm-reviewer --file path/to/main.c --adapters path/to/adapters
Review a code snippet directly:
llm-reviewer --code "void login() { gets(password); }" --adapters path/to/adapters
Review a GitHub Pull Request:
llm-reviewer --pr 42 --repo owner/repo --adapters path/to/adapters
Supported file types: .c, .cpp, .h, .py, .js, .ts, .java, .go, .php, .rb, .rs, .cs
Example Output
============================================================
SECURITY REVIEW REPORT
============================================================
Files/Functions reviewed : 4
Vulnerabilities found : 2
Status: REVIEW NEEDED
============================================================
[1] main.c — function 1
Verdict : VULNERABLE
CWE : CWE-120
Review :
Buffer overflow via gets(). No bounds checking on input.
Attacker can overwrite stack memory.
[2] main.c — function 2
Verdict : SAFE
CWE : N/A
Review :
Uses fgets() with explicit buffer size. No issues found.
RECOMMENDATION: Do not merge. Address the vulnerabilities above before merging.
Running Tests
pip install llm-security-reviewer[dev]
pytest tests/ -v
Troubleshooting
If the program only uses your CPU, make sure you have the right version of torch installed. Uninstall current version. Run nvidia-smi and check your CUDA version in the top right corner (CUDA Version: XX.X) Install torch for the right cuda version by replacing cuXXX with your CUDA version (exception: for CUDA 13.1+ you have to use 130)
pip uninstall torch torchvision torchaudio
nvidia-smi
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXX
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_security_reviewer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: llm_security_reviewer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4c25a0f6102ff54180e7c271b1bd50e19635002e3f8dac7a62d079a63a336b9
|
|
| MD5 |
4b63c2ab53b8d13f125fdc9e997b4a33
|
|
| BLAKE2b-256 |
cd2c2312a512ed31deffcfd206634e7b723a7b2265eb450febcd828ab5640ea3
|